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

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

Issue 2267783002: [parser] Clean up (pre)parser traits (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@nickie-2267663002-crtp
Patch Set: Rebase Created 4 years, 3 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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 } 87 }
88 88
89 PreParserExpression ParserBaseTraits<PreParser>::ExpressionFromString( 89 PreParserExpression ParserBaseTraits<PreParser>::ExpressionFromString(
90 int pos, Scanner* scanner, PreParserFactory* factory) const { 90 int pos, Scanner* scanner, PreParserFactory* factory) const {
91 if (scanner->UnescapedLiteralMatches("use strict", 10)) { 91 if (scanner->UnescapedLiteralMatches("use strict", 10)) {
92 return PreParserExpression::UseStrictStringLiteral(); 92 return PreParserExpression::UseStrictStringLiteral();
93 } 93 }
94 return PreParserExpression::StringLiteral(); 94 return PreParserExpression::StringLiteral();
95 } 95 }
96 96
97 PreParserExpression ParserBaseTraits<PreParser>::ParseV8Intrinsic(bool* ok) {
98 return delegate()->ParseV8Intrinsic(ok);
99 }
100
101 PreParserExpression ParserBaseTraits<PreParser>::ParseFunctionLiteral(
102 PreParserIdentifier name, Scanner::Location function_name_location,
103 FunctionNameValidity function_name_validity, FunctionKind kind,
104 int function_token_position, FunctionLiteral::FunctionType type,
105 LanguageMode language_mode, bool* ok) {
106 return delegate()->ParseFunctionLiteral(
107 name, function_name_location, function_name_validity, kind,
108 function_token_position, type, language_mode, ok);
109 }
110
111 PreParser::PreParseResult PreParser::PreParseLazyFunction( 97 PreParser::PreParseResult PreParser::PreParseLazyFunction(
112 LanguageMode language_mode, FunctionKind kind, bool has_simple_parameters, 98 LanguageMode language_mode, FunctionKind kind, bool has_simple_parameters,
113 bool parsing_module, ParserRecorder* log, Scanner::BookmarkScope* bookmark, 99 bool parsing_module, ParserRecorder* log, Scanner::BookmarkScope* bookmark,
114 int* use_counts) { 100 int* use_counts) {
115 parsing_module_ = parsing_module; 101 parsing_module_ = parsing_module;
116 log_ = log; 102 log_ = log;
117 use_counts_ = use_counts; 103 use_counts_ = use_counts;
118 // Lazy functions always have trivial outer scopes (no with/catch scopes). 104 // Lazy functions always have trivial outer scopes (no with/catch scopes).
119 DCHECK_NULL(scope_state_); 105 DCHECK_NULL(scope_state_);
120 DeclarationScope* top_scope = NewScriptScope(); 106 DeclarationScope* top_scope = NewScriptScope();
(...skipping 20 matching lines...) Expand all
141 if (is_strict(scope()->language_mode())) { 127 if (is_strict(scope()->language_mode())) {
142 int end_pos = scanner()->location().end_pos; 128 int end_pos = scanner()->location().end_pos;
143 CheckStrictOctalLiteral(start_position, end_pos, &ok); 129 CheckStrictOctalLiteral(start_position, end_pos, &ok);
144 CheckDecimalLiteralWithLeadingZero(use_counts, start_position, end_pos); 130 CheckDecimalLiteralWithLeadingZero(use_counts, start_position, end_pos);
145 if (!ok) return kPreParseSuccess; 131 if (!ok) return kPreParseSuccess;
146 } 132 }
147 } 133 }
148 return kPreParseSuccess; 134 return kPreParseSuccess;
149 } 135 }
150 136
151 PreParserExpression ParserBaseTraits<PreParser>::ParseClassLiteral(
152 Type::ExpressionClassifier* classifier, PreParserIdentifier name,
153 Scanner::Location class_name_location, bool name_is_strict_reserved,
154 int pos, bool* ok) {
155 return delegate()->ParseClassLiteral(classifier, name, class_name_location,
156 name_is_strict_reserved, pos, ok);
157 }
158
159 137
160 // Preparsing checks a JavaScript program and emits preparse-data that helps 138 // Preparsing checks a JavaScript program and emits preparse-data that helps
161 // a later parsing to be faster. 139 // a later parsing to be faster.
162 // See preparser-data.h for the data. 140 // See preparser-data.h for the data.
163 141
164 // The PreParser checks that the syntax follows the grammar for JavaScript, 142 // The PreParser checks that the syntax follows the grammar for JavaScript,
165 // and collects some information about the program along the way. 143 // and collects some information about the program along the way.
166 // The grammar check is only performed in order to understand the program 144 // The grammar check is only performed in order to understand the program
167 // sufficiently to deduce some information about it, that can be used 145 // sufficiently to deduce some information about it, that can be used
168 // to speed up later parsing. Finding errors is not the goal of pre-parsing, 146 // to speed up later parsing. Finding errors is not the goal of pre-parsing,
(...skipping 1098 matching lines...) Expand 10 before | Expand all | Expand 10 after
1267 // do '{' StatementList '}' 1245 // do '{' StatementList '}'
1268 Expect(Token::DO, CHECK_OK); 1246 Expect(Token::DO, CHECK_OK);
1269 Expect(Token::LBRACE, CHECK_OK); 1247 Expect(Token::LBRACE, CHECK_OK);
1270 while (peek() != Token::RBRACE) { 1248 while (peek() != Token::RBRACE) {
1271 ParseStatementListItem(CHECK_OK); 1249 ParseStatementListItem(CHECK_OK);
1272 } 1250 }
1273 Expect(Token::RBRACE, CHECK_OK); 1251 Expect(Token::RBRACE, CHECK_OK);
1274 return PreParserExpression::Default(); 1252 return PreParserExpression::Default();
1275 } 1253 }
1276 1254
1277 void ParserBaseTraits<PreParser>::ParseAsyncArrowSingleExpressionBody( 1255 void PreParser::ParseAsyncArrowSingleExpressionBody(
1278 PreParserStatementList body, bool accept_IN, 1256 PreParserStatementList body, bool accept_IN,
1279 Type::ExpressionClassifier* classifier, int pos, bool* ok) { 1257 ExpressionClassifier* classifier, int pos, bool* ok) {
1280 Scope* scope = delegate()->scope(); 1258 scope()->ForceContextAllocation();
1281 scope->ForceContextAllocation();
1282 1259
1283 PreParserExpression return_value = delegate()->ParseAssignmentExpression( 1260 PreParserExpression return_value =
1284 accept_IN, classifier, CHECK_OK_CUSTOM(Void)); 1261 ParseAssignmentExpression(accept_IN, classifier, CHECK_OK_CUSTOM(Void));
1285 1262
1286 body->Add(PreParserStatement::ExpressionStatement(return_value), zone()); 1263 body->Add(PreParserStatement::ExpressionStatement(return_value), zone());
1287 } 1264 }
1288 1265
1289 #undef CHECK_OK 1266 #undef CHECK_OK
1290 #undef CHECK_OK_CUSTOM 1267 #undef CHECK_OK_CUSTOM
1291 1268
1292 1269
1293 } // namespace internal 1270 } // namespace internal
1294 } // namespace v8 1271 } // 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