diff options
author | Jo-Philipp Wich <jo@mein.io> | 2021-05-04 16:01:13 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-04 16:01:13 +0200 |
commit | 799c9f4dbe123536e1dde1639a122f48dcf75a05 (patch) | |
tree | edcf626dc7a68398e8ac9a9793aa0ebb9a9cf042 /vm.c | |
parent | a5aead5161821b2f5be9ae76f1bd76e8814147bd (diff) | |
parent | a36e0dfd8432a0c345ab3a710280f6d4f663bddc (diff) |
Merge pull request #8 from jow-/introduce-use-strict
syntax: implement support for 'use strict' pragma
Diffstat (limited to 'vm.c')
-rw-r--r-- | vm.c | 14 |
1 files changed, 11 insertions, 3 deletions
@@ -158,6 +158,12 @@ uc_vm_current_chunk(uc_vm *vm) return uc_vm_frame_chunk(uc_vm_current_frame(vm)); } +static bool +uc_vm_is_strict(uc_vm *vm) +{ + return uc_vm_current_frame(vm)->strict; +} + static enum insn_type uc_vm_decode_insn(uc_vm *vm, uc_callframe *frame, uc_chunk *chunk) { @@ -503,6 +509,7 @@ uc_vm_call_function(uc_vm *vm, uc_value_t *ctx, uc_value_t *fno, bool mcall, siz frame->ctx = ctx; frame->ip = function->chunk.entries; frame->mcall = mcall; + frame->strict = function->strict; if (vm->trace) uc_vm_frame_dump(vm, frame); @@ -919,7 +926,7 @@ uc_vm_insn_load_var(uc_vm *vm, enum insn_type insn) next = ucv_prototype_get(scope); if (!next) { - if (vm->config->strict_declarations) { + if (uc_vm_is_strict(vm)) { uc_vm_raise_exception(vm, EXCEPTION_REFERENCE, "access to undeclared variable %s", ucv_string_get(name)); @@ -1092,7 +1099,7 @@ uc_vm_insn_store_var(uc_vm *vm, enum insn_type insn) next = ucv_prototype_get(scope); if (!next) { - if (vm->config->strict_declarations) { + if (uc_vm_is_strict(vm)) { uc_vm_raise_exception(vm, EXCEPTION_REFERENCE, "access to undeclared variable %s", ucv_string_get(name)); @@ -1335,7 +1342,7 @@ uc_vm_insn_update_var(uc_vm *vm, enum insn_type insn) next = ucv_prototype_get(scope); if (!next) { - if (vm->config->strict_declarations) { + if (uc_vm_is_strict(vm)) { uc_vm_raise_exception(vm, EXCEPTION_REFERENCE, "access to undeclared variable %s", ucv_string_get(name)); @@ -2250,6 +2257,7 @@ uc_vm_execute(uc_vm *vm, uc_function_t *fn, uc_value_t *globals, uc_value_t *mod frame->closure = closure; frame->stackframe = 0; frame->ip = uc_vm_frame_chunk(frame)->entries; + frame->strict = fn->strict; if (vm->trace) { buf = xprintbuf_new(); |