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

Side by Side Diff: src/parser.h

Issue 1399893002: [es7] implement |do| expressions proposal (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix AST numbering issue + add simple TF impl Created 5 years, 2 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 unified diff | Download patch
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_PARSER_H_ 5 #ifndef V8_PARSER_H_
6 #define V8_PARSER_H_ 6 #define V8_PARSER_H_
7 7
8 #include "src/allocation.h" 8 #include "src/allocation.h"
9 #include "src/ast.h" 9 #include "src/ast.h"
10 #include "src/compiler.h" // TODO(titzer): remove this include dependency 10 #include "src/compiler.h" // TODO(titzer): remove this include dependency
(...skipping 795 matching lines...) Expand 10 before | Expand all | Expand 10 after
806 int function_token_position, FunctionLiteral::FunctionType type, 806 int function_token_position, FunctionLiteral::FunctionType type,
807 FunctionLiteral::ArityRestriction arity_restriction, 807 FunctionLiteral::ArityRestriction arity_restriction,
808 LanguageMode language_mode, bool* ok); 808 LanguageMode language_mode, bool* ok);
809 V8_INLINE void SkipLazyFunctionBody( 809 V8_INLINE void SkipLazyFunctionBody(
810 int* materialized_literal_count, int* expected_property_count, bool* ok, 810 int* materialized_literal_count, int* expected_property_count, bool* ok,
811 Scanner::BookmarkScope* bookmark = nullptr); 811 Scanner::BookmarkScope* bookmark = nullptr);
812 V8_INLINE ZoneList<Statement*>* ParseEagerFunctionBody( 812 V8_INLINE ZoneList<Statement*>* ParseEagerFunctionBody(
813 const AstRawString* name, int pos, 813 const AstRawString* name, int pos,
814 const ParserFormalParameters& parameters, FunctionKind kind, 814 const ParserFormalParameters& parameters, FunctionKind kind,
815 FunctionLiteral::FunctionType function_type, bool* ok); 815 FunctionLiteral::FunctionType function_type, bool* ok);
816 V8_INLINE ZoneList<Statement*>* ParseStatementList(Token::Value end_token,
817 bool* ok);
816 818
817 ClassLiteral* ParseClassLiteral(const AstRawString* name, 819 ClassLiteral* ParseClassLiteral(const AstRawString* name,
818 Scanner::Location class_name_location, 820 Scanner::Location class_name_location,
819 bool name_is_strict_reserved, int pos, 821 bool name_is_strict_reserved, int pos,
820 bool* ok); 822 bool* ok);
821 823
824 inline void RewriteDoExpression(Expression* expr, bool* ok);
825
822 V8_INLINE void CheckConflictingVarDeclarations(v8::internal::Scope* scope, 826 V8_INLINE void CheckConflictingVarDeclarations(v8::internal::Scope* scope,
823 bool* ok); 827 bool* ok);
824 828
825 class TemplateLiteral : public ZoneObject { 829 class TemplateLiteral : public ZoneObject {
826 public: 830 public:
827 TemplateLiteral(Zone* zone, int pos) 831 TemplateLiteral(Zone* zone, int pos)
828 : cooked_(8, zone), raw_(8, zone), expressions_(8, zone), pos_(pos) {} 832 : cooked_(8, zone), raw_(8, zone), expressions_(8, zone), pos_(pos) {}
829 833
830 const ZoneList<Expression*>* cooked() const { return &cooked_; } 834 const ZoneList<Expression*>* cooked() const { return &cooked_; }
831 const ZoneList<Expression*>* raw() const { return &raw_; } 835 const ZoneList<Expression*>* raw() const { return &raw_; }
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
1097 // Initialize the components of a for-in / for-of statement. 1101 // Initialize the components of a for-in / for-of statement.
1098 void InitializeForEachStatement(ForEachStatement* stmt, 1102 void InitializeForEachStatement(ForEachStatement* stmt,
1099 Expression* each, 1103 Expression* each,
1100 Expression* subject, 1104 Expression* subject,
1101 Statement* body); 1105 Statement* body);
1102 Statement* DesugarLexicalBindingsInForStatement( 1106 Statement* DesugarLexicalBindingsInForStatement(
1103 Scope* inner_scope, bool is_const, ZoneList<const AstRawString*>* names, 1107 Scope* inner_scope, bool is_const, ZoneList<const AstRawString*>* names,
1104 ForStatement* loop, Statement* init, Expression* cond, Statement* next, 1108 ForStatement* loop, Statement* init, Expression* cond, Statement* next,
1105 Statement* body, bool* ok); 1109 Statement* body, bool* ok);
1106 1110
1111 void RewriteDoExpression(Expression* expr, bool* ok);
1112
1107 FunctionLiteral* ParseFunctionLiteral( 1113 FunctionLiteral* ParseFunctionLiteral(
1108 const AstRawString* name, Scanner::Location function_name_location, 1114 const AstRawString* name, Scanner::Location function_name_location,
1109 FunctionNameValidity function_name_validity, FunctionKind kind, 1115 FunctionNameValidity function_name_validity, FunctionKind kind,
1110 int function_token_position, FunctionLiteral::FunctionType type, 1116 int function_token_position, FunctionLiteral::FunctionType type,
1111 FunctionLiteral::ArityRestriction arity_restriction, 1117 FunctionLiteral::ArityRestriction arity_restriction,
1112 LanguageMode language_mode, bool* ok); 1118 LanguageMode language_mode, bool* ok);
1113 1119
1114 1120
1115 ClassLiteral* ParseClassLiteral(const AstRawString* name, 1121 ClassLiteral* ParseClassLiteral(const AstRawString* name,
1116 Scanner::Location class_name_location, 1122 Scanner::Location class_name_location,
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
1241 } 1247 }
1242 1248
1243 1249
1244 ZoneList<Statement*>* ParserTraits::ParseEagerFunctionBody( 1250 ZoneList<Statement*>* ParserTraits::ParseEagerFunctionBody(
1245 const AstRawString* name, int pos, const ParserFormalParameters& parameters, 1251 const AstRawString* name, int pos, const ParserFormalParameters& parameters,
1246 FunctionKind kind, FunctionLiteral::FunctionType function_type, bool* ok) { 1252 FunctionKind kind, FunctionLiteral::FunctionType function_type, bool* ok) {
1247 return parser_->ParseEagerFunctionBody(name, pos, parameters, kind, 1253 return parser_->ParseEagerFunctionBody(name, pos, parameters, kind,
1248 function_type, ok); 1254 function_type, ok);
1249 } 1255 }
1250 1256
1257
1258 ZoneList<Statement*>* ParserTraits::ParseStatementList(Token::Value end_token,
1259 bool* ok) {
1260 ZoneList<Statement*>* statements =
1261 new (parser_->zone()) ZoneList<Statement*>(16, parser_->zone());
1262 parser_->ParseStatementList(statements, end_token, ok);
1263 return statements;
1264 }
1265
1266
1251 void ParserTraits::CheckConflictingVarDeclarations(v8::internal::Scope* scope, 1267 void ParserTraits::CheckConflictingVarDeclarations(v8::internal::Scope* scope,
1252 bool* ok) { 1268 bool* ok) {
1253 parser_->CheckConflictingVarDeclarations(scope, ok); 1269 parser_->CheckConflictingVarDeclarations(scope, ok);
1254 } 1270 }
1255 1271
1256 1272
1257 // Support for handling complex values (array and object literals) that 1273 // Support for handling complex values (array and object literals) that
1258 // can be fully handled at compile time. 1274 // can be fully handled at compile time.
1259 class CompileTimeValue: public AllStatic { 1275 class CompileTimeValue: public AllStatic {
1260 public: 1276 public:
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
1370 ZoneList<v8::internal::Statement*>* body, bool* ok) { 1386 ZoneList<v8::internal::Statement*>* body, bool* ok) {
1371 if (!parameters.is_simple) { 1387 if (!parameters.is_simple) {
1372 auto* init_block = 1388 auto* init_block =
1373 parser_->BuildParameterInitializationBlock(parameters, ok); 1389 parser_->BuildParameterInitializationBlock(parameters, ok);
1374 if (!*ok) return; 1390 if (!*ok) return;
1375 if (init_block != nullptr) { 1391 if (init_block != nullptr) {
1376 body->Add(init_block, parser_->zone()); 1392 body->Add(init_block, parser_->zone());
1377 } 1393 }
1378 } 1394 }
1379 } 1395 }
1396
1397
1398 void ParserTraits::RewriteDoExpression(Expression* expr, bool* ok) {
1399 return parser_->RewriteDoExpression(expr, ok);
1400 }
1401
1402
1380 } // namespace internal 1403 } // namespace internal
1381 } // namespace v8 1404 } // namespace v8
1382 1405
1383 #endif // V8_PARSER_H_ 1406 #endif // V8_PARSER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698