Commit 6874978c authored by nikolaos's avatar nikolaos Committed by Commit bot

[parser] Refactor of Parse*Statement*, part 3

This patch moves the following parsing methods to ParserBase:

- ParseScopedStatement
- ParseVariableStatement
- ParseDebuggerStatement
- ParseV8Intrinsic

It also cleans up the implementation-specific use counter mechanism.

R=adamk@chromium.org, marja@chromium.org
BUG=
LOG=N

Review-Url: https://codereview.chromium.org/2318263002
Cr-Commit-Position: refs/heads/master@{#39272}
parent 82953686
......@@ -812,15 +812,13 @@ class ParserBase {
}
}
// for now, this check just collects statistics.
void CheckDecimalLiteralWithLeadingZero(int* use_counts, int beg_pos,
int end_pos) {
void CheckDecimalLiteralWithLeadingZero(int beg_pos, int end_pos) {
Scanner::Location token_location =
scanner()->decimal_with_leading_zero_position();
if (token_location.IsValid() && beg_pos <= token_location.beg_pos &&
token_location.end_pos <= end_pos) {
scanner()->clear_decimal_with_leading_zero_position();
if (use_counts != nullptr)
++use_counts[v8::Isolate::kDecimalWithLeadingZeroInStrictMode];
impl()->CountUsage(v8::Isolate::kDecimalWithLeadingZeroInStrictMode);
}
}
......@@ -1171,6 +1169,24 @@ class ParserBase {
bool* ok);
BlockT ParseBlock(ZoneList<const AstRawString*>* labels, bool* ok);
// Parse a SubStatement in strict mode, or with an extra block scope in
// sloppy mode to handle
// ES#sec-functiondeclarations-in-ifstatement-statement-clauses
// The legacy parameter indicates whether function declarations are
// banned by the ES2015 specification in this location, and they are being
// permitted here to match previous V8 behavior.
StatementT ParseScopedStatement(ZoneList<const AstRawString*>* labels,
bool legacy, bool* ok);
StatementT ParseVariableStatement(VariableDeclarationContext var_context,
ZoneList<const AstRawString*>* names,
bool* ok);
// Magical syntax support.
ExpressionT ParseV8Intrinsic(bool* ok);
StatementT ParseDebuggerStatement(bool* ok);
bool IsNextLetKeyword();
bool IsTrivialExpression();
......@@ -1712,7 +1728,7 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParsePrimaryExpression(
case Token::MOD:
if (allow_natives() || extension_ != NULL) {
BindingPatternUnexpectedToken();
return impl()->ParseV8Intrinsic(ok);
return ParseV8Intrinsic(ok);
}
break;
......@@ -3443,10 +3459,7 @@ typename ParserBase<Impl>::BlockT ParserBase<Impl>::ParseVariableDeclarations(
// FIXME(marja, nikolaos): Add an up-to-date comment about ES6 variable
// declaration syntax.
DeclarationParsingResult temp_result;
if (parsing_result == nullptr) {
parsing_result = &temp_result;
}
DCHECK_NOT_NULL(parsing_result);
parsing_result->descriptor.declaration_kind = DeclarationDescriptor::NORMAL;
parsing_result->descriptor.declaration_pos = peek_position();
parsing_result->descriptor.initialization_pos = peek_position();
......@@ -3935,6 +3948,25 @@ void ParserBase<Impl>::CheckDestructuringElement(ExpressionT expression,
}
}
template <typename Impl>
typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseV8Intrinsic(
bool* ok) {
// CallRuntime ::
// '%' Identifier Arguments
int pos = peek_position();
Expect(Token::MOD, CHECK_OK);
// Allow "eval" or "arguments" for backward compatibility.
IdentifierT name = ParseIdentifier(kAllowRestrictedIdentifiers, CHECK_OK);
Scanner::Location spread_pos;
ExpressionClassifier classifier(this);
ExpressionListT args = ParseArguments(&spread_pos, CHECK_OK);
DCHECK(!spread_pos.IsValid());
return impl()->NewV8Intrinsic(name, args, pos, ok);
}
// Redefinition of CHECK_OK for parsing statements.
#undef CHECK_OK
#define CHECK_OK CHECK_OK_CUSTOM(NullStatement)
......@@ -4062,10 +4094,10 @@ typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseStatementListItem(
return impl()->ParseClassDeclaration(nullptr, false, ok);
case Token::VAR:
case Token::CONST:
return impl()->ParseVariableStatement(kStatementListItem, nullptr, ok);
return ParseVariableStatement(kStatementListItem, nullptr, ok);
case Token::LET:
if (IsNextLetKeyword()) {
return impl()->ParseVariableStatement(kStatementListItem, nullptr, ok);
return ParseVariableStatement(kStatementListItem, nullptr, ok);
}
break;
case Token::ASYNC:
......@@ -4159,9 +4191,9 @@ typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseStatement(
*ok = false;
return impl()->NullStatement();
case Token::DEBUGGER:
return impl()->ParseDebuggerStatement(ok);
return ParseDebuggerStatement(ok);
case Token::VAR:
return impl()->ParseVariableStatement(kStatement, nullptr, ok);
return ParseVariableStatement(kStatement, nullptr, ok);
default:
return impl()->ParseExpressionOrLabelledStatement(labels, allow_function,
ok);
......@@ -4222,6 +4254,70 @@ typename ParserBase<Impl>::BlockT ParserBase<Impl>::ParseBlock(
return body;
}
template <typename Impl>
typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseScopedStatement(
ZoneList<const AstRawString*>* labels, bool legacy, bool* ok) {
if (is_strict(language_mode()) || peek() != Token::FUNCTION ||
(legacy && allow_harmony_restrictive_declarations())) {
return ParseStatement(labels, kDisallowLabelledFunctionStatement, ok);
} else {
if (legacy) {
impl()->CountUsage(v8::Isolate::kLegacyFunctionDeclaration);
}
// Make a block around the statement for a lexical binding
// is introduced by a FunctionDeclaration.
BlockState block_state(&scope_state_);
block_state.set_start_position(scanner()->location().beg_pos);
BlockT block = factory()->NewBlock(NULL, 1, false, kNoSourcePosition);
StatementT body = impl()->ParseFunctionDeclaration(CHECK_OK);
block->statements()->Add(body, zone());
block_state.set_end_position(scanner()->location().end_pos);
block->set_scope(block_state.FinalizedBlockScope());
return block;
}
}
template <typename Impl>
typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseVariableStatement(
VariableDeclarationContext var_context,
ZoneList<const AstRawString*>* names, bool* ok) {
// VariableStatement ::
// VariableDeclarations ';'
// The scope of a var declared variable anywhere inside a function
// is the entire function (ECMA-262, 3rd, 10.1.3, and 12.2). Thus we can
// transform a source-level var declaration into a (Function) Scope
// declaration, and rewrite the source-level initialization into an assignment
// statement. We use a block to collect multiple assignments.
//
// We mark the block as initializer block because we don't want the
// rewriter to add a '.result' assignment to such a block (to get compliant
// behavior for code such as print(eval('var x = 7')), and for cosmetic
// reasons when pretty-printing. Also, unless an assignment (initialization)
// is inside an initializer block, it is ignored.
DeclarationParsingResult parsing_result;
StatementT result =
ParseVariableDeclarations(var_context, &parsing_result, names, CHECK_OK);
ExpectSemicolon(CHECK_OK);
return result;
}
template <typename Impl>
typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseDebuggerStatement(
bool* ok) {
// In ECMA-262 'debugger' is defined as a reserved keyword. In some browser
// contexts this is used as a statement which invokes the debugger as i a
// break point is present.
// DebuggerStatement ::
// 'debugger' ';'
int pos = peek_position();
Expect(Token::DEBUGGER, CHECK_OK);
ExpectSemicolon(CHECK_OK);
return factory()->NewDebuggerStatement(pos);
}
#undef CHECK_OK
#undef CHECK_OK_CUSTOM
......
......@@ -506,6 +506,58 @@ void Parser::MarkTailPosition(Expression* expression) {
expression->MarkTail();
}
Expression* Parser::NewV8Intrinsic(const AstRawString* name,
ZoneList<Expression*>* args, int pos,
bool* ok) {
if (extension_ != nullptr) {
// The extension structures are only accessible while parsing the
// very first time, not when reparsing because of lazy compilation.
GetClosureScope()->ForceEagerCompilation();
}
const Runtime::Function* function = Runtime::FunctionForName(name->string());
if (function != nullptr) {
// Check for possible name clash.
DCHECK_EQ(Context::kNotFound,
Context::IntrinsicIndexForName(name->string()));
// Check for built-in IS_VAR macro.
if (function->function_id == Runtime::kIS_VAR) {
DCHECK_EQ(Runtime::RUNTIME, function->intrinsic_type);
// %IS_VAR(x) evaluates to x if x is a variable,
// leads to a parse error otherwise. Could be implemented as an
// inline function %_IS_VAR(x) to eliminate this special case.
if (args->length() == 1 && args->at(0)->AsVariableProxy() != nullptr) {
return args->at(0);
} else {
ReportMessage(MessageTemplate::kNotIsvar);
*ok = false;
return nullptr;
}
}
// Check that the expected number of arguments are being passed.
if (function->nargs != -1 && function->nargs != args->length()) {
ReportMessage(MessageTemplate::kRuntimeWrongNumArgs);
*ok = false;
return nullptr;
}
return factory()->NewCallRuntime(function, args, pos);
}
int context_index = Context::IntrinsicIndexForName(name->string());
// Check that the function is defined.
if (context_index == Context::kNotFound) {
ReportMessage(MessageTemplate::kNotDefined, name);
*ok = false;
return nullptr;
}
return factory()->NewCallRuntime(context_index, args, pos);
}
Parser::Parser(ParseInfo* info)
: ParserBase<Parser>(info->zone(), &scanner_, info->stack_limit(),
info->extension(), info->ast_value_factory(), NULL),
......@@ -707,7 +759,7 @@ FunctionLiteral* Parser::DoParseProgram(ParseInfo* info) {
if (ok && is_strict(language_mode())) {
CheckStrictOctalLiteral(beg_pos, scanner()->location().end_pos, &ok);
CheckDecimalLiteralWithLeadingZero(use_counts_, beg_pos,
CheckDecimalLiteralWithLeadingZero(beg_pos,
scanner()->location().end_pos);
}
if (ok && is_sloppy(language_mode())) {
......@@ -1617,31 +1669,6 @@ void Parser::DeclareAndInitializeVariables(
this, block, declaration_descriptor, declaration, names, ok);
}
Block* Parser::ParseVariableStatement(VariableDeclarationContext var_context,
ZoneList<const AstRawString*>* names,
bool* ok) {
// VariableStatement ::
// VariableDeclarations ';'
// The scope of a var declared variable anywhere inside a function
// is the entire function (ECMA-262, 3rd, 10.1.3, and 12.2). Thus we can
// transform a source-level var declaration into a (Function) Scope
// declaration, and rewrite the source-level initialization into an assignment
// statement. We use a block to collect multiple assignments.
//
// We mark the block as initializer block because we don't want the
// rewriter to add a '.result' assignment to such a block (to get compliant
// behavior for code such as print(eval('var x = 7')), and for cosmetic
// reasons when pretty-printing. Also, unless an assignment (initialization)
// is inside an initializer block, it is ignored.
DeclarationParsingResult parsing_result;
Block* result =
ParseVariableDeclarations(var_context, &parsing_result, names, CHECK_OK);
ExpectSemicolon(CHECK_OK);
return result;
}
static bool ContainsLabel(ZoneList<const AstRawString*>* labels,
const AstRawString* label) {
DCHECK(label != NULL);
......@@ -2767,28 +2794,6 @@ Statement* Parser::DesugarLexicalBindingsInForStatement(
return outer_block;
}
Statement* Parser::ParseScopedStatement(ZoneList<const AstRawString*>* labels,
bool legacy, bool* ok) {
if (is_strict(language_mode()) || peek() != Token::FUNCTION ||
(legacy && allow_harmony_restrictive_declarations())) {
return ParseStatement(labels, kDisallowLabelledFunctionStatement, ok);
} else {
if (legacy) {
++use_counts_[v8::Isolate::kLegacyFunctionDeclaration];
}
// Make a block around the statement for a lexical binding
// is introduced by a FunctionDeclaration.
BlockState block_state(&scope_state_);
block_state.set_start_position(scanner()->location().beg_pos);
Block* block = factory()->NewBlock(NULL, 1, false, kNoSourcePosition);
Statement* body = ParseFunctionDeclaration(CHECK_OK);
block->statements()->Add(body, zone());
block_state.set_end_position(scanner()->location().end_pos);
block->set_scope(block_state.FinalizedBlockScope());
return block;
}
}
Statement* Parser::ParseForStatement(ZoneList<const AstRawString*>* labels,
bool* ok) {
int stmt_pos = peek_position();
......@@ -3136,21 +3141,6 @@ Statement* Parser::ParseForStatement(ZoneList<const AstRawString*>* labels,
return result;
}
DebuggerStatement* Parser::ParseDebuggerStatement(bool* ok) {
// In ECMA-262 'debugger' is defined as a reserved keyword. In some browser
// contexts this is used as a statement which invokes the debugger as i a
// break point is present.
// DebuggerStatement ::
// 'debugger' ';'
int pos = peek_position();
Expect(Token::DEBUGGER, CHECK_OK);
ExpectSemicolon(CHECK_OK);
return factory()->NewDebuggerStatement(pos);
}
void Parser::ParseArrowFunctionFormalParameters(
ParserFormalParameters* parameters, Expression* expr, int end_pos,
bool* ok) {
......@@ -3537,7 +3527,7 @@ FunctionLiteral* Parser::ParseFunctionLiteral(
if (is_strict(language_mode)) {
CheckStrictOctalLiteral(scope->start_position(), scope->end_position(),
CHECK_OK);
CheckDecimalLiteralWithLeadingZero(use_counts_, scope->start_position(),
CheckDecimalLiteralWithLeadingZero(scope->start_position(),
scope->end_position());
}
CheckConflictingVarDeclarations(scope, CHECK_OK);
......@@ -4269,71 +4259,6 @@ Expression* Parser::ParseClassLiteral(const AstRawString* name,
}
Expression* Parser::ParseV8Intrinsic(bool* ok) {
// CallRuntime ::
// '%' Identifier Arguments
int pos = peek_position();
Expect(Token::MOD, CHECK_OK);
// Allow "eval" or "arguments" for backward compatibility.
const AstRawString* name = ParseIdentifier(kAllowRestrictedIdentifiers,
CHECK_OK);
Scanner::Location spread_pos;
ExpressionClassifier classifier(this);
ZoneList<Expression*>* args = ParseArguments(&spread_pos, CHECK_OK);
DCHECK(!spread_pos.IsValid());
if (extension_ != NULL) {
// The extension structures are only accessible while parsing the
// very first time not when reparsing because of lazy compilation.
GetClosureScope()->ForceEagerCompilation();
}
const Runtime::Function* function = Runtime::FunctionForName(name->string());
if (function != NULL) {
// Check for possible name clash.
DCHECK_EQ(Context::kNotFound,
Context::IntrinsicIndexForName(name->string()));
// Check for built-in IS_VAR macro.
if (function->function_id == Runtime::kIS_VAR) {
DCHECK_EQ(Runtime::RUNTIME, function->intrinsic_type);
// %IS_VAR(x) evaluates to x if x is a variable,
// leads to a parse error otherwise. Could be implemented as an
// inline function %_IS_VAR(x) to eliminate this special case.
if (args->length() == 1 && args->at(0)->AsVariableProxy() != NULL) {
return args->at(0);
} else {
ReportMessage(MessageTemplate::kNotIsvar);
*ok = false;
return NULL;
}
}
// Check that the expected number of arguments are being passed.
if (function->nargs != -1 && function->nargs != args->length()) {
ReportMessage(MessageTemplate::kRuntimeWrongNumArgs);
*ok = false;
return NULL;
}
return factory()->NewCallRuntime(function, args, pos);
}
int context_index = Context::IntrinsicIndexForName(name->string());
// Check that the function is defined.
if (context_index == Context::kNotFound) {
ReportMessage(MessageTemplate::kNotDefined, name);
*ok = false;
return NULL;
}
return factory()->NewCallRuntime(context_index, args, pos);
}
Literal* Parser::GetLiteralUndefined(int position) {
return factory()->NewUndefinedLiteral(position);
}
......
......@@ -286,9 +286,6 @@ class Parser : public ParserBase<Parser> {
const DeclarationParsingResult::Declaration* declaration,
ZoneList<const AstRawString*>* names, bool* ok);
Block* ParseVariableStatement(VariableDeclarationContext var_context,
ZoneList<const AstRawString*>* names,
bool* ok);
DoExpression* ParseDoExpression(bool* ok);
Expression* ParseYieldStarExpression(bool* ok);
......@@ -395,15 +392,6 @@ class Parser : public ParserBase<Parser> {
Statement* ParseThrowStatement(bool* ok);
Expression* MakeCatchContext(Handle<String> id, VariableProxy* value);
TryStatement* ParseTryStatement(bool* ok);
DebuggerStatement* ParseDebuggerStatement(bool* ok);
// Parse a SubStatement in strict mode, or with an extra block scope in
// sloppy mode to handle
// ES#sec-functiondeclarations-in-ifstatement-statement-clauses
// The legacy parameter indicates whether function declarations are
// banned by the ES2015 specification in this location, and they are being
// permitted here to match previous V8 behavior.
Statement* ParseScopedStatement(ZoneList<const AstRawString*>* labels,
bool legacy, bool* ok);
// !%_IsJSReceiver(result = iterator.next()) &&
// %ThrowIteratorResultNotAnObject(result)
......@@ -442,9 +430,6 @@ class Parser : public ParserBase<Parser> {
bool name_is_strict_reserved, int pos,
bool* ok);
// Magical syntax support.
Expression* ParseV8Intrinsic(bool* ok);
// Get odd-ball literals.
Literal* GetLiteralUndefined(int position);
......@@ -944,6 +929,10 @@ class Parser : public ParserBase<Parser> {
return factory()->NewBlock(labels, capacity, ignore_completion_value, pos);
}
V8_INLINE Expression* NewV8Intrinsic(const AstRawString* name,
ZoneList<Expression*>* args, int pos,
bool* ok);
V8_INLINE void AddParameterInitializationBlock(
const ParserFormalParameters& parameters, ZoneList<Statement*>* body,
bool is_async, bool* ok) {
......@@ -1031,6 +1020,10 @@ class Parser : public ParserBase<Parser> {
return function_state_->non_patterns_to_rewrite();
}
V8_INLINE void CountUsage(v8::Isolate::UseCounterFeature feature) {
++use_counts_[feature];
}
// Parser's private field members.
Scanner scanner_;
......
......@@ -101,7 +101,7 @@ PreParser::PreParseResult PreParser::PreParseLazyFunction(
if (is_strict(scope()->language_mode())) {
int end_pos = scanner()->location().end_pos;
CheckStrictOctalLiteral(start_position, end_pos, &ok);
CheckDecimalLiteralWithLeadingZero(use_counts, start_position, end_pos);
CheckDecimalLiteralWithLeadingZero(start_position, end_pos);
}
}
return kPreParseSuccess;
......@@ -121,17 +121,6 @@ PreParser::PreParseResult PreParser::PreParseLazyFunction(
// That means that contextual checks (like a label being declared where
// it is used) are generally omitted.
PreParser::Statement PreParser::ParseScopedStatement(bool legacy, bool* ok) {
if (is_strict(language_mode()) || peek() != Token::FUNCTION ||
(legacy && allow_harmony_restrictive_declarations())) {
return ParseStatement(nullptr, kDisallowLabelledFunctionStatement, ok);
} else {
BlockState block_state(&scope_state_);
return ParseFunctionDeclaration(ok);
}
}
PreParser::Statement PreParser::ParseHoistableDeclaration(
int pos, ParseFunctionFlags flags, ZoneList<const AstRawString*>* names,
bool default_export, bool* ok) {
......@@ -195,18 +184,6 @@ PreParser::Statement PreParser::ParseClassDeclaration(
return Statement::Default();
}
PreParser::Statement PreParser::ParseVariableStatement(
VariableDeclarationContext var_context,
ZoneList<const AstRawString*>* names, bool* ok) {
// VariableStatement ::
// VariableDeclarations ';'
Statement result =
ParseVariableDeclarations(var_context, nullptr, names, CHECK_OK);
ExpectSemicolon(CHECK_OK);
return result;
}
PreParser::Statement PreParser::ParseFunctionDeclaration(bool* ok) {
Consume(Token::FUNCTION);
int pos = position();
......@@ -264,7 +241,7 @@ PreParser::Statement PreParser::ParseExpressionOrLabelledStatement(
if (allow_function == kAllowLabelledFunctionStatement) {
return ParseFunctionDeclaration(ok);
} else {
return ParseScopedStatement(true, ok);
return ParseScopedStatement(names, true, ok);
}
}
Statement statement =
......@@ -288,10 +265,10 @@ PreParser::Statement PreParser::ParseIfStatement(
Expect(Token::LPAREN, CHECK_OK);
ParseExpression(true, CHECK_OK);
Expect(Token::RPAREN, CHECK_OK);
Statement stat = ParseScopedStatement(false, CHECK_OK);
Statement stat = ParseScopedStatement(labels, false, CHECK_OK);
if (peek() == Token::ELSE) {
Next();
Statement else_stat = ParseScopedStatement(false, CHECK_OK);
Statement else_stat = ParseScopedStatement(labels, false, CHECK_OK);
stat = (stat.IsJumpStatement() && else_stat.IsJumpStatement()) ?
Statement::Jump() : Statement::Default();
} else {
......@@ -388,7 +365,7 @@ PreParser::Statement PreParser::ParseWithStatement(
Scope* with_scope = NewScope(WITH_SCOPE);
BlockState block_state(&scope_state_, with_scope);
ParseScopedStatement(true, CHECK_OK);
ParseScopedStatement(labels, true, CHECK_OK);
return Statement::Default();
}
......@@ -434,7 +411,7 @@ PreParser::Statement PreParser::ParseDoWhileStatement(
// 'do' Statement 'while' '(' Expression ')' ';'
Expect(Token::DO, CHECK_OK);
ParseScopedStatement(true, CHECK_OK);
ParseScopedStatement(nullptr, true, CHECK_OK);
Expect(Token::WHILE, CHECK_OK);
Expect(Token::LPAREN, CHECK_OK);
ParseExpression(true, CHECK_OK);
......@@ -452,7 +429,7 @@ PreParser::Statement PreParser::ParseWhileStatement(
Expect(Token::LPAREN, CHECK_OK);
ParseExpression(true, CHECK_OK);
Expect(Token::RPAREN, CHECK_OK);
ParseScopedStatement(true, ok);
ParseScopedStatement(nullptr, true, ok);
return Statement::Default();
}
......@@ -518,7 +495,7 @@ PreParser::Statement PreParser::ParseForStatement(
{
ReturnExprScope no_tail_calls(function_state_,
ReturnExprContext::kInsideForInOfBody);
ParseScopedStatement(true, CHECK_OK);
ParseScopedStatement(nullptr, true, CHECK_OK);
}
return Statement::Default();
}
......@@ -555,7 +532,7 @@ PreParser::Statement PreParser::ParseForStatement(
Expect(Token::RPAREN, CHECK_OK);
{
BlockState block_state(&scope_state_);
ParseScopedStatement(true, CHECK_OK);
ParseScopedStatement(nullptr, true, CHECK_OK);
}
return Statement::Default();
}
......@@ -584,7 +561,7 @@ PreParser::Statement PreParser::ParseForStatement(
}
Expect(Token::RPAREN, CHECK_OK);
ParseScopedStatement(true, ok);
ParseScopedStatement(nullptr, true, ok);
}
return Statement::Default();
}
......@@ -672,19 +649,6 @@ PreParser::Statement PreParser::ParseTryStatement(bool* ok) {
}
PreParser::Statement PreParser::ParseDebuggerStatement(bool* ok) {
// In ECMA-262 'debugger' is defined as a reserved keyword. In some browser
// contexts this is used as a statement which invokes the debugger as if a
// break point is present.
// DebuggerStatement ::
// 'debugger' ';'
Expect(Token::DEBUGGER, CHECK_OK);
ExpectSemicolon(ok);
return Statement::Default();
}
// Redefinition of CHECK_OK for parsing expressions.
#undef CHECK_OK
#define CHECK_OK CHECK_OK_VALUE(Expression::Default())
......@@ -745,8 +709,7 @@ PreParser::Expression PreParser::ParseFunctionLiteral(
if (is_strict(language_mode)) {
int end_position = scanner()->location().end_pos;
CheckStrictOctalLiteral(start_position, end_position, CHECK_OK);
CheckDecimalLiteralWithLeadingZero(use_counts_, start_position,
end_position);
CheckDecimalLiteralWithLeadingZero(start_position, end_position);
}
return Expression::Default();
......@@ -851,28 +814,6 @@ PreParserExpression PreParser::ParseClassLiteral(
return Expression::Default();
}
PreParser::Expression PreParser::ParseV8Intrinsic(bool* ok) {
// CallRuntime ::
// '%' Identifier Arguments
Expect(Token::MOD, CHECK_OK);
if (!allow_natives()) {
*ok = false;
return Expression::Default();
}
// Allow "eval" or "arguments" for backward compatibility.
ParseIdentifier(kAllowRestrictedIdentifiers, CHECK_OK);
Scanner::Location spread_pos;
ExpressionClassifier classifier(this);
ParseArguments(&spread_pos, ok);
ValidateExpression(CHECK_OK);
DCHECK(!spread_pos.IsValid());
return Expression::Default();
}
PreParserExpression PreParser::ParseDoExpression(bool* ok) {
// AssignmentExpression ::
// do '{' StatementList '}'
......
......@@ -571,12 +571,6 @@ class PreParserFactory {
int pos) {
return PreParserExpression::Default();
}
PreParserExpression NewCallRuntime(const AstRawString* name,
const Runtime::Function* function,
PreParserExpressionList arguments,
int pos) {
return PreParserExpression::Default();
}
PreParserStatement NewReturnStatement(PreParserExpression expression,
int pos) {
return PreParserStatement::Default();
......@@ -611,6 +605,10 @@ class PreParserFactory {
return PreParserStatement::Default();
}
PreParserStatement NewDebuggerStatement(int pos) {
return PreParserStatement::Default();
}
// Return the object itself as AstVisitor and implement the needed
// dummy method right in this class.
PreParserFactory* visitor() { return this; }
......@@ -733,7 +731,7 @@ class PreParser : public ParserBase<PreParser> {
} else if (is_strict(this->scope()->language_mode())) {
CheckStrictOctalLiteral(start_position, scanner()->location().end_pos,
&ok);
CheckDecimalLiteralWithLeadingZero(use_counts_, start_position,
CheckDecimalLiteralWithLeadingZero(start_position,
scanner()->location().end_pos);
}
if (materialized_literals) {
......@@ -766,7 +764,6 @@ class PreParser : public ParserBase<PreParser> {
// which is set to false if parsing failed; it is unchanged otherwise.
// By making the 'exception handling' explicit, we are forced to check
// for failure at the call sites.
Statement ParseScopedStatement(bool legacy, bool* ok);
Statement ParseHoistableDeclaration(ZoneList<const AstRawString*>* names,
bool default_export, bool* ok);
Statement ParseHoistableDeclaration(int pos, ParseFunctionFlags flags,
......@@ -778,9 +775,6 @@ class PreParser : public ParserBase<PreParser> {
Expression ParseAsyncFunctionExpression(bool* ok);
Statement ParseClassDeclaration(ZoneList<const AstRawString*>* names,
bool default_export, bool* ok);
Statement ParseVariableStatement(VariableDeclarationContext var_context,
ZoneList<const AstRawString*>* names,
bool* ok);
Statement ParseExpressionOrLabelledStatement(
ZoneList<const AstRawString*>* names,
AllowLabelledFunctionStatement allow_function, bool* ok);
......@@ -799,10 +793,8 @@ class PreParser : public ParserBase<PreParser> {
Statement ParseForStatement(ZoneList<const AstRawString*>* labels, bool* ok);
Statement ParseThrowStatement(bool* ok);
Statement ParseTryStatement(bool* ok);
Statement ParseDebuggerStatement(bool* ok);
Expression ParseConditionalExpression(bool accept_IN, bool* ok);
Expression ParseObjectLiteral(bool* ok);
Expression ParseV8Intrinsic(bool* ok);
Expression ParseDoExpression(bool* ok);
V8_INLINE PreParserStatementList ParseEagerFunctionBody(
......@@ -1174,6 +1166,12 @@ class PreParser : public ParserBase<PreParser> {
return PreParserStatement::Default();
}
V8_INLINE PreParserExpression
NewV8Intrinsic(PreParserIdentifier name, PreParserExpressionList arguments,
int pos, bool* ok) {
return PreParserExpression::Default();
}
V8_INLINE void AddParameterInitializationBlock(
const PreParserFormalParameters& parameters, PreParserStatementList body,
bool is_async, bool* ok) {}
......@@ -1240,6 +1238,10 @@ class PreParser : public ParserBase<PreParser> {
return function_state_->non_patterns_to_rewrite();
}
V8_INLINE void CountUsage(v8::Isolate::UseCounterFeature feature) {
if (use_counts_ != nullptr) ++use_counts_[feature];
}
// Preparser's private field members.
int* use_counts_;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment