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 | |
187 // Remove a unresolved variable. During parsing, an unresolved variable | 181 // Remove a unresolved variable. During parsing, an unresolved variable |
188 // may have been added optimistically, but then only the variable name | 182 // may have been added optimistically, but then only the variable name |
189 // was used (typically for labels). If the variable was not declared, the | 183 // was used (typically for labels). If the variable was not declared, the |
190 // addition introduced a new unresolved variable which may end up being | 184 // addition introduced a new unresolved variable which may end up being |
191 // allocated globally as a "ghost" variable. RemoveUnresolved removes | 185 // allocated globally as a "ghost" variable. RemoveUnresolved removes |
192 // such a variable again if it was added; otherwise this is a no-op. | 186 // such a variable again if it was added; otherwise this is a no-op. |
193 bool RemoveUnresolved(VariableProxy* var); | 187 void RemoveUnresolved(VariableProxy* var); |
194 | 188 |
195 // Creates a new temporary variable in this scope's TemporaryScope. The | 189 // Creates a new temporary variable in this scope's TemporaryScope. The |
196 // name is only used for printing and cannot be used to find the variable. | 190 // name is only used for printing and cannot be used to find the variable. |
197 // In particular, the only way to get hold of the temporary is by keeping the | 191 // In particular, the only way to get hold of the temporary is by keeping the |
198 // Variable* around. The name should not clash with a legitimate variable | 192 // Variable* around. The name should not clash with a legitimate variable |
199 // names. | 193 // names. |
200 Variable* NewTemporary(const AstRawString* name); | 194 Variable* NewTemporary(const AstRawString* name); |
201 | 195 |
202 // Adds the specific declaration node to the list of declarations in | 196 // Adds the specific declaration node to the list of declarations in |
203 // this scope. The declarations are processed as part of entering | 197 // this scope. The declarations are processed as part of entering |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
463 } | 457 } |
464 | 458 |
465 // Declarations list. | 459 // Declarations list. |
466 ZoneList<Declaration*>* declarations() { return &decls_; } | 460 ZoneList<Declaration*>* declarations() { return &decls_; } |
467 | 461 |
468 // Inner scope list. | 462 // Inner scope list. |
469 ZoneList<Scope*>* inner_scopes() { return &inner_scopes_; } | 463 ZoneList<Scope*>* inner_scopes() { return &inner_scopes_; } |
470 | 464 |
471 // The scope immediately surrounding this scope, or NULL. | 465 // The scope immediately surrounding this scope, or NULL. |
472 Scope* outer_scope() const { return outer_scope_; } | 466 Scope* outer_scope() const { return outer_scope_; } |
473 void set_outer_scope(Scope* outer_scope) { outer_scope_ = outer_scope; } | |
474 | 467 |
475 // The ModuleDescriptor for this scope; only for module scopes. | 468 // The ModuleDescriptor for this scope; only for module scopes. |
476 ModuleDescriptor* module() const { return module_descriptor_; } | 469 ModuleDescriptor* module() const { return module_descriptor_; } |
477 | 470 |
478 | 471 |
479 void set_class_declaration_group_start(int position) { | 472 void set_class_declaration_group_start(int position) { |
480 class_declaration_group_start_ = position; | 473 class_declaration_group_start_ = position; |
481 } | 474 } |
482 | 475 |
483 int class_declaration_group_start() const { | 476 int class_declaration_group_start() const { |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
831 | 824 |
832 // For tracking which classes are declared consecutively. Needed for strong | 825 // For tracking which classes are declared consecutively. Needed for strong |
833 // mode. | 826 // mode. |
834 int class_declaration_group_start_; | 827 int class_declaration_group_start_; |
835 }; | 828 }; |
836 | 829 |
837 } // namespace internal | 830 } // namespace internal |
838 } // namespace v8 | 831 } // namespace v8 |
839 | 832 |
840 #endif // V8_SCOPES_H_ | 833 #endif // V8_SCOPES_H_ |
OLD | NEW |