MIRROR: javascript for ๐Ÿœ's, a tiny runtime with big ambitions
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

add loop block scope synchronization

+15 -18
+15 -18
src/ant.c
··· 10257 10257 return js_block_or_stmt(js); 10258 10258 } 10259 10259 10260 + static inline void loop_block_sync_scope(struct js *js, loop_block_ctx_t *ctx) { 10261 + struct for_let_ctx *flc = for_let_current(js); 10262 + if (flc && vtype(flc->body_scope) == T_OBJ) ctx->loop_scope = flc->body_scope; 10263 + } 10264 + 10260 10265 #define loop_block_clear(js, ctx) if ((ctx)->needs_scope) scope_clear_props(js, (ctx)->loop_scope) 10261 10266 #define loop_block_cleanup(js, ctx) if ((ctx)->needs_scope) delscope(js) 10262 10267 ··· 10803 10808 js->flags |= F_LOOP; 10804 10809 js->pos = pos3; 10805 10810 js->consumed = 1; 10811 + 10812 + if (is_let_loop && let_var_len > 0 && loop_ctx.needs_scope) { 10813 + loop_block_sync_scope(js, &loop_ctx); 10814 + } 10815 + 10806 10816 loop_block_clear(js, &loop_ctx); 10807 10817 v = loop_block_exec(js, &loop_ctx); 10808 10818 if (is_err2(&v, &res)) { 10809 10819 loop_block_cleanup(js, &loop_ctx); 10810 - if (is_let_loop && let_var_len > 0) { 10811 - for_let_pop(js); delscope(js); 10812 - } 10820 + if (is_let_loop && let_var_len > 0) for_let_pop(js); delscope(js); 10813 10821 goto done; 10814 10822 } 10815 10823 ··· 10901 10909 js->consumed = 1; 10902 10910 10903 10911 v = resolveprop(js, js_expr(js)); 10904 - if (is_err(v)) { 10905 - res = v; 10906 - break; 10907 - } 10912 + if (is_err(v)) { res = v; break; } 10908 10913 10909 10914 if (!js_truthy(js, v)) break; 10910 10915 ··· 10914 10919 10915 10920 loop_block_clear(js, &loop_ctx); 10916 10921 v = loop_block_exec(js, &loop_ctx); 10917 - if (is_err(v)) { 10918 - res = v; break; 10919 - } 10922 + if (is_err(v)) res = v; break; 10920 10923 10921 10924 if (label_flags & F_CONTINUE_LABEL) { 10922 10925 if (is_this_loop_continue_target(marker_index)) { ··· 10926 10929 } 10927 10930 } 10928 10931 10929 - if (js->flags & F_BREAK) { 10930 - break; 10931 - } 10932 - 10933 - if (js->flags & F_RETURN) { 10934 - res = v; 10935 - break; 10936 - } 10932 + if (js->flags & F_BREAK) break; 10933 + if (js->flags & F_RETURN) { res = v; break; } 10937 10934 } 10938 10935 loop_block_cleanup(js, &loop_ctx); 10939 10936 }