Commit 5c8c6fa1 authored by bakkot's avatar bakkot Committed by Commit bot

[parser] Clean up ParserBase typedefs

The ParserTypes class has typedefs provided by the preparser or the
parser (e.g. PreParserExpression vs Expression*). Some of those typedefs
had gotten stale and were getting in the way, especially on gcc. We
also were making inconsistent use of aliases in parser-base.h; now their
use is much more consistent.

Review-Url: https://codereview.chromium.org/2305523002
Cr-Commit-Position: refs/heads/master@{#39101}
parent 903172e4
...@@ -175,23 +175,19 @@ struct FormalParametersBase { ...@@ -175,23 +175,19 @@ struct FormalParametersBase {
// // Synonyms for ParserBase<Impl> and Impl, respectively. // // Synonyms for ParserBase<Impl> and Impl, respectively.
// typedef Base; // typedef Base;
// typedef Impl; // typedef Impl;
// // TODO(nikolaos): these two will probably go away, as they are // // TODO(nikolaos): this one will probably go away, as it is
// // not related to pure parsing. // // not related to pure parsing.
// typedef GeneratorVariable; // typedef GeneratorVariable;
// typedef AstProperties;
// // Return types for traversing functions. // // Return types for traversing functions.
// typedef Identifier; // typedef Identifier;
// typedef Expression; // typedef Expression;
// typedef YieldExpression;
// typedef FunctionLiteral; // typedef FunctionLiteral;
// typedef ClassLiteral;
// typedef Literal;
// typedef ObjectLiteralProperty; // typedef ObjectLiteralProperty;
// typedef ExpressionList; // typedef ExpressionList;
// typedef PropertyList; // typedef PropertyList;
// typedef FormalParameter;
// typedef FormalParameters; // typedef FormalParameters;
// typedef StatementList; // typedef StatementList;
// typedef Block;
// // For constructing objects returned by the traversing functions. // // For constructing objects returned by the traversing functions.
// typedef Factory; // typedef Factory;
// }; // };
...@@ -204,17 +200,17 @@ class ParserBase { ...@@ -204,17 +200,17 @@ class ParserBase {
public: public:
// Shorten type names defined by ParserTypes<Impl>. // Shorten type names defined by ParserTypes<Impl>.
typedef ParserTypes<Impl> Types; typedef ParserTypes<Impl> Types;
typedef typename Types::Expression ExpressionT;
typedef typename Types::Identifier IdentifierT; typedef typename Types::Identifier IdentifierT;
typedef typename Types::FormalParameter FormalParameterT; typedef typename Types::Expression ExpressionT;
typedef typename Types::FormalParameters FormalParametersT;
typedef typename Types::FunctionLiteral FunctionLiteralT; typedef typename Types::FunctionLiteral FunctionLiteralT;
typedef typename Types::Literal LiteralT;
typedef typename Types::ObjectLiteralProperty ObjectLiteralPropertyT; typedef typename Types::ObjectLiteralProperty ObjectLiteralPropertyT;
typedef typename Types::ExpressionList ExpressionListT;
typedef typename Types::PropertyList PropertyListT;
typedef typename Types::FormalParameters FormalParametersT;
typedef typename Types::StatementList StatementListT; typedef typename Types::StatementList StatementListT;
typedef typename Types::Block BlockT;
typedef typename v8::internal::ExpressionClassifier<Types> typedef typename v8::internal::ExpressionClassifier<Types>
ExpressionClassifier; ExpressionClassifier;
typedef typename Types::Block BlockT;
// All implementation-specific methods must be called through this. // All implementation-specific methods must be called through this.
Impl* impl() { return static_cast<Impl*>(this); } Impl* impl() { return static_cast<Impl*>(this); }
...@@ -1145,10 +1141,10 @@ class ParserBase { ...@@ -1145,10 +1141,10 @@ class ParserBase {
ObjectLiteralCheckerBase* checker, bool in_class, bool has_extends, ObjectLiteralCheckerBase* checker, bool in_class, bool has_extends,
bool* is_computed_name, bool* has_seen_constructor, IdentifierT* name, bool* is_computed_name, bool* has_seen_constructor, IdentifierT* name,
bool* ok); bool* ok);
typename Types::ExpressionList ParseArguments( ExpressionListT ParseArguments(Scanner::Location* first_spread_pos,
Scanner::Location* first_spread_pos, bool maybe_arrow, bool* ok); bool maybe_arrow, bool* ok);
typename Types::ExpressionList ParseArguments( ExpressionListT ParseArguments(Scanner::Location* first_spread_pos,
Scanner::Location* first_spread_pos, bool* ok) { bool* ok) {
return ParseArguments(first_spread_pos, false, ok); return ParseArguments(first_spread_pos, false, ok);
} }
...@@ -1828,7 +1824,7 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseArrayLiteral( ...@@ -1828,7 +1824,7 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseArrayLiteral(
// '[' Expression? (',' Expression?)* ']' // '[' Expression? (',' Expression?)* ']'
int pos = peek_position(); int pos = peek_position();
typename Types::ExpressionList values = impl()->NewExpressionList(4); ExpressionListT values = impl()->NewExpressionList(4);
int first_spread_index = -1; int first_spread_index = -1;
Expect(Token::LBRACK, CHECK_OK); Expect(Token::LBRACK, CHECK_OK);
while (peek() != Token::RBRACK) { while (peek() != Token::RBRACK) {
...@@ -2245,7 +2241,7 @@ ParserBase<Impl>::ParsePropertyDefinition(ObjectLiteralCheckerBase* checker, ...@@ -2245,7 +2241,7 @@ ParserBase<Impl>::ParsePropertyDefinition(ObjectLiteralCheckerBase* checker,
CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); CHECK_OK_CUSTOM(EmptyObjectLiteralProperty));
} }
typename Types::FunctionLiteral value = impl()->ParseFunctionLiteral( FunctionLiteralT value = impl()->ParseFunctionLiteral(
*name, scanner()->location(), kSkipFunctionNameCheck, *name, scanner()->location(), kSkipFunctionNameCheck,
is_get ? FunctionKind::kGetterFunction is_get ? FunctionKind::kGetterFunction
: FunctionKind::kSetterFunction, : FunctionKind::kSetterFunction,
...@@ -2280,7 +2276,7 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseObjectLiteral( ...@@ -2280,7 +2276,7 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseObjectLiteral(
// '{' (PropertyDefinition (',' PropertyDefinition)* ','? )? '}' // '{' (PropertyDefinition (',' PropertyDefinition)* ','? )? '}'
int pos = peek_position(); int pos = peek_position();
typename Types::PropertyList properties = impl()->NewPropertyList(4); PropertyListT properties = impl()->NewPropertyList(4);
int number_of_boilerplate_properties = 0; int number_of_boilerplate_properties = 0;
bool has_computed_names = false; bool has_computed_names = false;
ObjectLiteralChecker checker(this); ObjectLiteralChecker checker(this);
...@@ -2329,14 +2325,13 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseObjectLiteral( ...@@ -2329,14 +2325,13 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseObjectLiteral(
} }
template <typename Impl> template <typename Impl>
typename ParserBase<Impl>::Types::ExpressionList typename ParserBase<Impl>::ExpressionListT ParserBase<Impl>::ParseArguments(
ParserBase<Impl>::ParseArguments(Scanner::Location* first_spread_arg_loc, Scanner::Location* first_spread_arg_loc, bool maybe_arrow, bool* ok) {
bool maybe_arrow, bool* ok) {
// Arguments :: // Arguments ::
// '(' (AssignmentExpression)*[','] ')' // '(' (AssignmentExpression)*[','] ')'
Scanner::Location spread_arg = Scanner::Location::invalid(); Scanner::Location spread_arg = Scanner::Location::invalid();
typename Types::ExpressionList result = impl()->NewExpressionList(4); ExpressionListT result = impl()->NewExpressionList(4);
Expect(Token::LPAREN, CHECK_OK_CUSTOM(NullExpressionList)); Expect(Token::LPAREN, CHECK_OK_CUSTOM(NullExpressionList));
bool done = (peek() == Token::RPAREN); bool done = (peek() == Token::RPAREN);
bool was_unspread = false; bool was_unspread = false;
...@@ -2978,7 +2973,7 @@ ParserBase<Impl>::ParseLeftHandSideExpression(bool* ok) { ...@@ -2978,7 +2973,7 @@ ParserBase<Impl>::ParseLeftHandSideExpression(bool* ok) {
} }
} }
Scanner::Location spread_pos; Scanner::Location spread_pos;
typename Types::ExpressionList args; ExpressionListT args;
if (V8_UNLIKELY(is_async && impl()->IsIdentifier(result))) { if (V8_UNLIKELY(is_async && impl()->IsIdentifier(result))) {
ExpressionClassifier async_classifier(this); ExpressionClassifier async_classifier(this);
args = ParseArguments(&spread_pos, true, CHECK_OK); args = ParseArguments(&spread_pos, true, CHECK_OK);
...@@ -3111,8 +3106,7 @@ ParserBase<Impl>::ParseMemberWithNewPrefixesExpression(bool* is_async, ...@@ -3111,8 +3106,7 @@ ParserBase<Impl>::ParseMemberWithNewPrefixesExpression(bool* is_async,
if (peek() == Token::LPAREN) { if (peek() == Token::LPAREN) {
// NewExpression with arguments. // NewExpression with arguments.
Scanner::Location spread_pos; Scanner::Location spread_pos;
typename Types::ExpressionList args = ExpressionListT args = ParseArguments(&spread_pos, CHECK_OK);
ParseArguments(&spread_pos, CHECK_OK);
if (spread_pos.IsValid()) { if (spread_pos.IsValid()) {
args = impl()->PrepareSpreadArguments(args); args = impl()->PrepareSpreadArguments(args);
...@@ -3649,7 +3643,7 @@ ParserBase<Impl>::ParseArrowFunctionLiteral( ...@@ -3649,7 +3643,7 @@ ParserBase<Impl>::ParseArrowFunctionLiteral(
return impl()->EmptyExpression(); return impl()->EmptyExpression();
} }
typename Types::StatementList body = impl()->NullStatementList(); StatementListT body = impl()->NullStatementList();
int num_parameters = formal_parameters.scope->num_parameters(); int num_parameters = formal_parameters.scope->num_parameters();
int materialized_literal_count = -1; int materialized_literal_count = -1;
int expected_property_count = -1; int expected_property_count = -1;
......
...@@ -144,19 +144,13 @@ struct ParserTypes<Parser> { ...@@ -144,19 +144,13 @@ struct ParserTypes<Parser> {
typedef Variable GeneratorVariable; typedef Variable GeneratorVariable;
typedef v8::internal::AstProperties AstProperties;
// Return types for traversing functions. // Return types for traversing functions.
typedef const AstRawString* Identifier; typedef const AstRawString* Identifier;
typedef v8::internal::Expression* Expression; typedef v8::internal::Expression* Expression;
typedef Yield* YieldExpression;
typedef v8::internal::FunctionLiteral* FunctionLiteral; typedef v8::internal::FunctionLiteral* FunctionLiteral;
typedef v8::internal::ClassLiteral* ClassLiteral;
typedef v8::internal::Literal* Literal;
typedef ObjectLiteral::Property* ObjectLiteralProperty; typedef ObjectLiteral::Property* ObjectLiteralProperty;
typedef ZoneList<v8::internal::Expression*>* ExpressionList; typedef ZoneList<v8::internal::Expression*>* ExpressionList;
typedef ZoneList<ObjectLiteral::Property*>* PropertyList; typedef ZoneList<ObjectLiteral::Property*>* PropertyList;
typedef ParserFormalParameters::Parameter FormalParameter;
typedef ParserFormalParameters FormalParameters; typedef ParserFormalParameters FormalParameters;
typedef ZoneList<v8::internal::Statement*>* StatementList; typedef ZoneList<v8::internal::Statement*>* StatementList;
typedef v8::internal::Block* Block; typedef v8::internal::Block* Block;
......
...@@ -599,19 +599,13 @@ struct ParserTypes<PreParser> { ...@@ -599,19 +599,13 @@ struct ParserTypes<PreParser> {
// PreParser doesn't need to store generator variables. // PreParser doesn't need to store generator variables.
typedef void GeneratorVariable; typedef void GeneratorVariable;
typedef int AstProperties;
// Return types for traversing functions. // Return types for traversing functions.
typedef PreParserIdentifier Identifier; typedef PreParserIdentifier Identifier;
typedef PreParserExpression Expression; typedef PreParserExpression Expression;
typedef PreParserExpression YieldExpression;
typedef PreParserExpression FunctionLiteral; typedef PreParserExpression FunctionLiteral;
typedef PreParserExpression ClassLiteral;
typedef PreParserExpression Literal;
typedef PreParserExpression ObjectLiteralProperty; typedef PreParserExpression ObjectLiteralProperty;
typedef PreParserExpressionList ExpressionList; typedef PreParserExpressionList ExpressionList;
typedef PreParserExpressionList PropertyList; typedef PreParserExpressionList PropertyList;
typedef PreParserIdentifier FormalParameter;
typedef PreParserFormalParameters FormalParameters; typedef PreParserFormalParameters FormalParameters;
typedef PreParserStatementList StatementList; typedef PreParserStatementList StatementList;
typedef PreParserStatement Block; typedef PreParserStatement Block;
......
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