JS_NATIVE_ERROR_COUNT, /* number of different NativeError objects */
} JSErrorEnum;
-#define JS_MAX_LOCAL_VARS 65535
+/* the variable and scope indexes must fit on 16 bits. The (-1) and
+ ARG_SCOPE_END values are reserved. */
+#define JS_MAX_LOCAL_VARS 65534
#define JS_STACK_SIZE_MAX 65534
#define JS_STRING_LEN_MAX ((1 << 30) - 1)
JSValueConst obj;
int scope_idx;
call_argc = get_u16(pc);
- scope_idx = get_u16(pc + 2) - 1;
+ scope_idx = get_u16(pc + 2) + ARG_SCOPE_END;
pc += 4;
call_argv = sp - call_argc;
sf->cur_pc = pc;
JSValue *tab;
JSValueConst obj;
- scope_idx = get_u16(pc) - 1;
+ scope_idx = get_u16(pc) + ARG_SCOPE_END;
pc += 2;
tab = build_arg_list(ctx, &len, sp[-1]);
if (!tab)
mark_eval_captured_variables(ctx, s, scope);
dbuf_putc(&bc_out, op);
dbuf_put_u16(&bc_out, call_argc);
- dbuf_put_u16(&bc_out, s->scopes[scope].first + 1);
+ dbuf_put_u16(&bc_out, s->scopes[scope].first - ARG_SCOPE_END);
}
break;
case OP_apply_eval: /* convert scope index to adjusted variable index */
scope = get_u16(bc_buf + pos + 1);
mark_eval_captured_variables(ctx, s, scope);
dbuf_putc(&bc_out, op);
- dbuf_put_u16(&bc_out, s->scopes[scope].first + 1);
+ dbuf_put_u16(&bc_out, s->scopes[scope].first - ARG_SCOPE_END);
break;
case OP_scope_get_var_checkthis:
case OP_scope_get_var_undef: