Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1684)

Unified Diff: src/ast/scopes.cc

Issue 2372703004: Don't reset parameters if we aborted preparsing, rebuild them from the params_ list (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/ast/scopes.h ('k') | src/parsing/parser.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ast/scopes.cc
diff --git a/src/ast/scopes.cc b/src/ast/scopes.cc
index 8d23875ab6bca368251b9dd13d2172e8291a571d..ce293662e9a84c90f7ecee12962ba7f993951ad0 100644
--- a/src/ast/scopes.cc
+++ b/src/ast/scopes.cc
@@ -1188,6 +1188,36 @@ Handle<StringSet> DeclarationScope::CollectNonLocals(
return non_locals;
}
+void DeclarationScope::ResetAfterPreparsing(bool aborted) {
+ // Reset all non-trivial members.
+ decls_.Clear();
+ locals_.Clear();
+ sloppy_block_function_map_.Clear();
+ variables_.Clear();
+ // Make sure we won't walk the scope tree from here on.
+ inner_scope_ = nullptr;
+
+ // TODO(verwaest): We should properly preparse the parameters (no declarations
+ // should be created), and reparse on abort.
+ if (aborted) {
+ // Recreate declarations for parameters.
+ for (int i = 0; i < params_.length(); i++) {
+ Variable* var = params_[i];
+ if (var->mode() == TEMPORARY) {
+ locals_.Add(var, zone());
+ } else if (variables_.Lookup(var->raw_name()) == nullptr) {
+ variables_.Add(zone(), var);
+ locals_.Add(var, zone());
+ }
+ }
+ } else {
+ params_.Clear();
+ // Make sure we won't try to allocate the rest parameter. {params_} was
+ // cleared above.
+ has_rest_ = false;
+ }
+}
+
void DeclarationScope::AnalyzePartially(DeclarationScope* migrate_to,
AstNodeFactory* ast_node_factory) {
// Try to resolve unresolved variables for this Scope and migrate those which
« no previous file with comments | « src/ast/scopes.h ('k') | src/parsing/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698