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

Unified Diff: src/parsing/preparser.h

Issue 2673313003: [parser] Skipping inner funcs: produce the same scopes / variables for loops. (Closed)
Patch Set: moar Created 3 years, 10 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 | « no previous file | src/parsing/preparser.cc » ('j') | test/cctest/test-parsing.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parsing/preparser.h
diff --git a/src/parsing/preparser.h b/src/parsing/preparser.h
index 0120c2c5dffaf33bb24982f1447b6baa2d2b4dc2..23b8c52ff416da37bee5123ce0731de07670588b 100644
--- a/src/parsing/preparser.h
+++ b/src/parsing/preparser.h
@@ -1320,14 +1320,31 @@ class PreParser : public ParserBase<PreParser> {
PreParserExpression* each_variable, bool* ok) {
if (track_unresolved_variables_) {
DCHECK(for_info->parsing_result.declarations.length() == 1);
+ bool is_for_var_of =
+ for_info->mode == ForEachStatement::ITERATE &&
+ for_info->parsing_result.descriptor.mode == VariableMode::VAR;
+
DeclareAndInitializeVariables(
PreParserStatement::Default(), &for_info->parsing_result.descriptor,
- &for_info->parsing_result.declarations[0], nullptr, ok);
+ &for_info->parsing_result.declarations[0],
+ (IsLexicalVariableMode(for_info->parsing_result.descriptor.mode) ||
vogelheim 2017/02/06 10:02:11 super nitpick: Maybe hoist this expression into an
marja 2017/02/06 10:11:53 added collect_names = ... here and in the correspo
+ is_for_var_of)
+ ? &for_info->bound_names
+ : nullptr,
+ ok);
}
}
V8_INLINE PreParserStatement CreateForEachStatementTDZ(
PreParserStatement init_block, const ForInfo& for_info, bool* ok) {
+ if (track_unresolved_variables_) {
+ if (IsLexicalVariableMode(for_info.parsing_result.descriptor.mode)) {
+ for (auto name : for_info.bound_names) {
+ scope()->DeclareVariableName(name, LET);
+ }
+ return PreParserStatement::Default();
+ }
+ }
return init_block;
}
@@ -1337,9 +1354,11 @@ class PreParser : public ParserBase<PreParser> {
PreParserStatement body, Scope* inner_scope, const ForInfo& for_info,
bool* ok) {
// See Parser::DesugarLexicalBindingsInForStatement.
- for (int i = 0; i < for_info.bound_names.length(); i++) {
- inner_scope->DeclareVariableName(for_info.bound_names[i],
- for_info.parsing_result.descriptor.mode);
+ if (track_unresolved_variables_) {
+ for (auto name : for_info.bound_names) {
+ inner_scope->DeclareVariableName(
+ name, for_info.parsing_result.descriptor.mode);
+ }
}
return loop;
}
« no previous file with comments | « no previous file | src/parsing/preparser.cc » ('j') | test/cctest/test-parsing.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698