From b36f997ef27439d702a3dd0198182c8e4f96dc3c Mon Sep 17 00:00:00 2001 From: Ruben Ayrapetyan Date: Thu, 28 Aug 2014 20:29:42 +0400 Subject: [PATCH] Determining if global code is strict code by checking if first opcode is 'meta' opcode of OPCODE_META_TYPE_STRICT_CODE type; setting 'configurableBindings' in 'var_decl' opcode to true if current code is eval code. --- src/libcoreint/interpreter.c | 13 ++++++++++--- src/libcoreint/opcodes.c | 4 ++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/libcoreint/interpreter.c b/src/libcoreint/interpreter.c index 7d8a5467c..c156f7209 100644 --- a/src/libcoreint/interpreter.c +++ b/src/libcoreint/interpreter.c @@ -51,10 +51,17 @@ run_int (void) { JERRY_ASSERT (__program != NULL); - FIXME (Strict mode); - const bool is_strict = false; + bool is_strict = false; + opcode_counter_t start_pos = 0; + + opcode_t first_opcode = read_opcode (start_pos); + if (first_opcode.op_idx == __op__idx_meta + && first_opcode.data.meta.type == OPCODE_META_TYPE_STRICT_CODE) + { + is_strict = true; + start_pos++; + } - const opcode_counter_t start_pos = 0; ecma_object_t *glob_obj_p = ecma_op_create_global_object (); ecma_object_t *lex_env_p = ecma_op_create_global_environment (glob_obj_p); ecma_value_t this_binding_value = ecma_make_object_value (glob_obj_p); diff --git a/src/libcoreint/opcodes.c b/src/libcoreint/opcodes.c index c9ce2b317..79b59a84d 100644 --- a/src/libcoreint/opcodes.c +++ b/src/libcoreint/opcodes.c @@ -422,11 +422,11 @@ opfunc_var_decl (opcode_t opdata, /**< operation data */ if (ecma_is_completion_value_normal_false (ecma_op_has_binding (int_data->lex_env_p, var_name_string_p))) { - FIXME ("Pass configurableBindings that is true if and only if current code is eval code"); + const bool is_configurable_bindings = int_data->is_eval_code; ecma_completion_value_t completion = ecma_op_create_mutable_binding (int_data->lex_env_p, var_name_string_p, - false); + is_configurable_bindings); JERRY_ASSERT (ecma_is_empty_completion_value (completion));