Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2401)

Unified Diff: src/parsing/parser.h

Issue 2179423002: [parser] Refactor parser and preparser traits (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: More changes after reviewers' comments Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/parsing/parser.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parsing/parser.h
diff --git a/src/parsing/parser.h b/src/parsing/parser.h
index 9bb92e840899c2b21e1ad51ee16aacf6427ecc5c..8acbd84a050cd76bc7fa5f825df57b1dbe0902ba 100644
--- a/src/parsing/parser.h
+++ b/src/parsing/parser.h
@@ -494,49 +494,25 @@ class ParserTraits {
Expression* NewThrowTypeError(MessageTemplate::Template message,
const AstRawString* arg, int pos);
- // Generic AST generator for throwing errors from compiled code.
- Expression* NewThrowError(Runtime::FunctionId function_id,
- MessageTemplate::Template message,
- const AstRawString* arg, int pos);
-
- void FinalizeIteratorUse(Variable* completion, Expression* condition,
- Variable* iter, Block* iterator_use, Block* result);
-
- Statement* FinalizeForOfStatement(ForOfStatement* loop, Variable* completion,
- int pos);
-
// Reporting errors.
void ReportMessageAt(Scanner::Location source_location,
MessageTemplate::Template message,
const char* arg = NULL,
ParseErrorType error_type = kSyntaxError);
- void ReportMessage(MessageTemplate::Template message, const char* arg = NULL,
- ParseErrorType error_type = kSyntaxError);
- void ReportMessage(MessageTemplate::Template message, const AstRawString* arg,
- ParseErrorType error_type = kSyntaxError);
void ReportMessageAt(Scanner::Location source_location,
MessageTemplate::Template message,
const AstRawString* arg,
ParseErrorType error_type = kSyntaxError);
// "null" return type creators.
- static const AstRawString* EmptyIdentifier() {
- return NULL;
- }
- static Expression* EmptyExpression() {
- return NULL;
- }
- static Literal* EmptyLiteral() {
- return NULL;
- }
- static ObjectLiteralProperty* EmptyObjectLiteralProperty() { return NULL; }
- static FunctionLiteral* EmptyFunctionLiteral() { return NULL; }
+ static const AstRawString* EmptyIdentifier() { return nullptr; }
+ static Expression* EmptyExpression() { return nullptr; }
+ static Literal* EmptyLiteral() { return nullptr; }
+ static ObjectLiteralProperty* EmptyObjectLiteralProperty() { return nullptr; }
+ static FunctionLiteral* EmptyFunctionLiteral() { return nullptr; }
// Used in error return values.
- static ZoneList<Expression*>* NullExpressionList() {
- return NULL;
- }
- static const AstRawString* EmptyFormalParameter() { return NULL; }
+ static ZoneList<Expression*>* NullExpressionList() { return nullptr; }
// Non-NULL empty string.
V8_INLINE const AstRawString* EmptyIdentifierString();
@@ -581,10 +557,6 @@ class ParserTraits {
ZoneList<Statement*>* body, bool accept_IN,
Type::ExpressionClassifier* classifier, int pos, bool* ok);
- V8_INLINE Scope* NewScope(ScopeType scope_type);
- V8_INLINE DeclarationScope* NewFunctionScope(FunctionKind kind);
- V8_INLINE Scope* NewScopeWithParent(Scope* parent, ScopeType scope_type);
-
V8_INLINE void AddFormalParameter(ParserFormalParameters* parameters,
Expression* pattern,
Expression* initializer,
@@ -593,9 +565,6 @@ class ParserTraits {
DeclarationScope* scope,
const ParserFormalParameters::Parameter& parameter,
Type::ExpressionClassifier* classifier);
- void ParseArrowFunctionFormalParameters(ParserFormalParameters* parameters,
- Expression* params, int end_pos,
- bool* ok);
void ParseArrowFunctionFormalParameterList(
ParserFormalParameters* parameters, Expression* params,
const Scanner::Location& params_loc, Scanner::Location* duplicate_loc,
@@ -631,8 +600,7 @@ class ParserTraits {
V8_INLINE void MarkCollectedTailCallExpressions();
V8_INLINE void MarkTailPosition(Expression* expression);
- V8_INLINE void CheckConflictingVarDeclarations(v8::internal::Scope* scope,
- bool* ok);
+ V8_INLINE void CheckConflictingVarDeclarations(Scope* scope, bool* ok);
class TemplateLiteral : public ZoneObject {
public:
@@ -707,7 +675,6 @@ class ParserTraits {
void SetFunctionNameFromIdentifierRef(Expression* value,
Expression* identifier);
- void SetFunctionName(Expression* value, const AstRawString* name);
// Rewrite expressions that are not used as patterns
V8_INLINE void RewriteNonPattern(Type::ExpressionClassifier* classifier,
@@ -719,18 +686,11 @@ class ParserTraits {
V8_INLINE ZoneList<Expression*>* GetNonPatternList() const;
- Expression* RewriteYieldStar(
- Expression* generator, Expression* expression, int pos);
+ V8_INLINE Expression* RewriteYieldStar(Expression* generator,
+ Expression* expression, int pos);
private:
Parser* parser_;
-
- void BuildIteratorClose(ZoneList<Statement*>* statements, Variable* iterator,
- Variable* input, Variable* output);
- void BuildIteratorCloseForCompletion(ZoneList<Statement*>* statements,
- Variable* iterator,
- Expression* completion);
- Statement* CheckCallable(Variable* var, Expression* error, int pos);
};
@@ -1175,6 +1135,31 @@ class Parser : public ParserBase<ParserTraits> {
Expression* BuildPromiseResolve(Expression* value, int pos);
Expression* BuildPromiseReject(Expression* value, int pos);
+ // Generic AST generator for throwing errors from compiled code.
+ Expression* NewThrowError(Runtime::FunctionId function_id,
+ MessageTemplate::Template message,
+ const AstRawString* arg, int pos);
+
+ void FinalizeIteratorUse(Variable* completion, Expression* condition,
+ Variable* iter, Block* iterator_use, Block* result);
+
+ Statement* FinalizeForOfStatement(ForOfStatement* loop, Variable* completion,
+ int pos);
+ void BuildIteratorClose(ZoneList<Statement*>* statements, Variable* iterator,
+ Variable* input, Variable* output);
+ void BuildIteratorCloseForCompletion(ZoneList<Statement*>* statements,
+ Variable* iterator,
+ Expression* completion);
+ Statement* CheckCallable(Variable* var, Expression* error, int pos);
+
+ Expression* RewriteYieldStar(Expression* generator, Expression* expression,
+ int pos);
+
+ void ParseArrowFunctionFormalParameters(ParserFormalParameters* parameters,
+ Expression* params, int end_pos,
+ bool* ok);
+ void SetFunctionName(Expression* value, const AstRawString* name);
+
Scanner scanner_;
PreParser* reusable_preparser_;
Scope* original_scope_; // for ES5 function declarations in sloppy eval
@@ -1203,18 +1188,6 @@ bool ParserTraits::IsFutureStrictReserved(
return parser_->scanner()->IdentifierIsFutureStrictReserved(identifier);
}
-Scope* ParserTraits::NewScopeWithParent(Scope* parent, ScopeType scope_type) {
- return parser_->NewScopeWithParent(parent, scope_type);
-}
-
-Scope* ParserTraits::NewScope(ScopeType scope_type) {
- return parser_->NewScope(scope_type);
-}
-
-DeclarationScope* ParserTraits::NewFunctionScope(FunctionKind kind) {
- return parser_->NewFunctionScope(kind);
-}
-
const AstRawString* ParserTraits::EmptyIdentifierString() {
return parser_->ast_value_factory()->empty_string();
}
@@ -1235,9 +1208,7 @@ ZoneList<Statement*>* ParserTraits::ParseEagerFunctionBody(
function_type, ok);
}
-
-void ParserTraits::CheckConflictingVarDeclarations(v8::internal::Scope* scope,
- bool* ok) {
+void ParserTraits::CheckConflictingVarDeclarations(Scope* scope, bool* ok) {
parser_->CheckConflictingVarDeclarations(scope, ok);
}
@@ -1379,6 +1350,10 @@ DoExpression* ParserTraits::ParseDoExpression(bool* ok) {
return parser_->ParseDoExpression(ok);
}
+Expression* ParserTraits::RewriteYieldStar(Expression* generator,
+ Expression* iterable, int pos) {
+ return parser_->RewriteYieldStar(generator, iterable, pos);
+}
} // namespace internal
} // namespace v8
« no previous file with comments | « no previous file | src/parsing/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698