| 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_SCOPES_H_ | 5 #ifndef V8_SCOPES_H_ |
| 6 #define V8_SCOPES_H_ | 6 #define V8_SCOPES_H_ |
| 7 | 7 |
| 8 #include "src/ast.h" | 8 #include "src/ast.h" |
| 9 #include "src/pending-compilation-error-handler.h" | 9 #include "src/pending-compilation-error-handler.h" |
| 10 #include "src/zone.h" | 10 #include "src/zone.h" |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 // Note that we must not share the unresolved variables with | 171 // Note that we must not share the unresolved variables with |
| 172 // the same name because they may be removed selectively via | 172 // the same name because they may be removed selectively via |
| 173 // RemoveUnresolved(). | 173 // RemoveUnresolved(). |
| 174 DCHECK(!already_resolved()); | 174 DCHECK(!already_resolved()); |
| 175 VariableProxy* proxy = | 175 VariableProxy* proxy = |
| 176 factory->NewVariableProxy(name, kind, start_position, end_position); | 176 factory->NewVariableProxy(name, kind, start_position, end_position); |
| 177 unresolved_.Add(proxy, zone_); | 177 unresolved_.Add(proxy, zone_); |
| 178 return proxy; | 178 return proxy; |
| 179 } | 179 } |
| 180 | 180 |
| 181 void AddUnresolved(VariableProxy* proxy) { |
| 182 DCHECK(!already_resolved()); |
| 183 DCHECK(!proxy->is_resolved()); |
| 184 unresolved_.Add(proxy, zone_); |
| 185 } |
| 186 |
| 181 // Remove a unresolved variable. During parsing, an unresolved variable | 187 // Remove a unresolved variable. During parsing, an unresolved variable |
| 182 // may have been added optimistically, but then only the variable name | 188 // may have been added optimistically, but then only the variable name |
| 183 // was used (typically for labels). If the variable was not declared, the | 189 // was used (typically for labels). If the variable was not declared, the |
| 184 // addition introduced a new unresolved variable which may end up being | 190 // addition introduced a new unresolved variable which may end up being |
| 185 // allocated globally as a "ghost" variable. RemoveUnresolved removes | 191 // allocated globally as a "ghost" variable. RemoveUnresolved removes |
| 186 // such a variable again if it was added; otherwise this is a no-op. | 192 // such a variable again if it was added; otherwise this is a no-op. |
| 187 void RemoveUnresolved(VariableProxy* var); | 193 bool RemoveUnresolved(VariableProxy* var); |
| 188 | 194 |
| 189 // Creates a new temporary variable in this scope's TemporaryScope. The | 195 // Creates a new temporary variable in this scope's TemporaryScope. The |
| 190 // name is only used for printing and cannot be used to find the variable. | 196 // name is only used for printing and cannot be used to find the variable. |
| 191 // In particular, the only way to get hold of the temporary is by keeping the | 197 // In particular, the only way to get hold of the temporary is by keeping the |
| 192 // Variable* around. The name should not clash with a legitimate variable | 198 // Variable* around. The name should not clash with a legitimate variable |
| 193 // names. | 199 // names. |
| 194 Variable* NewTemporary(const AstRawString* name); | 200 Variable* NewTemporary(const AstRawString* name); |
| 195 | 201 |
| 196 // Adds the specific declaration node to the list of declarations in | 202 // Adds the specific declaration node to the list of declarations in |
| 197 // this scope. The declarations are processed as part of entering | 203 // this scope. The declarations are processed as part of entering |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 } | 458 } |
| 453 | 459 |
| 454 // Declarations list. | 460 // Declarations list. |
| 455 ZoneList<Declaration*>* declarations() { return &decls_; } | 461 ZoneList<Declaration*>* declarations() { return &decls_; } |
| 456 | 462 |
| 457 // Inner scope list. | 463 // Inner scope list. |
| 458 ZoneList<Scope*>* inner_scopes() { return &inner_scopes_; } | 464 ZoneList<Scope*>* inner_scopes() { return &inner_scopes_; } |
| 459 | 465 |
| 460 // The scope immediately surrounding this scope, or NULL. | 466 // The scope immediately surrounding this scope, or NULL. |
| 461 Scope* outer_scope() const { return outer_scope_; } | 467 Scope* outer_scope() const { return outer_scope_; } |
| 468 void set_outer_scope(Scope* outer_scope) { outer_scope_ = outer_scope; } |
| 462 | 469 |
| 463 // The ModuleDescriptor for this scope; only for module scopes. | 470 // The ModuleDescriptor for this scope; only for module scopes. |
| 464 ModuleDescriptor* module() const { return module_descriptor_; } | 471 ModuleDescriptor* module() const { return module_descriptor_; } |
| 465 | 472 |
| 466 | 473 |
| 467 void set_class_declaration_group_start(int position) { | 474 void set_class_declaration_group_start(int position) { |
| 468 class_declaration_group_start_ = position; | 475 class_declaration_group_start_ = position; |
| 469 } | 476 } |
| 470 | 477 |
| 471 int class_declaration_group_start() const { | 478 int class_declaration_group_start() const { |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 815 | 822 |
| 816 // For tracking which classes are declared consecutively. Needed for strong | 823 // For tracking which classes are declared consecutively. Needed for strong |
| 817 // mode. | 824 // mode. |
| 818 int class_declaration_group_start_; | 825 int class_declaration_group_start_; |
| 819 }; | 826 }; |
| 820 | 827 |
| 821 } // namespace internal | 828 } // namespace internal |
| 822 } // namespace v8 | 829 } // namespace v8 |
| 823 | 830 |
| 824 #endif // V8_SCOPES_H_ | 831 #endif // V8_SCOPES_H_ |
| OLD | NEW |