1/* Copyright JS Foundation and other contributors, http://js.foundation
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16#ifndef ECMA_LEX_ENV_H
17#define ECMA_LEX_ENV_H
18
19#include "ecma-globals.h"
20#include "ecma-reference.h"
21#include "jrt.h"
22
23/** \addtogroup ecma ECMA
24 * @{
25 *
26 * \addtogroup lexicalenvironment Lexical environment
27 * @{
28 *
29 * \addtogroup globallexicalenvironment Global lexical environment
30 * @{
31 */
32
33void ecma_init_global_environment (void);
34void ecma_finalize_global_environment (void);
35ecma_object_t *ecma_get_global_environment (void);
36ecma_object_t *ecma_get_global_scope (void);
37#if ENABLED (JERRY_ES2015)
38void ecma_create_global_lexical_block (void);
39#endif /* ENABLED (JERRY_ES2015) */
40
41#if ENABLED (JERRY_ES2015_MODULE_SYSTEM)
42void ecma_module_add_lex_env (ecma_object_t *lex_env_p);
43void ecma_module_finalize_lex_envs (void);
44#endif /* ENABLED (JERRY_ES2015_MODULE_SYSTEM) */
45
46/**
47 * @}
48 */
49
50/* ECMA-262 v5, 8.7.1 and 8.7.2 */
51ecma_value_t ecma_op_get_value_lex_env_base (ecma_object_t *lex_env_p, ecma_object_t **ref_base_lex_env_p,
52                                             ecma_string_t *name_p);
53ecma_value_t ecma_op_get_value_object_base (ecma_value_t base_value, ecma_string_t *property_name_p);
54ecma_value_t ecma_op_put_value_lex_env_base (ecma_object_t *lex_env_p, ecma_string_t *var_name_string_p,
55                                             bool is_strict, ecma_value_t value);
56
57/* ECMA-262 v5, Table 17. Abstract methods of Environment Records */
58ecma_value_t ecma_op_has_binding (ecma_object_t *lex_env_p, ecma_string_t *name_p);
59ecma_value_t ecma_op_create_mutable_binding (ecma_object_t *lex_env_p, ecma_string_t *name_p, bool is_deletable);
60ecma_value_t ecma_op_set_mutable_binding (ecma_object_t *lex_env_p, ecma_string_t *name_p, ecma_value_t value,
61                                          bool is_strict);
62ecma_value_t ecma_op_get_binding_value (ecma_object_t *lex_env_p, ecma_string_t *name_p, bool is_strict);
63ecma_value_t ecma_op_delete_binding (ecma_object_t *lex_env_p, ecma_string_t *name_p);
64ecma_value_t ecma_op_implicit_this_value (ecma_object_t *lex_env_p);
65
66/* ECMA-262 v5, Table 18. Additional methods of Declarative Environment Records */
67void ecma_op_create_immutable_binding (ecma_object_t *lex_env_p, ecma_string_t *name_p, ecma_value_t value);
68
69#if ENABLED (JERRY_ES2015)
70void ecma_op_initialize_binding (ecma_object_t *lex_env_p, ecma_string_t *name_p, ecma_value_t value);
71
72void
73ecma_op_init_this_binding (ecma_object_t *lex_env_p, ecma_value_t this_binding);
74
75ecma_property_t *
76ecma_op_get_this_property (ecma_object_t *lex_env_p);
77
78bool
79ecma_op_this_binding_is_initialized (ecma_property_t *prop_p);
80
81ecma_value_t
82ecma_op_get_this_binding (ecma_object_t *lex_env_p);
83
84void
85ecma_op_bind_this_value (ecma_property_t *prop_p, ecma_value_t this_binding);
86#endif /* ENABLED (JERRY_ES2015) */
87
88/**
89 * @}
90 * @}
91 */
92
93#endif /* !ECMA_LEX_ENV_H */
94