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/zone.h" | 9 #include "src/zone.h" |
10 | 10 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 static bool Analyze(CompilationInfo* info); | 81 static bool Analyze(CompilationInfo* info); |
82 | 82 |
83 static Scope* DeserializeScopeChain(Isolate* isolate, Zone* zone, | 83 static Scope* DeserializeScopeChain(Isolate* isolate, Zone* zone, |
84 Context* context, Scope* script_scope); | 84 Context* context, Scope* script_scope); |
85 | 85 |
86 // The scope name is only used for printing/debugging. | 86 // The scope name is only used for printing/debugging. |
87 void SetScopeName(const AstRawString* scope_name) { | 87 void SetScopeName(const AstRawString* scope_name) { |
88 scope_name_ = scope_name; | 88 scope_name_ = scope_name; |
89 } | 89 } |
90 | 90 |
91 void Initialize(bool subclass_constructor = false); | 91 void Initialize(bool uninitialized_this = false); |
92 | 92 |
93 // Checks if the block scope is redundant, i.e. it does not contain any | 93 // Checks if the block scope is redundant, i.e. it does not contain any |
94 // block scoped declarations. In that case it is removed from the scope | 94 // block scoped declarations. In that case it is removed from the scope |
95 // tree and its children are reparented. | 95 // tree and its children are reparented. |
96 Scope* FinalizeBlockScope(); | 96 Scope* FinalizeBlockScope(); |
97 | 97 |
98 Zone* zone() const { return zone_; } | 98 Zone* zone() const { return zone_; } |
99 | 99 |
100 // --------------------------------------------------------------------------- | 100 // --------------------------------------------------------------------------- |
101 // Declarations | 101 // Declarations |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 | 336 |
337 // --------------------------------------------------------------------------- | 337 // --------------------------------------------------------------------------- |
338 // Accessors. | 338 // Accessors. |
339 | 339 |
340 // The type of this scope. | 340 // The type of this scope. |
341 ScopeType scope_type() const { return scope_type_; } | 341 ScopeType scope_type() const { return scope_type_; } |
342 | 342 |
343 // The language mode of this scope. | 343 // The language mode of this scope. |
344 LanguageMode language_mode() const { return language_mode_; } | 344 LanguageMode language_mode() const { return language_mode_; } |
345 | 345 |
346 // The variable corresponding to the 'this' value. | 346 // The variable corresponding the 'this' value. |
347 Variable* receiver() { return receiver_; } | 347 Variable* receiver() { return receiver_; } |
348 | 348 |
349 // The variable corresponding to the 'new.target' value. | |
350 Variable* new_target_var() { return new_target_; } | |
351 | |
352 // The variable holding the function literal for named function | 349 // The variable holding the function literal for named function |
353 // literals, or NULL. Only valid for function scopes. | 350 // literals, or NULL. Only valid for function scopes. |
354 VariableDeclaration* function() const { | 351 VariableDeclaration* function() const { |
355 DCHECK(is_function_scope()); | 352 DCHECK(is_function_scope()); |
356 return function_; | 353 return function_; |
357 } | 354 } |
358 | 355 |
359 // Parameters. The left-most parameter has index 0. | 356 // Parameters. The left-most parameter has index 0. |
360 // Only valid for function scopes. | 357 // Only valid for function scopes. |
361 Variable* parameter(int index) const { | 358 Variable* parameter(int index) const { |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
513 // Variables that must be looked up dynamically. | 510 // Variables that must be looked up dynamically. |
514 DynamicScopePart* dynamics_; | 511 DynamicScopePart* dynamics_; |
515 // Unresolved variables referred to from this scope. | 512 // Unresolved variables referred to from this scope. |
516 ZoneList<VariableProxy*> unresolved_; | 513 ZoneList<VariableProxy*> unresolved_; |
517 // Declarations. | 514 // Declarations. |
518 ZoneList<Declaration*> decls_; | 515 ZoneList<Declaration*> decls_; |
519 // Convenience variable. | 516 // Convenience variable. |
520 Variable* receiver_; | 517 Variable* receiver_; |
521 // Function variable, if any; function scopes only. | 518 // Function variable, if any; function scopes only. |
522 VariableDeclaration* function_; | 519 VariableDeclaration* function_; |
523 // new.target variable, function scopes only. | |
524 Variable* new_target_; | |
525 // Convenience variable; function scopes only. | 520 // Convenience variable; function scopes only. |
526 Variable* arguments_; | 521 Variable* arguments_; |
527 // Interface; module scopes only. | 522 // Interface; module scopes only. |
528 Interface* interface_; | 523 Interface* interface_; |
529 | 524 |
530 // Illegal redeclaration. | 525 // Illegal redeclaration. |
531 Expression* illegal_redecl_; | 526 Expression* illegal_redecl_; |
532 | 527 |
533 // Scope-specific information computed during parsing. | 528 // Scope-specific information computed during parsing. |
534 // | 529 // |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
703 Scope* outer_scope, | 698 Scope* outer_scope, |
704 Handle<ScopeInfo> scope_info); | 699 Handle<ScopeInfo> scope_info); |
705 | 700 |
706 AstValueFactory* ast_value_factory_; | 701 AstValueFactory* ast_value_factory_; |
707 Zone* zone_; | 702 Zone* zone_; |
708 }; | 703 }; |
709 | 704 |
710 } } // namespace v8::internal | 705 } } // namespace v8::internal |
711 | 706 |
712 #endif // V8_SCOPES_H_ | 707 #endif // V8_SCOPES_H_ |
OLD | NEW |