| 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 678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 689 const AstRawString* arg, | 689 const AstRawString* arg, |
| 690 ParseErrorType error_type = kSyntaxError); | 690 ParseErrorType error_type = kSyntaxError); |
| 691 | 691 |
| 692 // "null" return type creators. | 692 // "null" return type creators. |
| 693 static const AstRawString* EmptyIdentifier() { | 693 static const AstRawString* EmptyIdentifier() { |
| 694 return NULL; | 694 return NULL; |
| 695 } | 695 } |
| 696 static Expression* EmptyExpression() { | 696 static Expression* EmptyExpression() { |
| 697 return NULL; | 697 return NULL; |
| 698 } | 698 } |
| 699 static Expression* EmptyArrowParamList() { return NULL; } | |
| 700 static Literal* EmptyLiteral() { | 699 static Literal* EmptyLiteral() { |
| 701 return NULL; | 700 return NULL; |
| 702 } | 701 } |
| 703 static ObjectLiteralProperty* EmptyObjectLiteralProperty() { return NULL; } | 702 static ObjectLiteralProperty* EmptyObjectLiteralProperty() { return NULL; } |
| 704 static FunctionLiteral* EmptyFunctionLiteral() { return NULL; } | 703 static FunctionLiteral* EmptyFunctionLiteral() { return NULL; } |
| 705 | 704 |
| 706 // Used in error return values. | 705 // Used in error return values. |
| 707 static ZoneList<Expression*>* NullExpressionList() { | 706 static ZoneList<Expression*>* NullExpressionList() { |
| 708 return NULL; | 707 return NULL; |
| 709 } | 708 } |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 746 ZoneList<v8::internal::Statement*>* NewStatementList(int size, Zone* zone) { | 745 ZoneList<v8::internal::Statement*>* NewStatementList(int size, Zone* zone) { |
| 747 return new(zone) ZoneList<v8::internal::Statement*>(size, zone); | 746 return new(zone) ZoneList<v8::internal::Statement*>(size, zone); |
| 748 } | 747 } |
| 749 ZoneList<const v8::internal::AstRawString*>* NewFormalParameterList( | 748 ZoneList<const v8::internal::AstRawString*>* NewFormalParameterList( |
| 750 int size, Zone* zone) { | 749 int size, Zone* zone) { |
| 751 return new (zone) ZoneList<const v8::internal::AstRawString*>(size, zone); | 750 return new (zone) ZoneList<const v8::internal::AstRawString*>(size, zone); |
| 752 } | 751 } |
| 753 V8_INLINE Scope* NewScope(Scope* parent_scope, ScopeType scope_type, | 752 V8_INLINE Scope* NewScope(Scope* parent_scope, ScopeType scope_type, |
| 754 FunctionKind kind = kNormalFunction); | 753 FunctionKind kind = kNormalFunction); |
| 755 | 754 |
| 756 // Utility functions | 755 void RecordArrowFunctionParameter(ZoneList<const AstRawString*>* result, |
| 757 int DeclareArrowParametersFromExpression(Expression* expression, Scope* scope, | 756 VariableProxy* proxy, |
| 758 FormalParameterErrorLocations* locs, | 757 FormalParameterErrorLocations* error_locs, |
| 759 bool* ok); | 758 bool* ok); |
| 759 ZoneList<const AstRawString*>* ParseArrowFunctionFormalParameterList( |
| 760 Expression* params, const Scanner::Location& params_loc, |
| 761 FormalParameterErrorLocations* error_locs, bool* is_rest, bool* ok); |
| 760 | 762 |
| 761 // Temporary glue; these functions will move to ParserBase. | 763 // Temporary glue; these functions will move to ParserBase. |
| 762 Expression* ParseV8Intrinsic(bool* ok); | 764 Expression* ParseV8Intrinsic(bool* ok); |
| 763 FunctionLiteral* ParseFunctionLiteral( | 765 FunctionLiteral* ParseFunctionLiteral( |
| 764 const AstRawString* name, Scanner::Location function_name_location, | 766 const AstRawString* name, Scanner::Location function_name_location, |
| 765 bool name_is_strict_reserved, FunctionKind kind, | 767 bool name_is_strict_reserved, FunctionKind kind, |
| 766 int function_token_position, FunctionLiteral::FunctionType type, | 768 int function_token_position, FunctionLiteral::FunctionType type, |
| 767 FunctionLiteral::ArityRestriction arity_restriction, bool* ok); | 769 FunctionLiteral::ArityRestriction arity_restriction, bool* ok); |
| 768 V8_INLINE void SkipLazyFunctionBody(const AstRawString* name, | 770 V8_INLINE void SkipLazyFunctionBody(const AstRawString* name, |
| 769 int* materialized_literal_count, | 771 int* materialized_literal_count, |
| 770 int* expected_property_count, bool* ok); | 772 int* expected_property_count, bool* ok); |
| 771 V8_INLINE ZoneList<Statement*>* ParseEagerFunctionBody( | 773 V8_INLINE ZoneList<Statement*>* ParseEagerFunctionBody( |
| 772 const AstRawString* name, int pos, Variable* fvar, | 774 const AstRawString* name, int pos, Variable* fvar, |
| 773 Token::Value fvar_init_op, FunctionKind kind, bool* ok); | 775 Token::Value fvar_init_op, FunctionKind kind, bool* ok); |
| 774 | 776 |
| 775 ClassLiteral* ParseClassLiteral(const AstRawString* name, | 777 ClassLiteral* ParseClassLiteral(const AstRawString* name, |
| 776 Scanner::Location class_name_location, | 778 Scanner::Location class_name_location, |
| 777 bool name_is_strict_reserved, int pos, | 779 bool name_is_strict_reserved, int pos, |
| 778 bool* ok); | 780 bool* ok); |
| 779 | 781 |
| 782 int DeclareFormalParameters(ZoneList<const AstRawString*>* params, |
| 783 Scope* scope, bool has_rest); |
| 784 |
| 780 V8_INLINE void CheckConflictingVarDeclarations(v8::internal::Scope* scope, | 785 V8_INLINE void CheckConflictingVarDeclarations(v8::internal::Scope* scope, |
| 781 bool* ok); | 786 bool* ok); |
| 782 | 787 |
| 783 class TemplateLiteral : public ZoneObject { | 788 class TemplateLiteral : public ZoneObject { |
| 784 public: | 789 public: |
| 785 TemplateLiteral(Zone* zone, int pos) | 790 TemplateLiteral(Zone* zone, int pos) |
| 786 : cooked_(8, zone), raw_(8, zone), expressions_(8, zone), pos_(pos) {} | 791 : cooked_(8, zone), raw_(8, zone), expressions_(8, zone), pos_(pos) {} |
| 787 | 792 |
| 788 const ZoneList<Expression*>* cooked() const { return &cooked_; } | 793 const ZoneList<Expression*>* cooked() const { return &cooked_; } |
| 789 const ZoneList<Expression*>* raw() const { return &raw_; } | 794 const ZoneList<Expression*>* raw() const { return &raw_; } |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1046 Expression* SpreadCallNew(Expression* function, | 1051 Expression* SpreadCallNew(Expression* function, |
| 1047 ZoneList<v8::internal::Expression*>* args, int pos); | 1052 ZoneList<v8::internal::Expression*>* args, int pos); |
| 1048 | 1053 |
| 1049 Scanner scanner_; | 1054 Scanner scanner_; |
| 1050 PreParser* reusable_preparser_; | 1055 PreParser* reusable_preparser_; |
| 1051 Scope* original_scope_; // for ES5 function declarations in sloppy eval | 1056 Scope* original_scope_; // for ES5 function declarations in sloppy eval |
| 1052 Target* target_stack_; // for break, continue statements | 1057 Target* target_stack_; // for break, continue statements |
| 1053 ScriptCompiler::CompileOptions compile_options_; | 1058 ScriptCompiler::CompileOptions compile_options_; |
| 1054 ParseData* cached_parse_data_; | 1059 ParseData* cached_parse_data_; |
| 1055 | 1060 |
| 1056 bool parsing_lazy_arrow_parameters_; // for lazily parsed arrow functions. | |
| 1057 | |
| 1058 PendingCompilationErrorHandler pending_error_handler_; | 1061 PendingCompilationErrorHandler pending_error_handler_; |
| 1059 | 1062 |
| 1060 // Other information which will be stored in Parser and moved to Isolate after | 1063 // Other information which will be stored in Parser and moved to Isolate after |
| 1061 // parsing. | 1064 // parsing. |
| 1062 int use_counts_[v8::Isolate::kUseCounterFeatureCount]; | 1065 int use_counts_[v8::Isolate::kUseCounterFeatureCount]; |
| 1063 int total_preparse_skipped_; | 1066 int total_preparse_skipped_; |
| 1064 HistogramTimer* pre_parse_timer_; | 1067 HistogramTimer* pre_parse_timer_; |
| 1065 | 1068 |
| 1066 bool parsing_on_main_thread_; | 1069 bool parsing_on_main_thread_; |
| 1067 }; | 1070 }; |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1170 } | 1173 } |
| 1171 | 1174 |
| 1172 | 1175 |
| 1173 Expression* ParserTraits::SpreadCallNew( | 1176 Expression* ParserTraits::SpreadCallNew( |
| 1174 Expression* function, ZoneList<v8::internal::Expression*>* args, int pos) { | 1177 Expression* function, ZoneList<v8::internal::Expression*>* args, int pos) { |
| 1175 return parser_->SpreadCallNew(function, args, pos); | 1178 return parser_->SpreadCallNew(function, args, pos); |
| 1176 } | 1179 } |
| 1177 } } // namespace v8::internal | 1180 } } // namespace v8::internal |
| 1178 | 1181 |
| 1179 #endif // V8_PARSER_H_ | 1182 #endif // V8_PARSER_H_ |
| OLD | NEW |