summaryrefslogtreecommitdiff
path: root/deps/v8/src/parsing/parser.h
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/src/parsing/parser.h')
-rw-r--r--deps/v8/src/parsing/parser.h86
1 files changed, 52 insertions, 34 deletions
diff --git a/deps/v8/src/parsing/parser.h b/deps/v8/src/parsing/parser.h
index 7d50221334..d4fb62f02c 100644
--- a/deps/v8/src/parsing/parser.h
+++ b/deps/v8/src/parsing/parser.h
@@ -335,6 +335,9 @@ class ParserTraits {
typedef v8::internal::AstProperties AstProperties;
+ typedef v8::internal::ExpressionClassifier<ParserTraits>
+ ExpressionClassifier;
+
// Return types for traversing functions.
typedef const AstRawString* Identifier;
typedef v8::internal::Expression* Expression;
@@ -461,6 +464,8 @@ class ParserTraits {
MessageTemplate::Template message,
const AstRawString* arg, int pos);
+ Statement* FinalizeForOfStatement(ForOfStatement* loop, int pos);
+
// Reporting errors.
void ReportMessageAt(Scanner::Location source_location,
MessageTemplate::Template message,
@@ -513,8 +518,8 @@ class ParserTraits {
int pos);
Expression* NewTargetExpression(Scope* scope, AstNodeFactory* factory,
int pos);
- Expression* DefaultConstructor(bool call_super, Scope* scope, int pos,
- int end_pos, LanguageMode language_mode);
+ Expression* FunctionSentExpression(Scope* scope, AstNodeFactory* factory,
+ int pos);
Literal* ExpressionFromLiteral(Token::Value token, int pos, Scanner* scanner,
AstNodeFactory* factory);
Expression* ExpressionFromIdentifier(const AstRawString* name,
@@ -547,7 +552,7 @@ class ParserTraits {
int initializer_end_position, bool is_rest);
V8_INLINE void DeclareFormalParameter(
Scope* scope, const ParserFormalParameters::Parameter& parameter,
- ExpressionClassifier* classifier);
+ Type::ExpressionClassifier* classifier);
void ParseArrowFunctionFormalParameters(ParserFormalParameters* parameters,
Expression* params,
const Scanner::Location& params_loc,
@@ -567,7 +572,6 @@ class ParserTraits {
const AstRawString* name, Scanner::Location function_name_location,
FunctionNameValidity function_name_validity, FunctionKind kind,
int function_token_position, FunctionLiteral::FunctionType type,
- FunctionLiteral::ArityRestriction arity_restriction,
LanguageMode language_mode, bool* ok);
V8_INLINE void SkipLazyFunctionBody(
int* materialized_literal_count, int* expected_property_count, bool* ok,
@@ -642,6 +646,7 @@ class ParserTraits {
V8_INLINE void QueueDestructuringAssignmentForRewriting(
Expression* assignment);
+ V8_INLINE void QueueNonPatternForRewriting(Expression* expr);
void SetFunctionNameFromPropertyName(ObjectLiteralProperty* property,
const AstRawString* name);
@@ -650,17 +655,28 @@ class ParserTraits {
Expression* identifier);
// Rewrite expressions that are not used as patterns
- V8_INLINE Expression* RewriteNonPattern(
- Expression* expr, const ExpressionClassifier* classifier, bool* ok);
- V8_INLINE ZoneList<Expression*>* RewriteNonPatternArguments(
- ZoneList<Expression*>* args, const ExpressionClassifier* classifier,
- bool* ok);
- V8_INLINE ObjectLiteralProperty* RewriteNonPatternObjectLiteralProperty(
- ObjectLiteralProperty* property, const ExpressionClassifier* classifier,
- bool* ok);
+ V8_INLINE void RewriteNonPattern(Type::ExpressionClassifier* classifier,
+ bool* ok);
+
+ V8_INLINE Zone* zone() const;
+
+ V8_INLINE ZoneList<Expression*>* GetNonPatternList() const;
+
+ Expression* RewriteYieldStar(
+ Expression* generator, Expression* expression, int pos);
+
+ Expression* RewriteInstanceof(Expression* lhs, Expression* rhs, int pos);
private:
Parser* parser_;
+
+ void BuildIteratorClose(
+ ZoneList<Statement*>* statements, Variable* iterator,
+ Expression* input, Variable* output);
+ void BuildIteratorCloseForCompletion(
+ ZoneList<Statement*>* statements, Variable* iterator,
+ Variable* body_threw);
+ Statement* CheckCallable(Variable* var, Expression* error);
};
@@ -744,6 +760,9 @@ class Parser : public ParserBase<ParserTraits> {
bool* ok);
Statement* ParseFunctionDeclaration(ZoneList<const AstRawString*>* names,
bool* ok);
+ Statement* ParseFunctionDeclaration(int pos, bool is_generator,
+ ZoneList<const AstRawString*>* names,
+ bool* ok);
Statement* ParseClassDeclaration(ZoneList<const AstRawString*>* names,
bool* ok);
Statement* ParseNativeDeclaration(bool* ok);
@@ -754,6 +773,7 @@ class Parser : public ParserBase<ParserTraits> {
ZoneList<const AstRawString*>* names,
bool* ok);
DoExpression* ParseDoExpression(bool* ok);
+ Expression* ParseYieldStarExpression(bool* ok);
struct DeclarationDescriptor {
enum Kind { NORMAL, PARAMETER };
@@ -761,7 +781,6 @@ class Parser : public ParserBase<ParserTraits> {
Scope* scope;
Scope* hoist_scope;
VariableMode mode;
- bool needs_init;
int declaration_pos;
int initialization_pos;
Kind declaration_kind;
@@ -801,8 +820,9 @@ class Parser : public ParserBase<ParserTraits> {
const DeclarationParsingResult::Declaration* declaration,
ZoneList<const AstRawString*>* names, bool* ok);
- static void RewriteDestructuringAssignment(
- Parser* parser, RewritableAssignmentExpression* expr, Scope* Scope);
+ static void RewriteDestructuringAssignment(Parser* parser,
+ RewritableExpression* expr,
+ Scope* Scope);
static Expression* RewriteDestructuringAssignment(Parser* parser,
Assignment* assignment,
@@ -872,10 +892,10 @@ class Parser : public ParserBase<ParserTraits> {
bool* ok_;
};
-
- void ParseVariableDeclarations(VariableDeclarationContext var_context,
- DeclarationParsingResult* parsing_result,
- bool* ok);
+ Block* ParseVariableDeclarations(VariableDeclarationContext var_context,
+ DeclarationParsingResult* parsing_result,
+ ZoneList<const AstRawString*>* names,
+ bool* ok);
Statement* ParseExpressionOrLabelledStatement(
ZoneList<const AstRawString*>* labels, bool* ok);
IfStatement* ParseIfStatement(ZoneList<const AstRawString*>* labels,
@@ -896,6 +916,8 @@ class Parser : public ParserBase<ParserTraits> {
Statement* ParseForStatement(ZoneList<const AstRawString*>* labels, bool* ok);
Statement* ParseThrowStatement(bool* ok);
Expression* MakeCatchContext(Handle<String> id, VariableProxy* value);
+ class DontCollectExpressionsInTailPositionScope;
+ class CollectExpressionsInTailPositionToListScope;
TryStatement* ParseTryStatement(bool* ok);
DebuggerStatement* ParseDebuggerStatement(bool* ok);
@@ -910,9 +932,9 @@ class Parser : public ParserBase<ParserTraits> {
Expression* subject, Statement* body,
bool is_destructuring);
Statement* DesugarLexicalBindingsInForStatement(
- Scope* inner_scope, bool is_const, ZoneList<const AstRawString*>* names,
- ForStatement* loop, Statement* init, Expression* cond, Statement* next,
- Statement* body, bool* ok);
+ Scope* inner_scope, VariableMode mode,
+ ZoneList<const AstRawString*>* names, ForStatement* loop, Statement* init,
+ Expression* cond, Statement* next, Statement* body, bool* ok);
void RewriteDoExpression(Expression* expr, bool* ok);
@@ -920,7 +942,6 @@ class Parser : public ParserBase<ParserTraits> {
const AstRawString* name, Scanner::Location function_name_location,
FunctionNameValidity function_name_validity, FunctionKind kind,
int function_token_position, FunctionLiteral::FunctionType type,
- FunctionLiteral::ArityRestriction arity_restriction,
LanguageMode language_mode, bool* ok);
@@ -966,8 +987,9 @@ class Parser : public ParserBase<ParserTraits> {
Statement* BuildAssertIsCoercible(Variable* var);
// Factory methods.
- FunctionLiteral* DefaultConstructor(bool call_super, Scope* scope, int pos,
- int end_pos, LanguageMode language_mode);
+ FunctionLiteral* DefaultConstructor(const AstRawString* name, bool call_super,
+ Scope* scope, int pos, int end_pos,
+ LanguageMode language_mode);
// Skip over a lazy function, either using cached data if we have it, or
// by parsing the function with PreParser. Consumes the ending }.
@@ -1013,14 +1035,10 @@ class Parser : public ParserBase<ParserTraits> {
V8_INLINE void RewriteDestructuringAssignments();
- V8_INLINE Expression* RewriteNonPattern(
- Expression* expr, const ExpressionClassifier* classifier, bool* ok);
- V8_INLINE ZoneList<Expression*>* RewriteNonPatternArguments(
- ZoneList<Expression*>* args, const ExpressionClassifier* classifier,
- bool* ok);
- V8_INLINE ObjectLiteralProperty* RewriteNonPatternObjectLiteralProperty(
- ObjectLiteralProperty* property, const ExpressionClassifier* classifier,
- bool* ok);
+ friend class NonPatternRewriter;
+ V8_INLINE Expression* RewriteSpreads(ArrayLiteral* lit);
+
+ V8_INLINE void RewriteNonPattern(ExpressionClassifier* classifier, bool* ok);
friend class InitializerRewriter;
void RewriteParameterInitializer(Expression* expr, Scope* scope);
@@ -1171,7 +1189,7 @@ void ParserTraits::AddFormalParameter(ParserFormalParameters* parameters,
void ParserTraits::DeclareFormalParameter(
Scope* scope, const ParserFormalParameters::Parameter& parameter,
- ExpressionClassifier* classifier) {
+ Type::ExpressionClassifier* classifier) {
bool is_duplicate = false;
bool is_simple = classifier->is_simple_parameter_list();
auto name = is_simple || parameter.is_rest