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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 // Propagates any eagerly-gathered scope usage flags (such as calls_eval()) | 113 // Propagates any eagerly-gathered scope usage flags (such as calls_eval()) |
114 // to the passed-in scope. | 114 // to the passed-in scope. |
115 void PropagateUsageFlagsToScope(Scope* other); | 115 void PropagateUsageFlagsToScope(Scope* other); |
116 | 116 |
117 Zone* zone() const { return zone_; } | 117 Zone* zone() const { return zone_; } |
118 | 118 |
119 // --------------------------------------------------------------------------- | 119 // --------------------------------------------------------------------------- |
120 // Declarations | 120 // Declarations |
121 | 121 |
122 // Lookup a variable in this scope. Returns the variable or NULL if not found. | 122 // Lookup a variable in this scope. Returns the variable or NULL if not found. |
123 Variable* LookupLocal(const AstRawString* name); | 123 Variable* LookupLocal(const AstRawString* name) { |
| 124 Variable* result = variables_.Lookup(name); |
| 125 if (result != nullptr || scope_info_.is_null()) return result; |
| 126 return LookupInScopeInfo(name); |
| 127 } |
| 128 |
| 129 Variable* LookupInScopeInfo(const AstRawString* name); |
124 | 130 |
125 // Lookup a variable in this scope or outer scopes. | 131 // Lookup a variable in this scope or outer scopes. |
126 // Returns the variable or NULL if not found. | 132 // Returns the variable or NULL if not found. |
127 Variable* Lookup(const AstRawString* name); | 133 Variable* Lookup(const AstRawString* name); |
128 | 134 |
129 // Declare a local variable in this scope. If the variable has been | 135 // Declare a local variable in this scope. If the variable has been |
130 // declared before, the previously declared variable is returned. | 136 // declared before, the previously declared variable is returned. |
131 Variable* DeclareLocal(const AstRawString* name, VariableMode mode, | 137 Variable* DeclareLocal(const AstRawString* name, VariableMode mode, |
132 InitializationFlag init_flag, Variable::Kind kind, | 138 InitializationFlag init_flag, Variable::Kind kind, |
133 MaybeAssignedFlag maybe_assigned_flag = kNotAssigned); | 139 MaybeAssignedFlag maybe_assigned_flag = kNotAssigned); |
(...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
860 void AllocateModuleVariables(); | 866 void AllocateModuleVariables(); |
861 | 867 |
862 private: | 868 private: |
863 ModuleDescriptor* module_descriptor_; | 869 ModuleDescriptor* module_descriptor_; |
864 }; | 870 }; |
865 | 871 |
866 } // namespace internal | 872 } // namespace internal |
867 } // namespace v8 | 873 } // namespace v8 |
868 | 874 |
869 #endif // V8_AST_SCOPES_H_ | 875 #endif // V8_AST_SCOPES_H_ |
OLD | NEW |