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

Unified Diff: src/parsing/preparser.cc

Issue 2407163003: PreParser: track variable declarations and parameters (Closed)
Patch Set: test fixes + more tests Created 4 years 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/parsing/preparser.h ('k') | test/cctest/test-parsing.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parsing/preparser.cc
diff --git a/src/parsing/preparser.cc b/src/parsing/preparser.cc
index 6acc48eec32662bd4c0360645ac9a25a199fcaea..b04090062124c55b297cd88b7cad6da314bd642b 100644
--- a/src/parsing/preparser.cc
+++ b/src/parsing/preparser.cc
@@ -91,6 +91,9 @@ PreParser::PreParseResult PreParser::PreParseFunction(
use_counts_ = use_counts;
DCHECK(!track_unresolved_variables_);
track_unresolved_variables_ = is_inner_function;
+#ifdef DEBUG
+ function_scope->set_is_being_lazily_parsed(true);
+#endif
// In the preparser, we use the function literal ids to count how many
// FunctionLiterals were encountered. The PreParser doesn't actually persist
@@ -133,6 +136,7 @@ PreParser::PreParseResult PreParser::PreParseFunction(
&formals, has_duplicate_parameters, may_abort, ok);
use_counts_ = nullptr;
track_unresolved_variables_ = false;
+
if (result == kLazyParsingAborted) {
return kPreParseAbort;
} else if (stack_overflow()) {
@@ -296,7 +300,10 @@ void PreParser::DeclareAndInitializeVariables(
var + initializer -> RemoveUnresolved followed by NewUnresolved
let / const + initializer -> RemoveUnresolved
*/
-
+ Scope* scope = declaration_descriptor->hoist_scope;
+ if (scope == nullptr) {
+ scope = this->scope();
+ }
if (declaration->initializer.IsEmpty() ||
(declaration_descriptor->mode == VariableMode::LET ||
declaration_descriptor->mode == VariableMode::CONST)) {
@@ -304,6 +311,9 @@ void PreParser::DeclareAndInitializeVariables(
declaration_descriptor->scope->RemoveUnresolved(identifier);
}
}
+ for (auto identifier : *(declaration->pattern.identifiers_)) {
+ scope->DeclareVariableName(identifier, declaration_descriptor->mode);
+ }
}
}
« no previous file with comments | « src/parsing/preparser.h ('k') | test/cctest/test-parsing.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698