Commit 58cfe4d6 authored by nikolaos's avatar nikolaos Committed by Commit bot

[parser] Clean up type definitions

This patch:

1. Removes the unecessary inheritance of ParserBaseTraits<Impl>
   in ParserBase<Impl>.
2. Flattens ParserBaseTraits<Impl> and renames it to
   ParserTypes<Impl>.  The Traits parameter/member is renamed to
   Types.
3. Removes unecessary v8::internal:: qualifications from parser
   types.

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

Review-Url: https://codereview.chromium.org/2279773002
Cr-Commit-Position: refs/heads/master@{#38927}
parent b143cb09
......@@ -26,7 +26,7 @@ class DuplicateFinder;
T(TailCallExpressionProduction, 8) \
T(AsyncArrowFormalParametersProduction, 9)
template <typename Traits>
template <typename Types>
class ExpressionClassifier {
public:
enum ErrorKind : unsigned {
......@@ -72,7 +72,7 @@ class ExpressionClassifier {
NonSimpleParameter = 1 << 0
};
explicit ExpressionClassifier(const typename Traits::Type::Base* base,
explicit ExpressionClassifier(const typename Types::Base* base,
DuplicateFinder* duplicate_finder = nullptr)
: zone_(base->impl()->zone()),
non_patterns_to_rewrite_(base->impl()->GetNonPatternList()),
......@@ -418,7 +418,7 @@ class ExpressionClassifier {
}
Zone* zone_;
ZoneList<typename Traits::Type::Expression>* non_patterns_to_rewrite_;
ZoneList<typename Types::Expression>* non_patterns_to_rewrite_;
ZoneList<Error>* reported_errors_;
DuplicateFinder* duplicate_finder_;
// The uint16_t for non_pattern_begin_ will not be enough in the case,
......
......@@ -140,88 +140,80 @@ struct FormalParametersBase {
// following the Curiously Recurring Template Pattern (CRTP).
// The structure of the parser objects is roughly the following:
//
// // Common denominator, needed to avoid cyclic dependency.
// // Instances of this template will end up with very minimal
// // definitions, ideally containing just typedefs.
// // A structure template containing type definitions, needed to
// // avoid a cyclic dependency.
// template <typename Impl>
// class ParserBaseTraits;
// struct ParserTypes;
//
// // The parser base object, which should just implement pure
// // parser behavior. The Impl parameter is the actual derived
// // class (according to CRTP), which implements impure parser
// // behavior.
// template <typename Impl>
// class ParserBase : public ParserBaseTraits<Impl> { ... };
// class ParserBase { ... };
//
// // And then, for each parser variant (e.g., parser, preparser, etc):
// class Parser;
//
// template <>
// class ParserBaseTraits<Parser> { ... };
// class ParserTypes<Parser> { ... };
//
// class Parser : public ParserBase<Parser> { ... };
//
// The traits class template encapsulates the differences between
// parser/pre-parser implementations. In particular:
// - Return types: For example, Parser functions return Expression* and
// PreParser functions return PreParserExpression.
// - Creating parse tree nodes: Parser generates an AST during the recursive
// descent. PreParser doesn't create a tree. Instead, it passes around minimal
// data objects (PreParserExpression, PreParserIdentifier etc.) which contain
// just enough data for the upper layer functions. PreParserFactory is
// responsible for creating these dummy objects. It provides a similar kind of
// interface as AstNodeFactory, so ParserBase doesn't need to care which one is
// used.
// The traits are expected to contain the following typedefs:
// The parser base object implements pure parsing, according to the
// language grammar. Different parser implementations may exhibit
// different parser-driven behavior that is not considered as pure
// parsing, e.g., early error detection and reporting, AST generation, etc.
// The ParserTypes structure encapsulates the differences in the
// types used in parsing methods. E.g., Parser methods use Expression*
// and PreParser methods use PreParserExpression. For any given parser
// implementation class Impl, it is expected to contain the following typedefs:
//
// template <>
// class ParserBaseTraits<Impl> {
// // In particular...
// struct Type {
// // Synonyms for ParserBase<Impl> and Impl, respectively.
// typedef Base;
// typedef Impl;
// typedef GeneratorVariable;
// typedef AstProperties;
// typedef ExpressionClassifier;
// // Return types for traversing functions.
// typedef Identifier;
// typedef Expression;
// typedef YieldExpression;
// typedef FunctionLiteral;
// typedef ClassLiteral;
// typedef Literal;
// typedef ObjectLiteralProperty;
// typedef ExpressionList;
// typedef PropertyList;
// typedef FormalParameter;
// typedef FormalParameters;
// typedef StatementList;
// // For constructing objects returned by the traversing functions.
// typedef Factory;
// };
// // ...
// struct ParserTypes<Impl> {
// // Synonyms for ParserBase<Impl> and Impl, respectively.
// typedef Base;
// typedef Impl;
// // TODO(nikolaos): these three will probably go away, as they are
// // not related to pure parsing.
// typedef GeneratorVariable;
// typedef AstProperties;
// typedef ExpressionClassifier;
// // Return types for traversing functions.
// typedef Identifier;
// typedef Expression;
// typedef YieldExpression;
// typedef FunctionLiteral;
// typedef ClassLiteral;
// typedef Literal;
// typedef ObjectLiteralProperty;
// typedef ExpressionList;
// typedef PropertyList;
// typedef FormalParameter;
// typedef FormalParameters;
// typedef StatementList;
// // For constructing objects returned by the traversing functions.
// typedef Factory;
// };
template <typename Impl>
class ParserBaseTraits;
struct ParserTypes;
template <typename Impl>
class ParserBase : public ParserBaseTraits<Impl> {
class ParserBase {
public:
// Shorten type names defined by Traits.
typedef ParserBaseTraits<Impl> Traits;
typedef typename Traits::Type::Expression ExpressionT;
typedef typename Traits::Type::Identifier IdentifierT;
typedef typename Traits::Type::FormalParameter FormalParameterT;
typedef typename Traits::Type::FormalParameters FormalParametersT;
typedef typename Traits::Type::FunctionLiteral FunctionLiteralT;
typedef typename Traits::Type::Literal LiteralT;
typedef typename Traits::Type::ObjectLiteralProperty ObjectLiteralPropertyT;
typedef typename Traits::Type::StatementList StatementListT;
typedef typename Traits::Type::ExpressionClassifier ExpressionClassifier;
// Shorten type names defined by ParserTypes<Impl>.
typedef ParserTypes<Impl> Types;
typedef typename Types::Expression ExpressionT;
typedef typename Types::Identifier IdentifierT;
typedef typename Types::FormalParameter FormalParameterT;
typedef typename Types::FormalParameters FormalParametersT;
typedef typename Types::FunctionLiteral FunctionLiteralT;
typedef typename Types::Literal LiteralT;
typedef typename Types::ObjectLiteralProperty ObjectLiteralPropertyT;
typedef typename Types::StatementList StatementListT;
typedef typename Types::ExpressionClassifier ExpressionClassifier;
// All implementation-specific methods must be called through this.
Impl* impl() { return static_cast<Impl*>(this); }
......@@ -447,13 +439,12 @@ class ParserBase : public ParserBaseTraits<Impl> {
FunctionState* outer() const { return outer_function_state_; }
void set_generator_object_variable(
typename Traits::Type::GeneratorVariable* variable) {
typename Types::GeneratorVariable* variable) {
DCHECK(variable != NULL);
DCHECK(is_resumable());
generator_object_variable_ = variable;
}
typename Traits::Type::GeneratorVariable* generator_object_variable()
const {
typename Types::GeneratorVariable* generator_object_variable() const {
return generator_object_variable_;
}
......@@ -876,7 +867,7 @@ class ParserBase : public ParserBaseTraits<Impl> {
return Token::Precedence(token);
}
typename Traits::Type::Factory* factory() { return &ast_node_factory_; }
typename Types::Factory* factory() { return &ast_node_factory_; }
DeclarationScope* GetReceiverScope() const {
return scope()->GetReceiverScope();
......@@ -1091,10 +1082,10 @@ class ParserBase : public ParserBaseTraits<Impl> {
ObjectLiteralCheckerBase* checker, bool in_class, bool has_extends,
MethodKind kind, bool* is_computed_name, bool* has_seen_constructor,
ExpressionClassifier* classifier, IdentifierT* name, bool* ok);
typename Traits::Type::ExpressionList ParseArguments(
typename Types::ExpressionList ParseArguments(
Scanner::Location* first_spread_pos, bool maybe_arrow,
ExpressionClassifier* classifier, bool* ok);
typename Traits::Type::ExpressionList ParseArguments(
typename Types::ExpressionList ParseArguments(
Scanner::Location* first_spread_pos, ExpressionClassifier* classifier,
bool* ok) {
return ParseArguments(first_spread_pos, false, classifier, ok);
......@@ -1260,7 +1251,7 @@ class ParserBase : public ParserBaseTraits<Impl> {
v8::Extension* extension_;
FuncNameInferrer* fni_;
AstValueFactory* ast_value_factory_; // Not owned.
typename Traits::Type::Factory ast_node_factory_;
typename Types::Factory ast_node_factory_;
ParserRecorder* log_;
Mode mode_;
bool parsing_module_;
......@@ -1802,7 +1793,7 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseArrayLiteral(
// '[' Expression? (',' Expression?)* ']'
int pos = peek_position();
typename Traits::Type::ExpressionList values = impl()->NewExpressionList(4);
typename Types::ExpressionList values = impl()->NewExpressionList(4);
int first_spread_index = -1;
Expect(Token::LBRACK, CHECK_OK);
while (peek() != Token::RBRACK) {
......@@ -2118,7 +2109,7 @@ ParserBase<Impl>::ParsePropertyDefinition(
CHECK_OK_CUSTOM(EmptyObjectLiteralProperty));
}
typename Traits::Type::FunctionLiteral value = impl()->ParseFunctionLiteral(
FunctionLiteralT value = impl()->ParseFunctionLiteral(
*name, scanner()->location(), kSkipFunctionNameCheck,
is_get ? FunctionKind::kGetterFunction : FunctionKind::kSetterFunction,
kNoSourcePosition, FunctionLiteral::kAccessorOrMethod, language_mode(),
......@@ -2151,7 +2142,7 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseObjectLiteral(
// '{' (PropertyDefinition (',' PropertyDefinition)* ','? )? '}'
int pos = peek_position();
typename Traits::Type::PropertyList properties = impl()->NewPropertyList(4);
typename Types::PropertyList properties = impl()->NewPropertyList(4);
int number_of_boilerplate_properties = 0;
bool has_computed_names = false;
ObjectLiteralChecker checker(this);
......@@ -2200,7 +2191,7 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseObjectLiteral(
}
template <typename Impl>
typename ParserBase<Impl>::Traits::Type::ExpressionList
typename ParserBase<Impl>::Types::ExpressionList
ParserBase<Impl>::ParseArguments(Scanner::Location* first_spread_arg_loc,
bool maybe_arrow,
ExpressionClassifier* classifier, bool* ok) {
......@@ -2208,7 +2199,7 @@ ParserBase<Impl>::ParseArguments(Scanner::Location* first_spread_arg_loc,
// '(' (AssignmentExpression)*[','] ')'
Scanner::Location spread_arg = Scanner::Location::invalid();
typename Traits::Type::ExpressionList result = impl()->NewExpressionList(4);
typename Types::ExpressionList result = impl()->NewExpressionList(4);
Expect(Token::LPAREN, CHECK_OK_CUSTOM(NullExpressionList));
bool done = (peek() == Token::RPAREN);
bool was_unspread = false;
......@@ -2539,8 +2530,8 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseYieldExpression(
expression = impl()->BuildIteratorResult(expression, false);
// Hackily disambiguate o from o.next and o [Symbol.iterator]().
// TODO(verwaest): Come up with a better solution.
typename Traits::Type::YieldExpression yield = factory()->NewYield(
generator_object, expression, pos, Yield::kOnExceptionThrow);
ExpressionT yield = factory()->NewYield(generator_object, expression, pos,
Yield::kOnExceptionThrow);
return yield;
}
......@@ -2738,7 +2729,7 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseUnaryExpression(
return impl()->EmptyExpression();
}
// Allow Traits do rewrite the expression.
// Allow the parser's implementation to rewrite the expression.
return impl()->BuildUnaryExpression(expression, op, pos);
} else if (Token::IsCountOp(op)) {
BindingPatternUnexpectedToken(classifier);
......@@ -2861,7 +2852,7 @@ ParserBase<Impl>::ParseLeftHandSideExpression(ExpressionClassifier* classifier,
}
}
Scanner::Location spread_pos;
typename Traits::Type::ExpressionList args;
typename Types::ExpressionList args;
if (V8_UNLIKELY(is_async && impl()->IsIdentifier(result))) {
ExpressionClassifier async_classifier(this);
args = ParseArguments(&spread_pos, true, &async_classifier, CHECK_OK);
......@@ -2996,7 +2987,7 @@ ParserBase<Impl>::ParseMemberWithNewPrefixesExpression(
if (peek() == Token::LPAREN) {
// NewExpression with arguments.
Scanner::Location spread_pos;
typename Traits::Type::ExpressionList args =
typename Types::ExpressionList args =
ParseArguments(&spread_pos, classifier, CHECK_OK);
if (spread_pos.IsValid()) {
......@@ -3393,7 +3384,7 @@ ParserBase<Impl>::ParseArrowFunctionLiteral(
return impl()->EmptyExpression();
}
typename Traits::Type::StatementList body;
typename Types::StatementList body;
int num_parameters = formal_parameters.scope->num_parameters();
int materialized_literal_count = -1;
int expected_property_count = -1;
......
......@@ -3866,7 +3866,7 @@ void Parser::ParseArrowFunctionFormalParameterList(
return;
}
Type::ExpressionClassifier classifier(this);
ExpressionClassifier classifier(this);
if (!parameters->is_simple) {
classifier.RecordNonSimpleParameter();
}
......@@ -5260,11 +5260,9 @@ uint32_t Parser::ComputeTemplateLiteralHash(const TemplateLiteral* lit) {
return running_hash;
}
ZoneList<v8::internal::Expression*>* Parser::PrepareSpreadArguments(
ZoneList<v8::internal::Expression*>* list) {
ZoneList<v8::internal::Expression*>* args =
new (zone()) ZoneList<v8::internal::Expression*>(1, zone());
ZoneList<Expression*>* Parser::PrepareSpreadArguments(
ZoneList<Expression*>* list) {
ZoneList<Expression*>* args = new (zone()) ZoneList<Expression*>(1, zone());
if (list->length() == 1) {
// Spread-call with single spread argument produces an InternalArray
// containing the values from the array.
......@@ -5291,8 +5289,8 @@ ZoneList<v8::internal::Expression*>* Parser::PrepareSpreadArguments(
int n = list->length();
while (i < n) {
if (!list->at(i)->IsSpread()) {
ZoneList<v8::internal::Expression*>* unspread =
new (zone()) ZoneList<v8::internal::Expression*>(1, zone());
ZoneList<Expression*>* unspread =
new (zone()) ZoneList<Expression*>(1, zone());
// Push array of unspread parameters
while (i < n && !list->at(i)->IsSpread()) {
......@@ -5307,15 +5305,15 @@ ZoneList<v8::internal::Expression*>* Parser::PrepareSpreadArguments(
}
// Push eagerly spread argument
ZoneList<v8::internal::Expression*>* spread_list =
new (zone()) ZoneList<v8::internal::Expression*>(1, zone());
ZoneList<Expression*>* spread_list =
new (zone()) ZoneList<Expression*>(1, zone());
spread_list->Add(list->at(i++)->AsSpread()->expression(), zone());
args->Add(factory()->NewCallRuntime(Context::SPREAD_ITERABLE_INDEX,
spread_list, kNoSourcePosition),
zone());
}
list = new (zone()) ZoneList<v8::internal::Expression*>(1, zone());
list = new (zone()) ZoneList<Expression*>(1, zone());
list->Add(factory()->NewCallRuntime(Context::SPREAD_ARGUMENTS_INDEX, args,
kNoSourcePosition),
zone());
......@@ -5324,10 +5322,8 @@ ZoneList<v8::internal::Expression*>* Parser::PrepareSpreadArguments(
UNREACHABLE();
}
Expression* Parser::SpreadCall(Expression* function,
ZoneList<v8::internal::Expression*>* args,
int pos) {
ZoneList<Expression*>* args, int pos) {
if (function->IsSuperCallReference()) {
// Super calls
// $super_constructor = %_GetSuperConstructor(<this-function>)
......@@ -5369,10 +5365,8 @@ Expression* Parser::SpreadCall(Expression* function,
}
}
Expression* Parser::SpreadCallNew(Expression* function,
ZoneList<v8::internal::Expression*>* args,
int pos) {
ZoneList<Expression*>* args, int pos) {
args->InsertAt(0, function, zone());
return factory()->NewCallRuntime(Context::REFLECT_CONSTRUCT_INDEX, args, pos);
......
......@@ -138,36 +138,33 @@ struct ParserFormalParameters : FormalParametersBase {
};
template <>
class ParserBaseTraits<Parser> {
public:
struct Type {
typedef ParserBase<Parser> Base;
typedef Parser Impl;
typedef Variable GeneratorVariable;
typedef v8::internal::AstProperties AstProperties;
typedef v8::internal::ExpressionClassifier<ParserBaseTraits<Parser>>
ExpressionClassifier;
// Return types for traversing functions.
typedef const AstRawString* Identifier;
typedef v8::internal::Expression* Expression;
typedef Yield* YieldExpression;
typedef v8::internal::FunctionLiteral* FunctionLiteral;
typedef v8::internal::ClassLiteral* ClassLiteral;
typedef v8::internal::Literal* Literal;
typedef ObjectLiteral::Property* ObjectLiteralProperty;
typedef ZoneList<v8::internal::Expression*>* ExpressionList;
typedef ZoneList<ObjectLiteral::Property*>* PropertyList;
typedef ParserFormalParameters::Parameter FormalParameter;
typedef ParserFormalParameters FormalParameters;
typedef ZoneList<v8::internal::Statement*>* StatementList;
// For constructing objects returned by the traversing functions.
typedef AstNodeFactory Factory;
};
struct ParserTypes<Parser> {
typedef ParserBase<Parser> Base;
typedef Parser Impl;
typedef Variable GeneratorVariable;
typedef v8::internal::AstProperties AstProperties;
typedef v8::internal::ExpressionClassifier<ParserTypes<Parser>>
ExpressionClassifier;
// Return types for traversing functions.
typedef const AstRawString* Identifier;
typedef v8::internal::Expression* Expression;
typedef Yield* YieldExpression;
typedef v8::internal::FunctionLiteral* FunctionLiteral;
typedef v8::internal::ClassLiteral* ClassLiteral;
typedef v8::internal::Literal* Literal;
typedef ObjectLiteral::Property* ObjectLiteralProperty;
typedef ZoneList<v8::internal::Expression*>* ExpressionList;
typedef ZoneList<ObjectLiteral::Property*>* PropertyList;
typedef ParserFormalParameters::Parameter FormalParameter;
typedef ParserFormalParameters FormalParameters;
typedef ZoneList<v8::internal::Statement*>* StatementList;
// For constructing objects returned by the traversing functions.
typedef AstNodeFactory Factory;
};
class Parser : public ParserBase<Parser> {
......@@ -197,7 +194,7 @@ class Parser : public ParserBase<Parser> {
private:
friend class ParserBase<Parser>;
friend class v8::internal::ExpressionClassifier<ParserBaseTraits<Parser>>;
friend class v8::internal::ExpressionClassifier<ParserTypes<Parser>>;
// Runtime encoding of different completion modes.
enum CompletionKind {
......@@ -480,7 +477,7 @@ class Parser : public ParserBase<Parser> {
void DesugarAsyncFunctionBody(const AstRawString* function_name, Scope* scope,
ZoneList<Statement*>* body,
Type::ExpressionClassifier* classifier,
ExpressionClassifier* classifier,
FunctionKind kind, FunctionBodyType type,
bool accept_IN, int pos, bool* ok);
......@@ -623,12 +620,11 @@ class Parser : public ParserBase<Parser> {
pos, ok);
}
ZoneList<v8::internal::Expression*>* PrepareSpreadArguments(
ZoneList<v8::internal::Expression*>* list);
Expression* SpreadCall(Expression* function,
ZoneList<v8::internal::Expression*>* args, int pos);
Expression* SpreadCallNew(Expression* function,
ZoneList<v8::internal::Expression*>* args, int pos);
ZoneList<Expression*>* PrepareSpreadArguments(ZoneList<Expression*>* list);
Expression* SpreadCall(Expression* function, ZoneList<Expression*>* args,
int pos);
Expression* SpreadCallNew(Expression* function, ZoneList<Expression*>* args,
int pos);
void SetLanguageMode(Scope* scope, LanguageMode mode);
void RaiseLanguageMode(LanguageMode mode);
......@@ -943,22 +939,20 @@ class Parser : public ParserBase<Parser> {
return factory()->NewStringLiteral(symbol, pos);
}
V8_INLINE ZoneList<v8::internal::Expression*>* NewExpressionList(
int size) const {
return new (zone()) ZoneList<v8::internal::Expression*>(size, zone());
V8_INLINE ZoneList<Expression*>* NewExpressionList(int size) const {
return new (zone()) ZoneList<Expression*>(size, zone());
}
V8_INLINE ZoneList<ObjectLiteral::Property*>* NewPropertyList(
int size) const {
return new (zone()) ZoneList<ObjectLiteral::Property*>(size, zone());
}
V8_INLINE ZoneList<v8::internal::Statement*>* NewStatementList(
int size) const {
return new (zone()) ZoneList<v8::internal::Statement*>(size, zone());
V8_INLINE ZoneList<Statement*>* NewStatementList(int size) const {
return new (zone()) ZoneList<Statement*>(size, zone());
}
V8_INLINE void AddParameterInitializationBlock(
const ParserFormalParameters& parameters,
ZoneList<v8::internal::Statement*>* body, bool is_async, bool* ok) {
const ParserFormalParameters& parameters, ZoneList<Statement*>* body,
bool is_async, bool* ok) {
if (parameters.is_simple) return;
auto* init_block = BuildParameterInitializationBlock(parameters, ok);
if (!*ok) return;
......@@ -984,7 +978,7 @@ class Parser : public ParserBase<Parser> {
V8_INLINE void DeclareFormalParameter(
DeclarationScope* scope,
const ParserFormalParameters::Parameter& parameter,
Type::ExpressionClassifier* classifier) {
ExpressionClassifier* classifier) {
bool is_duplicate = false;
bool is_simple = classifier->is_simple_parameter_list();
auto name = is_simple || parameter.is_rest
......@@ -1029,7 +1023,7 @@ class Parser : public ParserBase<Parser> {
void SetFunctionNameFromIdentifierRef(Expression* value,
Expression* identifier);
V8_INLINE ZoneList<typename Type::ExpressionClassifier::Error>*
V8_INLINE ZoneList<typename ExpressionClassifier::Error>*
GetReportedErrorList() const {
return function_state_->GetReportedErrorList();
}
......
......@@ -18,6 +18,14 @@
namespace v8 {
namespace internal {
// Whereas the Parser generates AST during the recursive descent,
// the PreParser doesn't create a tree. Instead, it passes around minimal
// data objects (PreParserExpression, PreParserIdentifier etc.) which contain
// just enough data for the upper layer functions. PreParserFactory is
// responsible for creating these dummy objects. It provides a similar kind of
// interface as AstNodeFactory, so ParserBase doesn't need to care which one is
// used.
class PreParserIdentifier {
public:
PreParserIdentifier() : type_(kUnknownIdentifier) {}
......@@ -585,37 +593,34 @@ struct PreParserFormalParameters : FormalParametersBase {
class PreParser;
template <>
class ParserBaseTraits<PreParser> {
public:
struct Type {
typedef ParserBase<PreParser> Base;
typedef PreParser Impl;
// PreParser doesn't need to store generator variables.
typedef void GeneratorVariable;
typedef int AstProperties;
typedef v8::internal::ExpressionClassifier<ParserBaseTraits<PreParser>>
ExpressionClassifier;
// Return types for traversing functions.
typedef PreParserIdentifier Identifier;
typedef PreParserExpression Expression;
typedef PreParserExpression YieldExpression;
typedef PreParserExpression FunctionLiteral;
typedef PreParserExpression ClassLiteral;
typedef PreParserExpression Literal;
typedef PreParserExpression ObjectLiteralProperty;
typedef PreParserExpressionList ExpressionList;
typedef PreParserExpressionList PropertyList;
typedef PreParserIdentifier FormalParameter;
typedef PreParserFormalParameters FormalParameters;
typedef PreParserStatementList StatementList;
// For constructing objects returned by the traversing functions.
typedef PreParserFactory Factory;
};
struct ParserTypes<PreParser> {
typedef ParserBase<PreParser> Base;
typedef PreParser Impl;
// PreParser doesn't need to store generator variables.
typedef void GeneratorVariable;
typedef int AstProperties;
typedef v8::internal::ExpressionClassifier<ParserTypes<PreParser>>
ExpressionClassifier;
// Return types for traversing functions.
typedef PreParserIdentifier Identifier;
typedef PreParserExpression Expression;
typedef PreParserExpression YieldExpression;
typedef PreParserExpression FunctionLiteral;
typedef PreParserExpression ClassLiteral;
typedef PreParserExpression Literal;
typedef PreParserExpression ObjectLiteralProperty;
typedef PreParserExpressionList ExpressionList;
typedef PreParserExpressionList PropertyList;
typedef PreParserIdentifier FormalParameter;
typedef PreParserFormalParameters FormalParameters;
typedef PreParserStatementList StatementList;
// For constructing objects returned by the traversing functions.
typedef PreParserFactory Factory;
};
......@@ -633,7 +638,7 @@ class ParserBaseTraits<PreParser> {
// it is used) are generally omitted.
class PreParser : public ParserBase<PreParser> {
friend class ParserBase<PreParser>;
friend class v8::internal::ExpressionClassifier<ParserBaseTraits<PreParser>>;
friend class v8::internal::ExpressionClassifier<ParserTypes<PreParser>>;
public:
typedef PreParserIdentifier Identifier;
......@@ -836,8 +841,7 @@ class PreParser : public ParserBase<PreParser> {
int pos) {
return PreParserExpression::Default();
}
V8_INLINE void RewriteNonPattern(Type::ExpressionClassifier* classifier,
bool* ok) {
V8_INLINE void RewriteNonPattern(ExpressionClassifier* classifier, bool* ok) {
ValidateExpression(classifier, ok);
}
......@@ -1092,9 +1096,9 @@ class PreParser : public ParserBase<PreParser> {
++parameters->arity;
}
V8_INLINE void DeclareFormalParameter(
DeclarationScope* scope, PreParserIdentifier parameter,
Type::ExpressionClassifier* classifier) {
V8_INLINE void DeclareFormalParameter(DeclarationScope* scope,
PreParserIdentifier parameter,
ExpressionClassifier* classifier) {
if (!classifier->is_simple_parameter_list()) {
scope->SetHasNonSimpleParameters();
}
......@@ -1135,7 +1139,7 @@ class PreParser : public ParserBase<PreParser> {
V8_INLINE void SetFunctionNameFromIdentifierRef(
PreParserExpression value, PreParserExpression identifier) {}
V8_INLINE ZoneList<typename Type::ExpressionClassifier::Error>*
V8_INLINE ZoneList<typename ExpressionClassifier::Error>*
GetReportedErrorList() const {
return function_state_->GetReportedErrorList();
}
......
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