| 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 Scope FormalParameterScope; |
| 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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 698 static Literal* EmptyLiteral() { | 700 static Literal* EmptyLiteral() { |
| 699 return NULL; | 701 return NULL; |
| 700 } | 702 } |
| 701 static ObjectLiteralProperty* EmptyObjectLiteralProperty() { return NULL; } | 703 static ObjectLiteralProperty* EmptyObjectLiteralProperty() { return NULL; } |
| 702 static FunctionLiteral* EmptyFunctionLiteral() { return NULL; } | 704 static FunctionLiteral* EmptyFunctionLiteral() { return NULL; } |
| 703 | 705 |
| 704 // Used in error return values. | 706 // Used in error return values. |
| 705 static ZoneList<Expression*>* NullExpressionList() { | 707 static ZoneList<Expression*>* NullExpressionList() { |
| 706 return NULL; | 708 return NULL; |
| 707 } | 709 } |
| 710 static const AstRawString* EmptyFormalParameter() { return NULL; } |
| 708 | 711 |
| 709 // Non-NULL empty string. | 712 // Non-NULL empty string. |
| 710 V8_INLINE const AstRawString* EmptyIdentifierString(); | 713 V8_INLINE const AstRawString* EmptyIdentifierString(); |
| 711 | 714 |
| 712 // Odd-ball literal creators. | 715 // Odd-ball literal creators. |
| 713 Literal* GetLiteralTheHole(int position, AstNodeFactory* factory); | 716 Literal* GetLiteralTheHole(int position, AstNodeFactory* factory); |
| 714 | 717 |
| 715 // Producing data during the recursive descent. | 718 // Producing data during the recursive descent. |
| 716 const AstRawString* GetSymbol(Scanner* scanner); | 719 const AstRawString* GetSymbol(Scanner* scanner); |
| 717 const AstRawString* GetNextSymbol(Scanner* scanner); | 720 const AstRawString* GetNextSymbol(Scanner* scanner); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 738 return new(zone) ZoneList<ObjectLiteral::Property*>(size, zone); | 741 return new(zone) ZoneList<ObjectLiteral::Property*>(size, zone); |
| 739 } | 742 } |
| 740 ZoneList<v8::internal::Statement*>* NewStatementList(int size, Zone* zone) { | 743 ZoneList<v8::internal::Statement*>* NewStatementList(int size, Zone* zone) { |
| 741 return new(zone) ZoneList<v8::internal::Statement*>(size, zone); | 744 return new(zone) ZoneList<v8::internal::Statement*>(size, zone); |
| 742 } | 745 } |
| 743 V8_INLINE Scope* NewScope(Scope* parent_scope, ScopeType scope_type, | 746 V8_INLINE Scope* NewScope(Scope* parent_scope, ScopeType scope_type, |
| 744 FunctionKind kind = kNormalFunction); | 747 FunctionKind kind = kNormalFunction); |
| 745 | 748 |
| 746 // Utility functions | 749 // Utility functions |
| 747 int DeclareArrowParametersFromExpression(Expression* expression, Scope* scope, | 750 int DeclareArrowParametersFromExpression(Expression* expression, Scope* scope, |
| 748 Scanner::Location* undefined_loc, | 751 FormalParameterErrorLocations* locs, |
| 749 Scanner::Location* dupe_loc, | |
| 750 bool* ok); | 752 bool* ok); |
| 751 | 753 |
| 754 bool DeclareFormalParameter(Scope* scope, const AstRawString* name, |
| 755 bool is_rest) { |
| 756 bool is_duplicate = false; |
| 757 Variable* var = scope->DeclareParameter(name, VAR, is_rest, &is_duplicate); |
| 758 if (is_sloppy(scope->language_mode())) { |
| 759 // TODO(sigurds) Mark every parameter as maybe assigned. This is a |
| 760 // conservative approximation necessary to account for parameters |
| 761 // that are assigned via the arguments array. |
| 762 var->set_maybe_assigned(); |
| 763 } |
| 764 return is_duplicate; |
| 765 } |
| 766 |
| 752 // Temporary glue; these functions will move to ParserBase. | 767 // Temporary glue; these functions will move to ParserBase. |
| 753 Expression* ParseV8Intrinsic(bool* ok); | 768 Expression* ParseV8Intrinsic(bool* ok); |
| 754 FunctionLiteral* ParseFunctionLiteral( | 769 FunctionLiteral* ParseFunctionLiteral( |
| 755 const AstRawString* name, Scanner::Location function_name_location, | 770 const AstRawString* name, Scanner::Location function_name_location, |
| 756 bool name_is_strict_reserved, FunctionKind kind, | 771 bool name_is_strict_reserved, FunctionKind kind, |
| 757 int function_token_position, FunctionLiteral::FunctionType type, | 772 int function_token_position, FunctionLiteral::FunctionType type, |
| 758 FunctionLiteral::ArityRestriction arity_restriction, bool* ok); | 773 FunctionLiteral::ArityRestriction arity_restriction, bool* ok); |
| 759 V8_INLINE void SkipLazyFunctionBody(const AstRawString* name, | 774 V8_INLINE void SkipLazyFunctionBody(const AstRawString* name, |
| 760 int* materialized_literal_count, | 775 int* materialized_literal_count, |
| 761 int* expected_property_count, bool* ok); | 776 int* expected_property_count, bool* ok); |
| (...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1162 } | 1177 } |
| 1163 | 1178 |
| 1164 | 1179 |
| 1165 Expression* ParserTraits::SpreadCallNew( | 1180 Expression* ParserTraits::SpreadCallNew( |
| 1166 Expression* function, ZoneList<v8::internal::Expression*>* args, int pos) { | 1181 Expression* function, ZoneList<v8::internal::Expression*>* args, int pos) { |
| 1167 return parser_->SpreadCallNew(function, args, pos); | 1182 return parser_->SpreadCallNew(function, args, pos); |
| 1168 } | 1183 } |
| 1169 } } // namespace v8::internal | 1184 } } // namespace v8::internal |
| 1170 | 1185 |
| 1171 #endif // V8_PARSER_H_ | 1186 #endif // V8_PARSER_H_ |
| OLD | NEW |