From fbcd393962decd30fb2eb51f92e63dfa92031046 Mon Sep 17 00:00:00 2001 From: Ruben Ayrapetyan Date: Mon, 8 Sep 2014 19:11:40 +0400 Subject: [PATCH] Adding configuration flag indicating whether Global Environment is bound to Global Object or it is simple declarative lexical environment. --- src/config.h | 6 ++++++ src/libecmaoperations/ecma-lex-env.c | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/src/config.h b/src/config.h index 7baea9905..e03cc7855 100644 --- a/src/config.h +++ b/src/config.h @@ -104,4 +104,10 @@ */ #define CONFIG_ECMA_EXCEPTION_SUPPORT +/** + * Link Global Environment to an empty declarative lexical environment + * instead of lexical environment bound to Global Object. + */ +// #define CONFIG_ECMA_GLOBAL_ENVIRONMENT_DECLARATIVE + #endif /* !CONFIG_H */ diff --git a/src/libecmaoperations/ecma-lex-env.c b/src/libecmaoperations/ecma-lex-env.c index e51815ced..19cd26291 100644 --- a/src/libecmaoperations/ecma-lex-env.c +++ b/src/libecmaoperations/ecma-lex-env.c @@ -498,7 +498,12 @@ ecma_op_initialize_immutable_binding (ecma_object_t *lex_env_p, /**< lexical env ecma_object_t* ecma_op_create_global_environment (ecma_object_t *glob_obj_p) /**< the Global object */ { +#ifdef CONFIG_ECMA_GLOBAL_ENVIRONMENT_DECLARATIVE + (void) glob_obj_p; + ecma_object_t *glob_env_p = ecma_create_decl_lex_env (NULL); +#else /* !CONFIG_ECMA_GLOBAL_ENVIRONMENT_DECLARATIVE */ ecma_object_t *glob_env_p = ecma_create_object_lex_env (NULL, glob_obj_p, false); +#endif /* !CONFIG_ECMA_GLOBAL_ENVIRONMENT_DECLARATIVE */ return glob_env_p; } /* ecma_op_create_global_environment */