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 strict eval scope support

+17 -9
+1
include/config.h
··· 63 63 SLOT_SUBSCRIPTION_CLEANUP, 64 64 SLOT_HOISTED_VARS, 65 65 SLOT_HOISTED_VARS_LEN, 66 + SLOT_STRICT_EVAL_SCOPE, 66 67 SLOT_MAX = 255 67 68 } internal_slot_t; 68 69
+1
include/config.h.in
··· 52 52 SLOT_SUBSCRIPTION_CLEANUP, 53 53 SLOT_HOISTED_VARS, 54 54 SLOT_HOISTED_VARS_LEN, 55 + SLOT_STRICT_EVAL_SCOPE, 55 56 SLOT_MAX = 255 56 57 } internal_slot_t; 57 58
+15 -9
src/ant.c
··· 6446 6446 } 6447 6447 6448 6448 if (global_scope_stack == NULL) utarray_new(global_scope_stack, &jsoff_icd); 6449 - utarray_push_back(global_scope_stack, &parent_scope_offset); 6450 6449 jsval_t function_scope = mkobj(js, parent_scope_offset); 6450 + jsoff_t function_scope_offset = (jsoff_t)vdata(function_scope); 6451 + utarray_push_back(global_scope_stack, &function_scope_offset); 6451 6452 6452 6453 const char *caller_code = js->code; 6453 6454 jsoff_t caller_clen = js->clen; ··· 6568 6569 (void)vstr(js, slot_name, &len); 6569 6570 if (len > 0) mkprop_fast(js, function_scope, slot_name, func_val, CONSTMASK); 6570 6571 } 6572 + 6573 + if (vtype(func_val) == T_FUNC) { 6574 + jsval_t func_obj = mkval(T_OBJ, vdata(func_val)); 6575 + hoist_var_declarations_from_slot(js, function_scope, func_obj); 6576 + } 6571 6577 6572 6578 if (func_strict && (vtype(target_this) == T_UNDEF || vtype(target_this) == T_NULL || 6573 6579 (vtype(target_this) == T_OBJ && vdata(target_this) == 0))) { ··· 12204 12210 } 12205 12211 12206 12212 static jsval_t find_var_scope(struct js *js) { 12213 + jsval_t scope = js->scope; 12214 + jsval_t eval_marker = get_slot(js, scope, SLOT_STRICT_EVAL_SCOPE); 12215 + if (vtype(eval_marker) == T_BOOL) return scope; 12216 + 12207 12217 if ((js->flags & F_CALL) && global_scope_stack && utarray_len(global_scope_stack) > 0) { 12208 - jsoff_t *scope_off = (jsoff_t *)utarray_eltptr(global_scope_stack, 0); 12218 + jsoff_t *scope_off = (jsoff_t *)utarray_back(global_scope_stack); 12209 12219 if (scope_off && *scope_off != 0) return mkval(T_OBJ, *scope_off); 12210 12220 } 12211 12221 12212 - jsval_t scope = js->scope; 12213 - jsoff_t eval_marker = lkp(js, scope, "__strict_eval_scope__", 21); 12214 - if (eval_marker != 0) return scope; 12215 - 12216 12222 while (vdata(upper(js, scope)) != 0) { 12217 12223 jsval_t parent = upper(js, scope); 12218 - jsoff_t parent_eval_marker = lkp(js, parent, "__strict_eval_scope__", 21); 12219 - if (parent_eval_marker != 0) return scope; 12224 + jsval_t parent_eval_marker = get_slot(js, parent, SLOT_STRICT_EVAL_SCOPE); 12225 + if (vtype(parent_eval_marker) == T_BOOL) return scope; 12220 12226 scope = parent; 12221 12227 } 12222 12228 return scope; ··· 22780 22786 22781 22787 if (is_strict) { 22782 22788 mkscope(js); 22783 - setprop(js, js->scope, js_mkstr(js, "__strict_eval_scope__", 21), js_mktrue()); 22789 + set_slot(js, js->scope, SLOT_STRICT_EVAL_SCOPE, js_mktrue()); 22784 22790 } 22785 22791 22786 22792 hoist_function_declarations(js);