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

Unified Diff: src/parsing/preparser.h

Issue 2636543002: PreParser scope analysis: sloppy block funcs. (Closed)
Patch Set: proactive code review Created 3 years, 11 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/parsing/parser-base.h ('k') | src/parsing/preparser.cc » ('j') | no next file with comments »
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 1f822a46c3591e7b6922adf095ac8433b4dcf4ab..77fe061f42a40798847e39f6f17fa80a49d5e9b7 100644
--- a/src/parsing/preparser.h
+++ b/src/parsing/preparser.h
@@ -886,6 +886,9 @@ class PreParser : public ParserBase<PreParser> {
bool is_module = false) {
DCHECK_NULL(scope_state_);
DeclarationScope* scope = NewScriptScope();
+#ifdef DEBUG
+ scope->set_is_being_lazily_parsed(true);
+#endif
// ModuleDeclarationInstantiation for Source Text Module Records creates a
// new Module Environment Record whose outer lexical environment record is
@@ -1089,9 +1092,19 @@ class PreParser : public ParserBase<PreParser> {
}
V8_INLINE PreParserStatement DeclareFunction(
- PreParserIdentifier variable_name, PreParserExpression function, int pos,
- bool is_generator, bool is_async, ZoneList<const AstRawString*>* names,
+ PreParserIdentifier variable_name, PreParserExpression function,
+ VariableMode mode, int pos, bool is_generator, bool is_async,
+ bool is_sloppy_block_function, ZoneList<const AstRawString*>* names,
bool* ok) {
+ DCHECK_NULL(names);
+ if (variable_name.string_ != nullptr) {
+ DCHECK(track_unresolved_variables_);
+ scope()->DeclareVariableName(variable_name.string_, mode);
+ if (is_sloppy_block_function) {
+ GetDeclarationScope()->DeclareSloppyBlockFunction(variable_name.string_,
+ scope());
+ }
+ }
return Statement::Default();
}
@@ -1616,8 +1629,8 @@ PreParserStatementList PreParser::ParseEagerFunctionBody(
FunctionLiteral::FunctionType function_type, bool* ok) {
PreParserStatementList result;
- Scope* inner_scope = scope();
- if (!parameters.is_simple) inner_scope = NewScope(BLOCK_SCOPE);
+ DeclarationScope* inner_scope = scope()->AsDeclarationScope();
+ if (!parameters.is_simple) inner_scope = NewVarblockScope();
{
BlockState block_state(&scope_state_, inner_scope);
@@ -1626,6 +1639,10 @@ PreParserStatementList PreParser::ParseEagerFunctionBody(
}
Expect(Token::RBRACE, ok);
+
+ if (is_sloppy(inner_scope->language_mode())) {
+ inner_scope->HoistSloppyBlockFunctions(nullptr);
+ }
return result;
}
« no previous file with comments | « src/parsing/parser-base.h ('k') | src/parsing/preparser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698