FunctionExpression name binding should be immutable

JerryScript-DCO-1.0-Signed-off-by: Youngil Choi duddlf.choi@samsung.com
This commit is contained in:
Youngil Choi
2016-08-29 18:02:34 +09:00
parent 260b967853
commit 2c78ee7f54
2 changed files with 53 additions and 9 deletions
+21 -9
View File
@@ -530,6 +530,8 @@ vm_init_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
uint16_t register_end;
jmem_cpointer_t *literal_start_p = frame_ctx_p->literal_start_p;
bool is_strict = ((frame_ctx_p->bytecode_header_p->status_flags & CBC_CODE_FLAGS_STRICT_MODE) != 0);
jmem_cpointer_t self_reference;
ECMA_SET_NON_NULL_POINTER (self_reference, bytecode_header_p);
/* Prepare. */
if (!(bytecode_header_p->status_flags & CBC_CODE_FLAGS_FULL_LITERAL_ENCODING))
@@ -602,12 +604,8 @@ vm_init_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
ecma_string_t *name_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_string_t,
literal_start_p[literal_index]);
vm_var_decl (frame_ctx_p, name_p);
READ_LITERAL_INDEX (value_index);
ecma_object_t *ref_base_lex_env_p = ecma_op_resolve_reference_base (frame_ctx_p->lex_env_p, name_p);
if (value_index < register_end)
{
lit_value = frame_ctx_p->registers_p[value_index];
@@ -618,11 +616,25 @@ vm_init_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
literal_start_p[value_index]);
}
/* TODO: check the return value */
ecma_op_put_value_lex_env_base (ref_base_lex_env_p,
name_p,
is_strict,
lit_value);
if (self_reference == literal_start_p[value_index])
{
ecma_op_create_immutable_binding (frame_ctx_p->lex_env_p, name_p);
ecma_op_initialize_immutable_binding (frame_ctx_p->lex_env_p,
name_p,
lit_value);
}
else
{
vm_var_decl (frame_ctx_p, name_p);
ecma_object_t *ref_base_lex_env_p = ecma_op_resolve_reference_base (frame_ctx_p->lex_env_p, name_p);
/* TODO: check the return value */
ecma_op_put_value_lex_env_base (ref_base_lex_env_p,
name_p,
is_strict,
lit_value);
}
if (value_index >= register_end)
{