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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 // to the passed-in scope. | 117 // to the passed-in scope. |
118 void PropagateUsageFlagsToScope(Scope* other); | 118 void PropagateUsageFlagsToScope(Scope* other); |
119 | 119 |
120 Zone* zone() const { return zone_; } | 120 Zone* zone() const { return zone_; } |
121 | 121 |
122 // --------------------------------------------------------------------------- | 122 // --------------------------------------------------------------------------- |
123 // Declarations | 123 // Declarations |
124 | 124 |
125 // Lookup a variable in this scope. Returns the variable or NULL if not found. | 125 // Lookup a variable in this scope. Returns the variable or NULL if not found. |
126 Variable* LookupLocal(const AstRawString* name) { | 126 Variable* LookupLocal(const AstRawString* name) { |
127 return variables_.Lookup(name); | 127 Variable* result = variables_.Lookup(name); |
| 128 if (result != nullptr || scope_info_.is_null()) return result; |
| 129 return LookupInScopeInfo(name); |
128 } | 130 } |
129 | 131 |
| 132 Variable* LookupInScopeInfo(const AstRawString* name); |
| 133 |
130 // Lookup a variable in this scope or outer scopes. | 134 // Lookup a variable in this scope or outer scopes. |
131 // Returns the variable or NULL if not found. | 135 // Returns the variable or NULL if not found. |
132 Variable* Lookup(const AstRawString* name); | 136 Variable* Lookup(const AstRawString* name); |
133 | 137 |
134 // 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 |
135 // declared before, the previously declared variable is returned. | 139 // declared before, the previously declared variable is returned. |
136 Variable* DeclareLocal(const AstRawString* name, VariableMode mode, | 140 Variable* DeclareLocal(const AstRawString* name, VariableMode mode, |
137 InitializationFlag init_flag, Variable::Kind kind, | 141 InitializationFlag init_flag, Variable::Kind kind, |
138 MaybeAssignedFlag maybe_assigned_flag = kNotAssigned); | 142 MaybeAssignedFlag maybe_assigned_flag = kNotAssigned); |
139 | 143 |
(...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
844 void AllocateModuleVariables(); | 848 void AllocateModuleVariables(); |
845 | 849 |
846 private: | 850 private: |
847 ModuleDescriptor* module_descriptor_; | 851 ModuleDescriptor* module_descriptor_; |
848 }; | 852 }; |
849 | 853 |
850 } // namespace internal | 854 } // namespace internal |
851 } // namespace v8 | 855 } // namespace v8 |
852 | 856 |
853 #endif // V8_AST_SCOPES_H_ | 857 #endif // V8_AST_SCOPES_H_ |
OLD | NEW |