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/base/hashmap.h" | 9 #include "src/base/hashmap.h" |
10 #include "src/globals.h" | 10 #include "src/globals.h" |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 // Script variable. | 85 // Script variable. |
86 | 86 |
87 class Scope: public ZoneObject { | 87 class Scope: public ZoneObject { |
88 public: | 88 public: |
89 // --------------------------------------------------------------------------- | 89 // --------------------------------------------------------------------------- |
90 // Construction | 90 // Construction |
91 | 91 |
92 Scope(Zone* zone, Scope* outer_scope, ScopeType scope_type, | 92 Scope(Zone* zone, Scope* outer_scope, ScopeType scope_type, |
93 FunctionKind function_kind = kNormalFunction); | 93 FunctionKind function_kind = kNormalFunction); |
94 | 94 |
| 95 class Snapshot final BASE_EMBEDDED { |
| 96 public: |
| 97 explicit Snapshot(Scope* scope) |
| 98 : outer_scope_(scope), |
| 99 top_inner_scope_(scope->inner_scope_), |
| 100 top_unresolved_(scope->unresolved_), |
| 101 top_temp_(scope->ClosureScope()->temps_.length()) {} |
| 102 |
| 103 void Reparent(Scope* new_parent) const; |
| 104 |
| 105 private: |
| 106 Scope* outer_scope_; |
| 107 Scope* top_inner_scope_; |
| 108 VariableProxy* top_unresolved_; |
| 109 int top_temp_; |
| 110 }; |
| 111 |
95 // Compute top scope and allocate variables. For lazy compilation the top | 112 // Compute top scope and allocate variables. For lazy compilation the top |
96 // scope only contains the single lazily compiled function, so this | 113 // scope only contains the single lazily compiled function, so this |
97 // doesn't re-allocate variables repeatedly. | 114 // doesn't re-allocate variables repeatedly. |
98 static bool Analyze(ParseInfo* info); | 115 static bool Analyze(ParseInfo* info); |
99 | 116 |
100 static Scope* DeserializeScopeChain(Isolate* isolate, Zone* zone, | 117 static Scope* DeserializeScopeChain(Isolate* isolate, Zone* zone, |
101 Context* context, Scope* script_scope, | 118 Context* context, Scope* script_scope, |
102 AstValueFactory* ast_value_factory); | 119 AstValueFactory* ast_value_factory); |
103 | 120 |
104 // The scope name is only used for printing/debugging. | 121 // The scope name is only used for printing/debugging. |
(...skipping 736 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
841 | 858 |
842 void SetDefaults(); | 859 void SetDefaults(); |
843 | 860 |
844 PendingCompilationErrorHandler pending_error_handler_; | 861 PendingCompilationErrorHandler pending_error_handler_; |
845 }; | 862 }; |
846 | 863 |
847 } // namespace internal | 864 } // namespace internal |
848 } // namespace v8 | 865 } // namespace v8 |
849 | 866 |
850 #endif // V8_AST_SCOPES_H_ | 867 #endif // V8_AST_SCOPES_H_ |
OLD | NEW |