| 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" | |
| 9 #include "src/base/compiler-specific.h" | 8 #include "src/base/compiler-specific.h" |
| 10 #include "src/base/hashmap.h" | 9 #include "src/base/hashmap.h" |
| 11 #include "src/globals.h" | 10 #include "src/globals.h" |
| 12 #include "src/objects.h" | 11 #include "src/objects.h" |
| 13 #include "src/zone/zone.h" | 12 #include "src/zone/zone.h" |
| 14 | 13 |
| 15 namespace v8 { | 14 namespace v8 { |
| 16 namespace internal { | 15 namespace internal { |
| 17 | 16 |
| 18 class AstNodeFactory; | 17 class AstNodeFactory; |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 Variable* DeclareVariableName(const AstRawString* name, VariableMode mode); | 201 Variable* DeclareVariableName(const AstRawString* name, VariableMode mode); |
| 203 | 202 |
| 204 // Declarations list. | 203 // Declarations list. |
| 205 ThreadedList<Declaration>* declarations() { return &decls_; } | 204 ThreadedList<Declaration>* declarations() { return &decls_; } |
| 206 | 205 |
| 207 ThreadedList<Variable>* locals() { return &locals_; } | 206 ThreadedList<Variable>* locals() { return &locals_; } |
| 208 | 207 |
| 209 // Create a new unresolved variable. | 208 // Create a new unresolved variable. |
| 210 VariableProxy* NewUnresolved(AstNodeFactory* factory, | 209 VariableProxy* NewUnresolved(AstNodeFactory* factory, |
| 211 const AstRawString* name, | 210 const AstRawString* name, |
| 212 int start_pos = kNoSourcePosition, | 211 int start_position = kNoSourcePosition, |
| 213 VariableKind kind = NORMAL_VARIABLE) { | 212 VariableKind kind = NORMAL_VARIABLE); |
| 214 // Note that we must not share the unresolved variables with | |
| 215 // the same name because they may be removed selectively via | |
| 216 // RemoveUnresolved(). | |
| 217 DCHECK(!already_resolved_); | |
| 218 DCHECK_EQ(factory->zone(), zone()); | |
| 219 VariableProxy* proxy = factory->NewVariableProxy(name, kind, start_pos); | |
| 220 proxy->set_next_unresolved(unresolved_); | |
| 221 unresolved_ = proxy; | |
| 222 return proxy; | |
| 223 } | |
| 224 | 213 |
| 225 void AddUnresolved(VariableProxy* proxy); | 214 void AddUnresolved(VariableProxy* proxy); |
| 226 | 215 |
| 227 // Remove a unresolved variable. During parsing, an unresolved variable | 216 // Remove a unresolved variable. During parsing, an unresolved variable |
| 228 // may have been added optimistically, but then only the variable name | 217 // may have been added optimistically, but then only the variable name |
| 229 // was used (typically for labels). If the variable was not declared, the | 218 // was used (typically for labels). If the variable was not declared, the |
| 230 // addition introduced a new unresolved variable which may end up being | 219 // addition introduced a new unresolved variable which may end up being |
| 231 // allocated globally as a "ghost" variable. RemoveUnresolved removes | 220 // allocated globally as a "ghost" variable. RemoveUnresolved removes |
| 232 // such a variable again if it was added; otherwise this is a no-op. | 221 // such a variable again if it was added; otherwise this is a no-op. |
| 233 bool RemoveUnresolved(VariableProxy* var); | 222 bool RemoveUnresolved(VariableProxy* var); |
| (...skipping 790 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1024 void AllocateModuleVariables(); | 1013 void AllocateModuleVariables(); |
| 1025 | 1014 |
| 1026 private: | 1015 private: |
| 1027 ModuleDescriptor* module_descriptor_; | 1016 ModuleDescriptor* module_descriptor_; |
| 1028 }; | 1017 }; |
| 1029 | 1018 |
| 1030 } // namespace internal | 1019 } // namespace internal |
| 1031 } // namespace v8 | 1020 } // namespace v8 |
| 1032 | 1021 |
| 1033 #endif // V8_AST_SCOPES_H_ | 1022 #endif // V8_AST_SCOPES_H_ |
| OLD | NEW |