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 #include "src/ast/scopes.h" | 5 #include "src/ast/scopes.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "src/accessors.h" | 9 #include "src/accessors.h" |
10 #include "src/ast/ast.h" | 10 #include "src/ast/ast.h" |
(...skipping 1177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1188 non_locals = StringSet::Add(non_locals, proxy->name()); | 1188 non_locals = StringSet::Add(non_locals, proxy->name()); |
1189 } | 1189 } |
1190 return non_locals; | 1190 return non_locals; |
1191 } | 1191 } |
1192 | 1192 |
1193 void DeclarationScope::ResetAfterPreparsing(AstValueFactory* ast_value_factory, | 1193 void DeclarationScope::ResetAfterPreparsing(AstValueFactory* ast_value_factory, |
1194 bool aborted) { | 1194 bool aborted) { |
1195 DCHECK(is_function_scope()); | 1195 DCHECK(is_function_scope()); |
1196 | 1196 |
1197 // Reset all non-trivial members. | 1197 // Reset all non-trivial members. |
1198 decls_.Clear(); | 1198 decls_.Rewind(0); |
1199 locals_.Clear(); | 1199 locals_.Rewind(0); |
1200 sloppy_block_function_map_.Clear(); | 1200 sloppy_block_function_map_.Clear(); |
1201 variables_.Clear(); | 1201 variables_.Clear(); |
1202 // Make sure we won't walk the scope tree from here on. | 1202 // Make sure we won't walk the scope tree from here on. |
1203 inner_scope_ = nullptr; | 1203 inner_scope_ = nullptr; |
1204 unresolved_ = nullptr; | 1204 unresolved_ = nullptr; |
1205 | 1205 |
1206 // TODO(verwaest): We should properly preparse the parameters (no declarations | 1206 // TODO(verwaest): We should properly preparse the parameters (no declarations |
1207 // should be created), and reparse on abort. | 1207 // should be created), and reparse on abort. |
1208 if (aborted) { | 1208 if (aborted) { |
1209 if (!IsArrowFunction(function_kind_)) { | 1209 if (!IsArrowFunction(function_kind_)) { |
1210 DeclareDefaultFunctionVariables(ast_value_factory); | 1210 DeclareDefaultFunctionVariables(ast_value_factory); |
1211 } | 1211 } |
1212 // Recreate declarations for parameters. | 1212 // Recreate declarations for parameters. |
1213 for (int i = 0; i < params_.length(); i++) { | 1213 for (int i = 0; i < params_.length(); i++) { |
1214 Variable* var = params_[i]; | 1214 Variable* var = params_[i]; |
1215 if (var->mode() == TEMPORARY) { | 1215 if (var->mode() == TEMPORARY) { |
1216 locals_.Add(var, zone()); | 1216 locals_.Add(var, zone()); |
1217 } else if (variables_.Lookup(var->raw_name()) == nullptr) { | 1217 } else if (variables_.Lookup(var->raw_name()) == nullptr) { |
1218 variables_.Add(zone(), var); | 1218 variables_.Add(zone(), var); |
1219 locals_.Add(var, zone()); | 1219 locals_.Add(var, zone()); |
1220 } | 1220 } |
1221 } | 1221 } |
1222 } else { | 1222 } else { |
1223 params_.Clear(); | 1223 params_.Rewind(0); |
1224 } | 1224 } |
1225 | 1225 |
1226 #ifdef DEBUG | 1226 #ifdef DEBUG |
1227 needs_migration_ = false; | 1227 needs_migration_ = false; |
1228 #endif | 1228 #endif |
1229 | 1229 |
1230 is_lazily_parsed_ = !aborted; | 1230 is_lazily_parsed_ = !aborted; |
1231 } | 1231 } |
1232 | 1232 |
1233 void DeclarationScope::AnalyzePartially(AstNodeFactory* ast_node_factory) { | 1233 void DeclarationScope::AnalyzePartially(AstNodeFactory* ast_node_factory) { |
(...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1904 Variable* function = | 1904 Variable* function = |
1905 is_function_scope() ? AsDeclarationScope()->function_var() : nullptr; | 1905 is_function_scope() ? AsDeclarationScope()->function_var() : nullptr; |
1906 bool is_function_var_in_context = | 1906 bool is_function_var_in_context = |
1907 function != nullptr && function->IsContextSlot(); | 1907 function != nullptr && function->IsContextSlot(); |
1908 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - | 1908 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - |
1909 (is_function_var_in_context ? 1 : 0); | 1909 (is_function_var_in_context ? 1 : 0); |
1910 } | 1910 } |
1911 | 1911 |
1912 } // namespace internal | 1912 } // namespace internal |
1913 } // namespace v8 | 1913 } // namespace v8 |
OLD | NEW |