Commit 31cde16e authored by Adam Klein's avatar Adam Klein Committed by Commit Bot

[parser cleanup] Replace redundant GetLiteral*() helpers with factory calls

Bug: v8:6092, v8:6921
Change-Id: I321ecc661832f2212d16260aa6b863cef56b7676
Reviewed-on: https://chromium-review.googlesource.com/719414Reviewed-by: 's avatarSathya Gunasekaran <gsathya@chromium.org>
Commit-Queue: Adam Klein <adamk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#48564}
parent 5a8c49a5
......@@ -3150,8 +3150,9 @@ class AstNodeFactory final BASE_EMBEDDED {
return new (zone_) Literal(ast_value_factory_->NewUndefined(), pos);
}
Literal* NewTheHoleLiteral(int pos) {
return new (zone_) Literal(ast_value_factory_->NewTheHole(), pos);
Literal* NewTheHoleLiteral() {
return new (zone_)
Literal(ast_value_factory_->NewTheHole(), kNoSourcePosition);
}
ObjectLiteral* NewObjectLiteral(
......
......@@ -1364,7 +1364,7 @@ class ParserBase {
inline StatementT BuildReturnStatement(ExpressionT expr, int pos,
int end_pos = kNoSourcePosition) {
if (impl()->IsNull(expr)) {
expr = impl()->GetLiteralUndefined(kNoSourcePosition);
expr = factory()->NewUndefinedLiteral(kNoSourcePosition);
} else if (is_async_generator()) {
// In async generators, if there is an explicit operand to the return
// statement, await the operand.
......@@ -2001,7 +2001,7 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseArrayLiteral(
while (peek() != Token::RBRACK) {
ExpressionT elem;
if (peek() == Token::COMMA) {
elem = impl()->GetLiteralTheHole(peek_position());
elem = factory()->NewTheHoleLiteral();
} else if (peek() == Token::ELLIPSIS) {
int start_pos = peek_position();
Consume(Token::ELLIPSIS);
......@@ -2450,7 +2450,7 @@ ParserBase<Impl>::ParseObjectPropertyDefinition(ObjectLiteralChecker* checker,
*is_rest_property = true;
return factory()->NewObjectLiteralProperty(
impl()->GetLiteralTheHole(kNoSourcePosition), name_expression,
factory()->NewTheHoleLiteral(), name_expression,
ObjectLiteralProperty::SPREAD, true);
case PropertyKind::kValueProperty: {
......@@ -3866,7 +3866,7 @@ typename ParserBase<Impl>::BlockT ParserBase<Impl>::ParseVariableDeclarations(
}
// 'let x' initializes 'x' to undefined.
if (parsing_result->descriptor.mode == LET) {
value = impl()->GetLiteralUndefined(position());
value = factory()->NewUndefinedLiteral(position());
}
}
......
......@@ -3212,11 +3212,6 @@ Expression* Parser::RewriteClassLiteral(Scope* block_scope,
return class_literal;
}
Literal* Parser::GetLiteralUndefined(int position) {
return factory()->NewUndefinedLiteral(position);
}
void Parser::CheckConflictingVarDeclarations(Scope* scope, bool* ok) {
Declaration* decl = scope->CheckConflictingVarDeclarations();
if (decl != nullptr) {
......@@ -3419,7 +3414,8 @@ void Parser::AddTemplateSpan(TemplateLiteralState* state, bool should_cook,
Literal* cooked = factory()->NewStringLiteral(tv, pos);
(*state)->AddTemplateSpan(cooked, raw, end, zone());
} else {
(*state)->AddTemplateSpan(GetLiteralUndefined(pos), raw, end, zone());
(*state)->AddTemplateSpan(factory()->NewUndefinedLiteral(pos), raw, end,
zone());
}
}
......
......@@ -427,9 +427,6 @@ class V8_EXPORT_PRIVATE Parser : public NON_EXPORTED_BASE(ParserBase<Parser>) {
int function_token_position, FunctionLiteral::FunctionType type,
LanguageMode language_mode, bool* ok);
// Get odd-ball literals.
Literal* GetLiteralUndefined(int position);
// Check if the scope has conflicting var/let declarations from different
// scopes. This covers for example
//
......@@ -851,11 +848,6 @@ class V8_EXPORT_PRIVATE Parser : public NON_EXPORTED_BASE(ParserBase<Parser>) {
return ast_value_factory()->empty_string();
}
// Odd-ball literal creators.
V8_INLINE Literal* GetLiteralTheHole(int position) {
return factory()->NewTheHoleLiteral(kNoSourcePosition);
}
// Producing data during the recursive descent.
V8_INLINE const AstRawString* GetSymbol() const {
const AstRawString* result = scanner()->CurrentSymbol(ast_value_factory());
......
......@@ -542,6 +542,9 @@ class PreParserFactory {
PreParserExpression NewUndefinedLiteral(int pos) {
return PreParserExpression::Default();
}
PreParserExpression NewTheHoleLiteral() {
return PreParserExpression::Default();
}
PreParserExpression NewRegExpLiteral(const PreParserIdentifier& js_pattern,
int js_flags, int pos) {
return PreParserExpression::Default();
......@@ -1450,15 +1453,6 @@ class PreParser : public ParserBase<PreParser> {
return PreParserIdentifier::Default();
}
// Odd-ball literal creators.
V8_INLINE PreParserExpression GetLiteralTheHole(int position) {
return PreParserExpression::Default();
}
V8_INLINE PreParserExpression GetLiteralUndefined(int position) {
return PreParserExpression::Default();
}
// Producing data during the recursive descent.
PreParserIdentifier GetSymbol() const;
......
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