| 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 732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 837 | 854 |
| 838 void SetDefaults(); | 855 void SetDefaults(); |
| 839 | 856 |
| 840 PendingCompilationErrorHandler pending_error_handler_; | 857 PendingCompilationErrorHandler pending_error_handler_; |
| 841 }; | 858 }; |
| 842 | 859 |
| 843 } // namespace internal | 860 } // namespace internal |
| 844 } // namespace v8 | 861 } // namespace v8 |
| 845 | 862 |
| 846 #endif // V8_AST_SCOPES_H_ | 863 #endif // V8_AST_SCOPES_H_ |
| OLD | NEW |