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