Storing global envorinment on global object's SCOPE internal property

This commit is contained in:
Ilyong Cho
2015-04-03 16:11:03 +09:00
parent c81651dbe9
commit 7b5764c445
2 changed files with 26 additions and 0 deletions
@@ -440,9 +440,34 @@ ecma_op_create_global_environment (ecma_object_t *glob_obj_p) /**< the Global ob
ecma_object_t *glob_env_p = ecma_create_object_lex_env (NULL, glob_obj_p, false);
#endif /* !CONFIG_ECMA_GLOBAL_ENVIRONMENT_DECLARATIVE */
ecma_property_t *scope_prop_p = ecma_create_internal_property (glob_obj_p, ECMA_INTERNAL_PROPERTY_SCOPE);
ECMA_SET_POINTER (scope_prop_p->u.internal_property.value, glob_env_p);
return glob_env_p;
} /* ecma_op_create_global_environment */
/**
* Get global lexcial envorinment
*
* Note:
* This function should called after global environment was created.
*
* @return pointer to global lexical environment
*/
ecma_object_t*
ecma_get_globl_lexical_environment ()
{
ecma_object_t *glob_p = ecma_builtin_get (ECMA_BUILTIN_ID_GLOBAL);
ecma_property_t *scope_prop_p = ecma_get_internal_property (glob_p, ECMA_INTERNAL_PROPERTY_SCOPE);
ecma_object_t *glob_env_p = ECMA_GET_POINTER (ecma_object_t,
scope_prop_p->u.internal_property.value);
JERRY_ASSERT (glob_env_p != NULL);
return glob_env_p;
}
/**
* Figure out whether the lexical environment is global.
*
@@ -66,6 +66,7 @@ extern void ecma_op_initialize_immutable_binding (ecma_object_t *lex_env_p,
const ecma_value_t& value);
extern ecma_object_t* ecma_op_create_global_environment (ecma_object_t *glob_obj_p);
extern ecma_object_t* ecma_get_globl_lexical_environment ();
extern bool ecma_is_lexical_environment_global (ecma_object_t *lex_env_p);
/**