mirror of
https://github.com/jerryscript-project/jerryscript.git
synced 2025-12-15 16:29:21 +00:00
Adding ecma_is_lexical_environment_global helper.
This commit is contained in:
parent
21a84afc4f
commit
04c6cb30c7
@ -509,6 +509,34 @@ ecma_op_create_global_environment (void)
|
||||
return glob_env_p;
|
||||
} /* ecma_op_create_global_environment */
|
||||
|
||||
/**
|
||||
* Figure out whether the lexical environment is global.
|
||||
*
|
||||
* @return true - if lexical environment is object-bound and corresponding object is global object,
|
||||
* false - otherwise.
|
||||
*/
|
||||
bool
|
||||
ecma_is_lexical_environment_global (ecma_object_t *lex_env_p) /**< lexical environment */
|
||||
{
|
||||
JERRY_ASSERT (lex_env_p != NULL && lex_env_p->is_lexical_environment);
|
||||
|
||||
ecma_lexical_environment_type_t type = lex_env_p->u.lexical_environment.type;
|
||||
|
||||
bool ret_value = false;
|
||||
|
||||
if (type == ECMA_LEXICAL_ENVIRONMENT_OBJECTBOUND)
|
||||
{
|
||||
ecma_object_t *binding_obj_p = ecma_get_lex_env_binding_object (lex_env_p);
|
||||
ecma_object_t *glob_obj_p = ecma_get_global_object ();
|
||||
|
||||
ret_value = (binding_obj_p == glob_obj_p);
|
||||
|
||||
ecma_deref_object (glob_obj_p);
|
||||
}
|
||||
|
||||
return ret_value;
|
||||
} /* ecma_is_lexical_environment_global */
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
|
||||
@ -53,6 +53,7 @@ extern void ecma_op_initialize_immutable_binding (ecma_object_t *lex_env_p,
|
||||
ecma_value_t value);
|
||||
|
||||
extern ecma_object_t* ecma_op_create_global_environment (void);
|
||||
extern bool ecma_is_lexical_environment_global (ecma_object_t *lex_env_p);
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user