| 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/hashmap.h" | 9 #include "src/hashmap.h" |
| 10 #include "src/pending-compilation-error-handler.h" | 10 #include "src/pending-compilation-error-handler.h" |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 | 202 |
| 203 // Creates a new temporary variable in this scope's TemporaryScope. The | 203 // Creates a new temporary variable in this scope's TemporaryScope. The |
| 204 // name is only used for printing and cannot be used to find the variable. | 204 // name is only used for printing and cannot be used to find the variable. |
| 205 // In particular, the only way to get hold of the temporary is by keeping the | 205 // In particular, the only way to get hold of the temporary is by keeping the |
| 206 // Variable* around. The name should not clash with a legitimate variable | 206 // Variable* around. The name should not clash with a legitimate variable |
| 207 // names. | 207 // names. |
| 208 Variable* NewTemporary(const AstRawString* name); | 208 Variable* NewTemporary(const AstRawString* name); |
| 209 | 209 |
| 210 // Remove a temporary variable. This is for adjusting the scope of | 210 // Remove a temporary variable. This is for adjusting the scope of |
| 211 // temporaries used when desugaring parameter initializers. | 211 // temporaries used when desugaring parameter initializers. |
| 212 bool RemoveTemporary(Variable* var); | 212 // Returns the index at which it was found in this scope, or -1 if |
| 213 // it was not found. |
| 214 int RemoveTemporary(Variable* var); |
| 213 | 215 |
| 214 // Adds a temporary variable in this scope's TemporaryScope. This is for | 216 // Adds a temporary variable in this scope's TemporaryScope. This is for |
| 215 // adjusting the scope of temporaries used when desugaring parameter | 217 // adjusting the scope of temporaries used when desugaring parameter |
| 216 // initializers. | 218 // initializers. |
| 217 void AddTemporary(Variable* var) { temps_.Add(var, zone()); } | 219 void AddTemporary(Variable* var) { temps_.Add(var, zone()); } |
| 218 | 220 |
| 219 // Adds the specific declaration node to the list of declarations in | 221 // Adds the specific declaration node to the list of declarations in |
| 220 // this scope. The declarations are processed as part of entering | 222 // this scope. The declarations are processed as part of entering |
| 221 // the scope; see codegen.cc:ProcessDeclarations. | 223 // the scope; see codegen.cc:ProcessDeclarations. |
| 222 void AddDeclaration(Declaration* declaration); | 224 void AddDeclaration(Declaration* declaration); |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 598 | 600 |
| 599 // Debugging support. | 601 // Debugging support. |
| 600 const AstRawString* scope_name_; | 602 const AstRawString* scope_name_; |
| 601 | 603 |
| 602 // The variables declared in this scope: | 604 // The variables declared in this scope: |
| 603 // | 605 // |
| 604 // All user-declared variables (incl. parameters). For script scopes | 606 // All user-declared variables (incl. parameters). For script scopes |
| 605 // variables may be implicitly 'declared' by being used (possibly in | 607 // variables may be implicitly 'declared' by being used (possibly in |
| 606 // an inner scope) with no intervening with statements or eval calls. | 608 // an inner scope) with no intervening with statements or eval calls. |
| 607 VariableMap variables_; | 609 VariableMap variables_; |
| 608 // Compiler-allocated (user-invisible) temporaries. | 610 // Compiler-allocated (user-invisible) temporaries. Due to the implementation |
| 611 // of RemoveTemporary(), may contain nulls, which must be skipped-over during |
| 612 // allocation and printing. |
| 609 ZoneList<Variable*> temps_; | 613 ZoneList<Variable*> temps_; |
| 610 // Parameter list in source order. | 614 // Parameter list in source order. |
| 611 ZoneList<Variable*> params_; | 615 ZoneList<Variable*> params_; |
| 612 // Variables that must be looked up dynamically. | 616 // Variables that must be looked up dynamically. |
| 613 DynamicScopePart* dynamics_; | 617 DynamicScopePart* dynamics_; |
| 614 // Unresolved variables referred to from this scope. | 618 // Unresolved variables referred to from this scope. |
| 615 ZoneList<VariableProxy*> unresolved_; | 619 ZoneList<VariableProxy*> unresolved_; |
| 616 // Declarations. | 620 // Declarations. |
| 617 ZoneList<Declaration*> decls_; | 621 ZoneList<Declaration*> decls_; |
| 618 // Convenience variable. | 622 // Convenience variable. |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 810 AstValueFactory* ast_value_factory_; | 814 AstValueFactory* ast_value_factory_; |
| 811 Zone* zone_; | 815 Zone* zone_; |
| 812 | 816 |
| 813 PendingCompilationErrorHandler pending_error_handler_; | 817 PendingCompilationErrorHandler pending_error_handler_; |
| 814 }; | 818 }; |
| 815 | 819 |
| 816 } // namespace internal | 820 } // namespace internal |
| 817 } // namespace v8 | 821 } // namespace v8 |
| 818 | 822 |
| 819 #endif // V8_AST_SCOPES_H_ | 823 #endif // V8_AST_SCOPES_H_ |
| OLD | NEW |