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.

mark scopes created during ESM loading as module scope

+15 -4
+1
include/common.h
··· 51 51 SLOT_HOISTED_VARS, 52 52 SLOT_HOISTED_VARS_LEN, 53 53 SLOT_STRICT_EVAL_SCOPE, 54 + SLOT_MODULE_SCOPE, 54 55 SLOT_STRICT_ARGS, 55 56 SLOT_NO_FUNC_DECLS, 56 57 SLOT_MAX = 255
+14 -4
src/ant.c
··· 12284 12284 12285 12285 static jsval_t find_var_scope(struct js *js) { 12286 12286 jsval_t scope = js->scope; 12287 + 12287 12288 jsval_t eval_marker = get_slot(js, scope, SLOT_STRICT_EVAL_SCOPE); 12288 - if (vtype(eval_marker) == T_BOOL) return scope; 12289 + if (vtype(eval_marker) != T_UNDEF) return scope; 12290 + 12291 + jsval_t module_marker = get_slot(js, scope, SLOT_MODULE_SCOPE); 12292 + if (vtype(module_marker) != T_UNDEF) return scope; 12289 12293 12290 12294 if ((js->flags & F_CALL) && global_scope_stack && utarray_len(global_scope_stack) > 0) { 12291 12295 jsoff_t *scope_off = (jsoff_t *)utarray_back(global_scope_stack); ··· 12294 12298 12295 12299 while (vdata(upper(js, scope)) != 0) { 12296 12300 jsval_t parent = upper(js, scope); 12301 + 12297 12302 jsval_t parent_eval_marker = get_slot(js, parent, SLOT_STRICT_EVAL_SCOPE); 12298 - if (vtype(parent_eval_marker) == T_BOOL) return scope; 12303 + if (vtype(parent_eval_marker) != T_UNDEF) return scope; 12304 + 12305 + jsval_t parent_module_marker = get_slot(js, parent, SLOT_MODULE_SCOPE); 12306 + if (vtype(parent_module_marker) != T_UNDEF) return scope; 12307 + 12299 12308 scope = parent; 12300 12309 } 12310 + 12301 12311 return scope; 12302 12312 } 12303 12313 ··· 20370 20380 jsval_t saved_scope = js->scope; 20371 20381 20372 20382 js_set_filename(js, mod->resolved_path); 20373 - mkscope(js); 20383 + mkscope(js); set_slot(js, js->scope, SLOT_MODULE_SCOPE, tov(1)); 20374 20384 20375 20385 jsval_t result = js_eval(js, js_code, js_len); 20376 20386 free(content); ··· 22943 22953 22944 22954 if (is_strict) { 22945 22955 mkscope(js); 22946 - set_slot(js, js->scope, SLOT_STRICT_EVAL_SCOPE, js_mktrue()); 22956 + set_slot(js, js->scope, SLOT_STRICT_EVAL_SCOPE, tov(1)); 22947 22957 } 22948 22958 22949 22959 hoist_function_declarations(js);