| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_AST_SCOPES_H_ | 5 #ifndef V8_AST_SCOPES_H_ |
| 6 #define V8_AST_SCOPES_H_ | 6 #define V8_AST_SCOPES_H_ |
| 7 | 7 |
| 8 #include "src/ast/ast.h" | 8 #include "src/ast/ast.h" |
| 9 #include "src/base/hashmap.h" | 9 #include "src/base/hashmap.h" |
| 10 #include "src/globals.h" | 10 #include "src/globals.h" |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 // Lookup a variable in this scope or outer scopes. | 134 // Lookup a variable in this scope or outer scopes. |
| 135 // Returns the variable or NULL if not found. | 135 // Returns the variable or NULL if not found. |
| 136 Variable* Lookup(const AstRawString* name); | 136 Variable* Lookup(const AstRawString* name); |
| 137 | 137 |
| 138 // Declare a local variable in this scope. If the variable has been | 138 // Declare a local variable in this scope. If the variable has been |
| 139 // declared before, the previously declared variable is returned. | 139 // declared before, the previously declared variable is returned. |
| 140 Variable* DeclareLocal(const AstRawString* name, VariableMode mode, | 140 Variable* DeclareLocal(const AstRawString* name, VariableMode mode, |
| 141 InitializationFlag init_flag, Variable::Kind kind, | 141 InitializationFlag init_flag, Variable::Kind kind, |
| 142 MaybeAssignedFlag maybe_assigned_flag = kNotAssigned); | 142 MaybeAssignedFlag maybe_assigned_flag = kNotAssigned); |
| 143 | 143 |
| 144 Variable* DeclareVariable(Declaration* declaration, VariableMode mode, |
| 145 InitializationFlag init, |
| 146 bool allow_harmony_restrictive_generators, |
| 147 bool* sloppy_mode_block_scope_function_redefinition, |
| 148 bool* ok); |
| 149 |
| 144 // Declarations list. | 150 // Declarations list. |
| 145 ZoneList<Declaration*>* declarations() { return &decls_; } | 151 ZoneList<Declaration*>* declarations() { return &decls_; } |
| 146 | 152 |
| 147 // Create a new unresolved variable. | 153 // Create a new unresolved variable. |
| 148 VariableProxy* NewUnresolved(AstNodeFactory* factory, | 154 VariableProxy* NewUnresolved(AstNodeFactory* factory, |
| 149 const AstRawString* name, | 155 const AstRawString* name, |
| 150 int start_position = kNoSourcePosition, | 156 int start_position = kNoSourcePosition, |
| 151 int end_position = kNoSourcePosition, | 157 int end_position = kNoSourcePosition, |
| 152 Variable::Kind kind = Variable::NORMAL) { | 158 Variable::Kind kind = Variable::NORMAL) { |
| 153 // Note that we must not share the unresolved variables with | 159 // Note that we must not share the unresolved variables with |
| (...skipping 24 matching lines...) Expand all Loading... |
| 178 bool RemoveUnresolved(VariableProxy* var); | 184 bool RemoveUnresolved(VariableProxy* var); |
| 179 | 185 |
| 180 // Creates a new temporary variable in this scope's TemporaryScope. The | 186 // Creates a new temporary variable in this scope's TemporaryScope. The |
| 181 // name is only used for printing and cannot be used to find the variable. | 187 // name is only used for printing and cannot be used to find the variable. |
| 182 // In particular, the only way to get hold of the temporary is by keeping the | 188 // In particular, the only way to get hold of the temporary is by keeping the |
| 183 // Variable* around. The name should not clash with a legitimate variable | 189 // Variable* around. The name should not clash with a legitimate variable |
| 184 // names. | 190 // names. |
| 185 // TODO(verwaest): Move to DeclarationScope? | 191 // TODO(verwaest): Move to DeclarationScope? |
| 186 Variable* NewTemporary(const AstRawString* name); | 192 Variable* NewTemporary(const AstRawString* name); |
| 187 | 193 |
| 188 // Adds the specific declaration node to the list of declarations in | |
| 189 // this scope. The declarations are processed as part of entering | |
| 190 // the scope; see codegen.cc:ProcessDeclarations. | |
| 191 void AddDeclaration(Declaration* declaration); | |
| 192 | |
| 193 // --------------------------------------------------------------------------- | 194 // --------------------------------------------------------------------------- |
| 194 // Illegal redeclaration support. | 195 // Illegal redeclaration support. |
| 195 | 196 |
| 196 // Check if the scope has conflicting var | 197 // Check if the scope has conflicting var |
| 197 // declarations, i.e. a var declaration that has been hoisted from a nested | 198 // declarations, i.e. a var declaration that has been hoisted from a nested |
| 198 // scope over a let binding of the same name. | 199 // scope over a let binding of the same name. |
| 199 Declaration* CheckConflictingVarDeclarations(); | 200 Declaration* CheckConflictingVarDeclarations(); |
| 200 | 201 |
| 201 // Check if the scope has a conflicting lexical declaration that has a name in | 202 // Check if the scope has a conflicting lexical declaration that has a name in |
| 202 // the given list. This is used to catch patterns like | 203 // the given list. This is used to catch patterns like |
| (...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 848 void AllocateModuleVariables(); | 849 void AllocateModuleVariables(); |
| 849 | 850 |
| 850 private: | 851 private: |
| 851 ModuleDescriptor* module_descriptor_; | 852 ModuleDescriptor* module_descriptor_; |
| 852 }; | 853 }; |
| 853 | 854 |
| 854 } // namespace internal | 855 } // namespace internal |
| 855 } // namespace v8 | 856 } // namespace v8 |
| 856 | 857 |
| 857 #endif // V8_AST_SCOPES_H_ | 858 #endif // V8_AST_SCOPES_H_ |
| OLD | NEW |