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

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

Issue 2209573002: Separate Scope into DeclarationScope and Scope (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Move has_simple_parameters_ to DeclarationScope Created 4 years, 4 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
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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 124
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 DeclarationScope* top_scope = NewScriptScope();
135 FunctionState top_state(&function_state_, &scope_state_, top_scope, 135 FunctionState top_state(&function_state_, &scope_state_, top_scope,
136 kNormalFunction); 136 kNormalFunction);
137 scope()->SetLanguageMode(language_mode); 137 scope()->SetLanguageMode(language_mode);
138 Scope* function_scope = NewFunctionScope(kind); 138 DeclarationScope* function_scope = NewFunctionScope(kind);
139 if (!has_simple_parameters) function_scope->SetHasNonSimpleParameters(); 139 if (!has_simple_parameters) function_scope->SetHasNonSimpleParameters();
140 FunctionState function_state(&function_state_, &scope_state_, function_scope, 140 FunctionState function_state(&function_state_, &scope_state_, function_scope,
141 kind); 141 kind);
142 DCHECK_EQ(Token::LBRACE, scanner()->current_token()); 142 DCHECK_EQ(Token::LBRACE, scanner()->current_token());
143 bool ok = true; 143 bool ok = true;
144 int start_position = peek_position(); 144 int start_position = peek_position();
145 ParseLazyFunctionLiteralBody(&ok, bookmark); 145 ParseLazyFunctionLiteralBody(&ok, bookmark);
146 use_counts_ = nullptr; 146 use_counts_ = nullptr;
147 if (bookmark && bookmark->HasBeenReset()) { 147 if (bookmark && bookmark->HasBeenReset()) {
148 // Do nothing, as we've just aborted scanning this function. 148 // Do nothing, as we've just aborted scanning this function.
(...skipping 947 matching lines...) Expand 10 before | Expand all | Expand 10 after
1096 PreParser::Expression PreParser::ParseFunctionLiteral( 1096 PreParser::Expression PreParser::ParseFunctionLiteral(
1097 Identifier function_name, Scanner::Location function_name_location, 1097 Identifier function_name, Scanner::Location function_name_location,
1098 FunctionNameValidity function_name_validity, FunctionKind kind, 1098 FunctionNameValidity function_name_validity, FunctionKind kind,
1099 int function_token_pos, FunctionLiteral::FunctionType function_type, 1099 int function_token_pos, FunctionLiteral::FunctionType function_type,
1100 LanguageMode language_mode, bool* ok) { 1100 LanguageMode language_mode, bool* ok) {
1101 // Function :: 1101 // Function ::
1102 // '(' FormalParameterList? ')' '{' FunctionBody '}' 1102 // '(' FormalParameterList? ')' '{' FunctionBody '}'
1103 1103
1104 // Parse function body. 1104 // Parse function body.
1105 bool outer_is_script_scope = scope()->is_script_scope(); 1105 bool outer_is_script_scope = scope()->is_script_scope();
1106 Scope* function_scope = NewFunctionScope(kind); 1106 DeclarationScope* function_scope = NewFunctionScope(kind);
1107 function_scope->SetLanguageMode(language_mode); 1107 function_scope->SetLanguageMode(language_mode);
1108 FunctionState function_state(&function_state_, &scope_state_, function_scope, 1108 FunctionState function_state(&function_state_, &scope_state_, function_scope,
1109 kind); 1109 kind);
1110 DuplicateFinder duplicate_finder(scanner()->unicode_cache()); 1110 DuplicateFinder duplicate_finder(scanner()->unicode_cache());
1111 ExpressionClassifier formals_classifier(this, &duplicate_finder); 1111 ExpressionClassifier formals_classifier(this, &duplicate_finder);
1112 1112
1113 Expect(Token::LPAREN, CHECK_OK); 1113 Expect(Token::LPAREN, CHECK_OK);
1114 int start_position = scanner()->location().beg_pos; 1114 int start_position = scanner()->location().beg_pos;
1115 function_scope->set_start_position(start_position); 1115 function_scope->set_start_position(start_position);
1116 PreParserFormalParameters formals(function_scope); 1116 PreParserFormalParameters formals(function_scope);
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
1311 1311
1312 body->Add(PreParserStatement::ExpressionStatement(return_value), zone()); 1312 body->Add(PreParserStatement::ExpressionStatement(return_value), zone());
1313 } 1313 }
1314 1314
1315 #undef CHECK_OK 1315 #undef CHECK_OK
1316 #undef CHECK_OK_CUSTOM 1316 #undef CHECK_OK_CUSTOM
1317 1317
1318 1318
1319 } // namespace internal 1319 } // namespace internal
1320 } // namespace v8 1320 } // namespace v8
OLDNEW
« src/ast/scopes.cc ('K') | « src/parsing/preparser.h ('k') | src/parsing/rewriter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698