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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 } | 161 } |
162 | 162 |
163 // Remove a unresolved variable. During parsing, an unresolved variable | 163 // Remove a unresolved variable. During parsing, an unresolved variable |
164 // may have been added optimistically, but then only the variable name | 164 // may have been added optimistically, but then only the variable name |
165 // was used (typically for labels). If the variable was not declared, the | 165 // was used (typically for labels). If the variable was not declared, the |
166 // addition introduced a new unresolved variable which may end up being | 166 // addition introduced a new unresolved variable which may end up being |
167 // allocated globally as a "ghost" variable. RemoveUnresolved removes | 167 // allocated globally as a "ghost" variable. RemoveUnresolved removes |
168 // such a variable again if it was added; otherwise this is a no-op. | 168 // such a variable again if it was added; otherwise this is a no-op. |
169 void RemoveUnresolved(VariableProxy* var); | 169 void RemoveUnresolved(VariableProxy* var); |
170 | 170 |
171 // Creates a new internal variable in this scope. The name is only used | 171 // Creates a new temporary variable in this scope's TemporaryScope. The |
172 // for printing and cannot be used to find the variable. In particular, | 172 // name is only used for printing and cannot be used to find the variable. |
173 // the only way to get hold of the temporary is by keeping the Variable* | 173 // In particular, the only way to get hold of the temporary is by keeping the |
174 // around. | 174 // Variable* around. The name should not clash with a legitimate variable |
175 Variable* NewInternal(const AstRawString* name); | 175 // names. |
176 | |
177 // Creates a new temporary variable in this scope. The name is only used | |
178 // for printing and cannot be used to find the variable. In particular, | |
179 // the only way to get hold of the temporary is by keeping the Variable* | |
180 // around. The name should not clash with a legitimate variable names. | |
181 Variable* NewTemporary(const AstRawString* name); | 176 Variable* NewTemporary(const AstRawString* name); |
182 | 177 |
183 // Adds the specific declaration node to the list of declarations in | 178 // Adds the specific declaration node to the list of declarations in |
184 // this scope. The declarations are processed as part of entering | 179 // this scope. The declarations are processed as part of entering |
185 // the scope; see codegen.cc:ProcessDeclarations. | 180 // the scope; see codegen.cc:ProcessDeclarations. |
186 void AddDeclaration(Declaration* declaration); | 181 void AddDeclaration(Declaration* declaration); |
187 | 182 |
188 // --------------------------------------------------------------------------- | 183 // --------------------------------------------------------------------------- |
189 // Illegal redeclaration support. | 184 // Illegal redeclaration support. |
190 | 185 |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
480 // True if the outer context of this scope is always the native context. | 475 // True if the outer context of this scope is always the native context. |
481 bool HasTrivialOuterContext() const; | 476 bool HasTrivialOuterContext() const; |
482 | 477 |
483 // The number of contexts between this and scope; zero if this == scope. | 478 // The number of contexts between this and scope; zero if this == scope. |
484 int ContextChainLength(Scope* scope); | 479 int ContextChainLength(Scope* scope); |
485 | 480 |
486 // Find the first function, script, eval or (declaration) block scope. This is | 481 // Find the first function, script, eval or (declaration) block scope. This is |
487 // the scope where var declarations will be hoisted to in the implementation. | 482 // the scope where var declarations will be hoisted to in the implementation. |
488 Scope* DeclarationScope(); | 483 Scope* DeclarationScope(); |
489 | 484 |
| 485 // Find the first non-block declaration scope. This should be either a script, |
| 486 // function, or eval scope. Same as DeclarationScope(), but skips |
| 487 // declaration "block" scopes. Used for declaring temporaries. |
| 488 Scope* TemporaryScope(); |
| 489 |
490 // Find the first (non-arrow) function or script scope. This is where | 490 // Find the first (non-arrow) function or script scope. This is where |
491 // 'this' is bound, and what determines the function kind. | 491 // 'this' is bound, and what determines the function kind. |
492 Scope* ReceiverScope(); | 492 Scope* ReceiverScope(); |
493 | 493 |
494 Handle<ScopeInfo> GetScopeInfo(Isolate* isolate); | 494 Handle<ScopeInfo> GetScopeInfo(Isolate* isolate); |
495 | 495 |
496 // Get the chain of nested scopes within this scope for the source statement | 496 // Get the chain of nested scopes within this scope for the source statement |
497 // position. The scopes will be added to the list from the outermost scope to | 497 // position. The scopes will be added to the list from the outermost scope to |
498 // the innermost scope. Only nested block, catch or with scopes are tracked | 498 // the innermost scope. Only nested block, catch or with scopes are tracked |
499 // and will be returned, but no inner function scopes. | 499 // and will be returned, but no inner function scopes. |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
765 PendingCompilationErrorHandler pending_error_handler_; | 765 PendingCompilationErrorHandler pending_error_handler_; |
766 | 766 |
767 // For tracking which classes are declared consecutively. Needed for strong | 767 // For tracking which classes are declared consecutively. Needed for strong |
768 // mode. | 768 // mode. |
769 int class_declaration_group_start_; | 769 int class_declaration_group_start_; |
770 }; | 770 }; |
771 | 771 |
772 } } // namespace v8::internal | 772 } } // namespace v8::internal |
773 | 773 |
774 #endif // V8_SCOPES_H_ | 774 #endif // V8_SCOPES_H_ |
OLD | NEW |