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

Side by Side Diff: src/parsing/preparser.cc

Issue 2169823002: FunctionState doesn't need to know AstNodeFactory. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix Created 4 years, 5 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 unified diff | Download patch
« no previous file with comments | « src/parsing/preparser.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 <cmath> 5 #include <cmath>
6 6
7 #include "src/allocation.h" 7 #include "src/allocation.h"
8 #include "src/base/logging.h" 8 #include "src/base/logging.h"
9 #include "src/conversions-inl.h" 9 #include "src/conversions-inl.h"
10 #include "src/conversions.h" 10 #include "src/conversions.h"
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 PreParser::PreParseResult PreParser::PreParseLazyFunction( 125 PreParser::PreParseResult PreParser::PreParseLazyFunction(
126 LanguageMode language_mode, FunctionKind kind, bool has_simple_parameters, 126 LanguageMode language_mode, FunctionKind kind, bool has_simple_parameters,
127 bool parsing_module, ParserRecorder* log, Scanner::BookmarkScope* bookmark, 127 bool parsing_module, ParserRecorder* log, Scanner::BookmarkScope* bookmark,
128 int* use_counts) { 128 int* use_counts) {
129 parsing_module_ = parsing_module; 129 parsing_module_ = parsing_module;
130 log_ = log; 130 log_ = log;
131 use_counts_ = use_counts; 131 use_counts_ = use_counts;
132 // Lazy functions always have trivial outer scopes (no with/catch scopes). 132 // Lazy functions always have trivial outer scopes (no with/catch scopes).
133 DCHECK_NULL(scope_state_); 133 DCHECK_NULL(scope_state_);
134 Scope* top_scope = NewScriptScope(); 134 Scope* top_scope = NewScriptScope();
135 PreParserFactory top_factory(nullptr);
136 FunctionState top_state(&function_state_, &scope_state_, top_scope, 135 FunctionState top_state(&function_state_, &scope_state_, top_scope,
137 kNormalFunction, &top_factory); 136 kNormalFunction);
138 scope()->SetLanguageMode(language_mode); 137 scope()->SetLanguageMode(language_mode);
139 Scope* function_scope = NewFunctionScope(kind); 138 Scope* function_scope = NewFunctionScope(kind);
140 if (!has_simple_parameters) function_scope->SetHasNonSimpleParameters(); 139 if (!has_simple_parameters) function_scope->SetHasNonSimpleParameters();
141 PreParserFactory function_factory(nullptr);
142 FunctionState function_state(&function_state_, &scope_state_, function_scope, 140 FunctionState function_state(&function_state_, &scope_state_, function_scope,
143 kind, &function_factory); 141 kind);
144 DCHECK_EQ(Token::LBRACE, scanner()->current_token()); 142 DCHECK_EQ(Token::LBRACE, scanner()->current_token());
145 bool ok = true; 143 bool ok = true;
146 int start_position = peek_position(); 144 int start_position = peek_position();
147 ParseLazyFunctionLiteralBody(&ok, bookmark); 145 ParseLazyFunctionLiteralBody(&ok, bookmark);
148 use_counts_ = nullptr; 146 use_counts_ = nullptr;
149 if (bookmark && bookmark->HasBeenReset()) { 147 if (bookmark && bookmark->HasBeenReset()) {
150 // Do nothing, as we've just aborted scanning this function. 148 // Do nothing, as we've just aborted scanning this function.
151 } else if (stack_overflow()) { 149 } else if (stack_overflow()) {
152 return kPreParseStackOverflow; 150 return kPreParseStackOverflow;
153 } else if (!ok) { 151 } else if (!ok) {
(...skipping 952 matching lines...) Expand 10 before | Expand all | Expand 10 after
1106 FunctionNameValidity function_name_validity, FunctionKind kind, 1104 FunctionNameValidity function_name_validity, FunctionKind kind,
1107 int function_token_pos, FunctionLiteral::FunctionType function_type, 1105 int function_token_pos, FunctionLiteral::FunctionType function_type,
1108 LanguageMode language_mode, bool* ok) { 1106 LanguageMode language_mode, bool* ok) {
1109 // Function :: 1107 // Function ::
1110 // '(' FormalParameterList? ')' '{' FunctionBody '}' 1108 // '(' FormalParameterList? ')' '{' FunctionBody '}'
1111 1109
1112 // Parse function body. 1110 // Parse function body.
1113 bool outer_is_script_scope = scope()->is_script_scope(); 1111 bool outer_is_script_scope = scope()->is_script_scope();
1114 Scope* function_scope = NewFunctionScope(kind); 1112 Scope* function_scope = NewFunctionScope(kind);
1115 function_scope->SetLanguageMode(language_mode); 1113 function_scope->SetLanguageMode(language_mode);
1116 PreParserFactory factory(NULL);
1117 FunctionState function_state(&function_state_, &scope_state_, function_scope, 1114 FunctionState function_state(&function_state_, &scope_state_, function_scope,
1118 kind, &factory); 1115 kind);
1119 DuplicateFinder duplicate_finder(scanner()->unicode_cache()); 1116 DuplicateFinder duplicate_finder(scanner()->unicode_cache());
1120 ExpressionClassifier formals_classifier(this, &duplicate_finder); 1117 ExpressionClassifier formals_classifier(this, &duplicate_finder);
1121 1118
1122 Expect(Token::LPAREN, CHECK_OK); 1119 Expect(Token::LPAREN, CHECK_OK);
1123 int start_position = scanner()->location().beg_pos; 1120 int start_position = scanner()->location().beg_pos;
1124 function_scope->set_start_position(start_position); 1121 function_scope->set_start_position(start_position);
1125 PreParserFormalParameters formals(function_scope); 1122 PreParserFormalParameters formals(function_scope);
1126 ParseFormalParameterList(&formals, &formals_classifier, CHECK_OK); 1123 ParseFormalParameterList(&formals, &formals_classifier, CHECK_OK);
1127 Expect(Token::RPAREN, CHECK_OK); 1124 Expect(Token::RPAREN, CHECK_OK);
1128 int formals_end_position = scanner()->location().end_pos; 1125 int formals_end_position = scanner()->location().end_pos;
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
1321 1318
1322 body->Add(PreParserStatement::ExpressionStatement(return_value), zone()); 1319 body->Add(PreParserStatement::ExpressionStatement(return_value), zone());
1323 } 1320 }
1324 1321
1325 #undef CHECK_OK 1322 #undef CHECK_OK
1326 #undef CHECK_OK_CUSTOM 1323 #undef CHECK_OK_CUSTOM
1327 1324
1328 1325
1329 } // namespace internal 1326 } // namespace internal
1330 } // namespace v8 1327 } // namespace v8
OLDNEW
« no previous file with comments | « src/parsing/preparser.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698