OLD | NEW |
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 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
550 // Return types for traversing functions. | 550 // Return types for traversing functions. |
551 typedef const AstRawString* Identifier; | 551 typedef const AstRawString* Identifier; |
552 typedef v8::internal::Expression* Expression; | 552 typedef v8::internal::Expression* Expression; |
553 typedef Yield* YieldExpression; | 553 typedef Yield* YieldExpression; |
554 typedef v8::internal::FunctionLiteral* FunctionLiteral; | 554 typedef v8::internal::FunctionLiteral* FunctionLiteral; |
555 typedef v8::internal::ClassLiteral* ClassLiteral; | 555 typedef v8::internal::ClassLiteral* ClassLiteral; |
556 typedef v8::internal::Literal* Literal; | 556 typedef v8::internal::Literal* Literal; |
557 typedef ObjectLiteral::Property* ObjectLiteralProperty; | 557 typedef ObjectLiteral::Property* ObjectLiteralProperty; |
558 typedef ZoneList<v8::internal::Expression*>* ExpressionList; | 558 typedef ZoneList<v8::internal::Expression*>* ExpressionList; |
559 typedef ZoneList<ObjectLiteral::Property*>* PropertyList; | 559 typedef ZoneList<ObjectLiteral::Property*>* PropertyList; |
| 560 typedef const v8::internal::AstRawString* FormalParameter; |
| 561 typedef ZoneList<const v8::internal::AstRawString*>* FormalParameterList; |
560 typedef ZoneList<v8::internal::Statement*>* StatementList; | 562 typedef ZoneList<v8::internal::Statement*>* StatementList; |
561 | 563 |
562 // For constructing objects returned by the traversing functions. | 564 // For constructing objects returned by the traversing functions. |
563 typedef AstNodeFactory Factory; | 565 typedef AstNodeFactory Factory; |
564 }; | 566 }; |
565 | 567 |
566 explicit ParserTraits(Parser* parser) : parser_(parser) {} | 568 explicit ParserTraits(Parser* parser) : parser_(parser) {} |
567 | 569 |
568 // Helper functions for recursive descent. | 570 // Helper functions for recursive descent. |
569 bool IsEval(const AstRawString* identifier) const; | 571 bool IsEval(const AstRawString* identifier) const; |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
697 static Literal* EmptyLiteral() { | 699 static Literal* EmptyLiteral() { |
698 return NULL; | 700 return NULL; |
699 } | 701 } |
700 static ObjectLiteralProperty* EmptyObjectLiteralProperty() { return NULL; } | 702 static ObjectLiteralProperty* EmptyObjectLiteralProperty() { return NULL; } |
701 static FunctionLiteral* EmptyFunctionLiteral() { return NULL; } | 703 static FunctionLiteral* EmptyFunctionLiteral() { return NULL; } |
702 | 704 |
703 // Used in error return values. | 705 // Used in error return values. |
704 static ZoneList<Expression*>* NullExpressionList() { | 706 static ZoneList<Expression*>* NullExpressionList() { |
705 return NULL; | 707 return NULL; |
706 } | 708 } |
| 709 static const AstRawString* EmptyFormalParameter() { return NULL; } |
| 710 static ZoneList<const AstRawString*>* NullFormalParameterList() { |
| 711 return NULL; |
| 712 } |
707 | 713 |
708 // Non-NULL empty string. | 714 // Non-NULL empty string. |
709 V8_INLINE const AstRawString* EmptyIdentifierString(); | 715 V8_INLINE const AstRawString* EmptyIdentifierString(); |
710 | 716 |
711 // Odd-ball literal creators. | 717 // Odd-ball literal creators. |
712 Literal* GetLiteralTheHole(int position, AstNodeFactory* factory); | 718 Literal* GetLiteralTheHole(int position, AstNodeFactory* factory); |
713 | 719 |
714 // Producing data during the recursive descent. | 720 // Producing data during the recursive descent. |
715 const AstRawString* GetSymbol(Scanner* scanner); | 721 const AstRawString* GetSymbol(Scanner* scanner); |
716 const AstRawString* GetNextSymbol(Scanner* scanner); | 722 const AstRawString* GetNextSymbol(Scanner* scanner); |
(...skipping 15 matching lines...) Expand all Loading... |
732 Expression* GetIterator(Expression* iterable, AstNodeFactory* factory); | 738 Expression* GetIterator(Expression* iterable, AstNodeFactory* factory); |
733 ZoneList<v8::internal::Expression*>* NewExpressionList(int size, Zone* zone) { | 739 ZoneList<v8::internal::Expression*>* NewExpressionList(int size, Zone* zone) { |
734 return new(zone) ZoneList<v8::internal::Expression*>(size, zone); | 740 return new(zone) ZoneList<v8::internal::Expression*>(size, zone); |
735 } | 741 } |
736 ZoneList<ObjectLiteral::Property*>* NewPropertyList(int size, Zone* zone) { | 742 ZoneList<ObjectLiteral::Property*>* NewPropertyList(int size, Zone* zone) { |
737 return new(zone) ZoneList<ObjectLiteral::Property*>(size, zone); | 743 return new(zone) ZoneList<ObjectLiteral::Property*>(size, zone); |
738 } | 744 } |
739 ZoneList<v8::internal::Statement*>* NewStatementList(int size, Zone* zone) { | 745 ZoneList<v8::internal::Statement*>* NewStatementList(int size, Zone* zone) { |
740 return new(zone) ZoneList<v8::internal::Statement*>(size, zone); | 746 return new(zone) ZoneList<v8::internal::Statement*>(size, zone); |
741 } | 747 } |
| 748 ZoneList<const v8::internal::AstRawString*>* NewFormalParameterList( |
| 749 int size, Zone* zone) { |
| 750 return new (zone) ZoneList<const v8::internal::AstRawString*>(size, zone); |
| 751 } |
742 V8_INLINE Scope* NewScope(Scope* parent_scope, ScopeType scope_type, | 752 V8_INLINE Scope* NewScope(Scope* parent_scope, ScopeType scope_type, |
743 FunctionKind kind = kNormalFunction); | 753 FunctionKind kind = kNormalFunction); |
744 | 754 |
745 // Utility functions | 755 // Utility functions |
746 int DeclareArrowParametersFromExpression(Expression* expression, Scope* scope, | 756 int DeclareArrowParametersFromExpression(Expression* expression, Scope* scope, |
747 Scanner::Location* dupe_loc, | 757 Scanner::Location* dupe_loc, |
748 bool* ok); | 758 bool* ok); |
749 | 759 |
750 // Temporary glue; these functions will move to ParserBase. | 760 // Temporary glue; these functions will move to ParserBase. |
751 Expression* ParseV8Intrinsic(bool* ok); | 761 Expression* ParseV8Intrinsic(bool* ok); |
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1159 } | 1169 } |
1160 | 1170 |
1161 | 1171 |
1162 Expression* ParserTraits::SpreadCallNew( | 1172 Expression* ParserTraits::SpreadCallNew( |
1163 Expression* function, ZoneList<v8::internal::Expression*>* args, int pos) { | 1173 Expression* function, ZoneList<v8::internal::Expression*>* args, int pos) { |
1164 return parser_->SpreadCallNew(function, args, pos); | 1174 return parser_->SpreadCallNew(function, args, pos); |
1165 } | 1175 } |
1166 } } // namespace v8::internal | 1176 } } // namespace v8::internal |
1167 | 1177 |
1168 #endif // V8_PARSER_H_ | 1178 #endif // V8_PARSER_H_ |
OLD | NEW |