Fix local scoping for functions. (#3559)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
@@ -1463,6 +1463,41 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
|
||||
}
|
||||
continue;
|
||||
}
|
||||
case VM_OC_COPY_TO_GLOBAL:
|
||||
{
|
||||
uint32_t literal_index;
|
||||
READ_LITERAL_INDEX (literal_index);
|
||||
|
||||
ecma_string_t *name_p = ecma_get_string_from_value (literal_start_p[literal_index]);
|
||||
ecma_object_t *lex_env_p = frame_ctx_p->lex_env_p;
|
||||
|
||||
while (lex_env_p->type_flags_refs & ECMA_OBJECT_FLAG_BLOCK)
|
||||
{
|
||||
#if ENABLED (JERRY_ES2015) && !(defined JERRY_NDEBUG)
|
||||
if (ecma_get_lex_env_type (lex_env_p) == ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE)
|
||||
{
|
||||
ecma_property_t *property_p = ecma_find_named_property (lex_env_p, name_p);
|
||||
|
||||
JERRY_ASSERT (property_p == NULL || !(*property_p & ECMA_PROPERTY_FLAG_ENUMERABLE));
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) && !JERRY_NDEBUG */
|
||||
|
||||
JERRY_ASSERT (lex_env_p->u2.outer_reference_cp != JMEM_CP_NULL);
|
||||
lex_env_p = ECMA_GET_NON_NULL_POINTER (ecma_object_t, lex_env_p->u2.outer_reference_cp);
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ES2015) && !(defined JERRY_NDEBUG)
|
||||
if (ecma_get_lex_env_type (lex_env_p) == ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE)
|
||||
{
|
||||
ecma_property_t *property_p = ecma_find_named_property (lex_env_p, name_p);
|
||||
|
||||
JERRY_ASSERT (property_p == NULL || !(*property_p & ECMA_PROPERTY_FLAG_ENUMERABLE));
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) && !JERRY_NDEBUG */
|
||||
|
||||
vm_set_var (lex_env_p, name_p, is_strict, left_value);
|
||||
continue;
|
||||
}
|
||||
case VM_OC_CLONE_CONTEXT:
|
||||
{
|
||||
JERRY_ASSERT (byte_code_start_p[0] == CBC_EXT_OPCODE);
|
||||
|
||||
@@ -226,6 +226,7 @@ typedef enum
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
VM_OC_INIT_LOCALS, /**< call vm_init_loop() */
|
||||
VM_OC_ASSIGN_LET_CONST, /**< assign values to let/const declarations */
|
||||
VM_OC_COPY_TO_GLOBAL, /**< copy value to global lex env */
|
||||
VM_OC_CLONE_CONTEXT, /**< clone lexical environment with let/const declarations */
|
||||
VM_OC_SET_COMPUTED_PROPERTY, /**< set computed property */
|
||||
|
||||
@@ -283,6 +284,7 @@ typedef enum
|
||||
#if !ENABLED (JERRY_ES2015)
|
||||
VM_OC_INIT_LOCALS = VM_OC_NONE, /**< call vm_init_loop() */
|
||||
VM_OC_ASSIGN_LET_CONST = VM_OC_NONE, /**< assign values to let/const declarations */
|
||||
VM_OC_COPY_TO_GLOBAL = VM_OC_NONE, /**< copy value to global lex env */
|
||||
VM_OC_CLONE_CONTEXT = VM_OC_NONE, /**< clone lexical environment with let/const declarations */
|
||||
VM_OC_SET_COMPUTED_PROPERTY = VM_OC_NONE, /**< set computed property is unused */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user