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" // For CachedDataMode | 10 #include "src/compiler.h" // For CachedDataMode |
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
556 Expression* GetIterator(Expression* iterable, AstNodeFactory* factory); | 556 Expression* GetIterator(Expression* iterable, AstNodeFactory* factory); |
557 ZoneList<v8::internal::Expression*>* NewExpressionList(int size, Zone* zone) { | 557 ZoneList<v8::internal::Expression*>* NewExpressionList(int size, Zone* zone) { |
558 return new(zone) ZoneList<v8::internal::Expression*>(size, zone); | 558 return new(zone) ZoneList<v8::internal::Expression*>(size, zone); |
559 } | 559 } |
560 ZoneList<ObjectLiteral::Property*>* NewPropertyList(int size, Zone* zone) { | 560 ZoneList<ObjectLiteral::Property*>* NewPropertyList(int size, Zone* zone) { |
561 return new(zone) ZoneList<ObjectLiteral::Property*>(size, zone); | 561 return new(zone) ZoneList<ObjectLiteral::Property*>(size, zone); |
562 } | 562 } |
563 ZoneList<v8::internal::Statement*>* NewStatementList(int size, Zone* zone) { | 563 ZoneList<v8::internal::Statement*>* NewStatementList(int size, Zone* zone) { |
564 return new(zone) ZoneList<v8::internal::Statement*>(size, zone); | 564 return new(zone) ZoneList<v8::internal::Statement*>(size, zone); |
565 } | 565 } |
566 V8_INLINE Scope* NewScope(Scope* parent_scope, ScopeType scope_type); | 566 V8_INLINE Scope* NewScope(Scope* parent_scope, ScopeType scope_type, |
| 567 FunctionKind kind = kNormalFunction); |
567 | 568 |
568 // Utility functions | 569 // Utility functions |
569 int DeclareArrowParametersFromExpression(Expression* expression, Scope* scope, | 570 int DeclareArrowParametersFromExpression(Expression* expression, Scope* scope, |
570 Scanner::Location* dupe_loc, | 571 Scanner::Location* dupe_loc, |
571 bool* ok); | 572 bool* ok); |
572 V8_INLINE AstValueFactory* ast_value_factory(); | 573 V8_INLINE AstValueFactory* ast_value_factory(); |
573 | 574 |
574 // Temporary glue; these functions will move to ParserBase. | 575 // Temporary glue; these functions will move to ParserBase. |
575 Expression* ParseV8Intrinsic(bool* ok); | 576 Expression* ParseV8Intrinsic(bool* ok); |
576 FunctionLiteral* ParseFunctionLiteral( | 577 FunctionLiteral* ParseFunctionLiteral( |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
845 VariableMode mode, | 846 VariableMode mode, |
846 Interface* interface); | 847 Interface* interface); |
847 void Declare(Declaration* declaration, bool resolve, bool* ok); | 848 void Declare(Declaration* declaration, bool resolve, bool* ok); |
848 | 849 |
849 bool TargetStackContainsLabel(const AstRawString* label); | 850 bool TargetStackContainsLabel(const AstRawString* label); |
850 BreakableStatement* LookupBreakTarget(const AstRawString* label, bool* ok); | 851 BreakableStatement* LookupBreakTarget(const AstRawString* label, bool* ok); |
851 IterationStatement* LookupContinueTarget(const AstRawString* label, bool* ok); | 852 IterationStatement* LookupContinueTarget(const AstRawString* label, bool* ok); |
852 | 853 |
853 // Factory methods. | 854 // Factory methods. |
854 | 855 |
855 Scope* NewScope(Scope* parent, ScopeType type); | 856 Scope* NewScope(Scope* parent, ScopeType type, |
| 857 FunctionKind kind = kNormalFunction); |
856 | 858 |
857 FunctionLiteral* DefaultConstructor(bool call_super, Scope* scope, int pos, | 859 FunctionLiteral* DefaultConstructor(bool call_super, Scope* scope, int pos, |
858 int end_pos); | 860 int end_pos); |
859 | 861 |
860 // Skip over a lazy function, either using cached data if we have it, or | 862 // Skip over a lazy function, either using cached data if we have it, or |
861 // by parsing the function with PreParser. Consumes the ending }. | 863 // by parsing the function with PreParser. Consumes the ending }. |
862 void SkipLazyFunctionBody(const AstRawString* function_name, | 864 void SkipLazyFunctionBody(const AstRawString* function_name, |
863 int* materialized_literal_count, | 865 int* materialized_literal_count, |
864 int* expected_property_count, | 866 int* expected_property_count, |
865 bool* ok); | 867 bool* ok); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
906 HistogramTimer* pre_parse_timer_; | 908 HistogramTimer* pre_parse_timer_; |
907 }; | 909 }; |
908 | 910 |
909 | 911 |
910 bool ParserTraits::IsFutureStrictReserved( | 912 bool ParserTraits::IsFutureStrictReserved( |
911 const AstRawString* identifier) const { | 913 const AstRawString* identifier) const { |
912 return parser_->scanner()->IdentifierIsFutureStrictReserved(identifier); | 914 return parser_->scanner()->IdentifierIsFutureStrictReserved(identifier); |
913 } | 915 } |
914 | 916 |
915 | 917 |
916 Scope* ParserTraits::NewScope(Scope* parent_scope, ScopeType scope_type) { | 918 Scope* ParserTraits::NewScope(Scope* parent_scope, ScopeType scope_type, |
917 return parser_->NewScope(parent_scope, scope_type); | 919 FunctionKind kind) { |
| 920 return parser_->NewScope(parent_scope, scope_type, kind); |
918 } | 921 } |
919 | 922 |
920 | 923 |
921 const AstRawString* ParserTraits::EmptyIdentifierString() { | 924 const AstRawString* ParserTraits::EmptyIdentifierString() { |
922 return parser_->ast_value_factory()->empty_string(); | 925 return parser_->ast_value_factory()->empty_string(); |
923 } | 926 } |
924 | 927 |
925 | 928 |
926 void ParserTraits::SkipLazyFunctionBody(const AstRawString* function_name, | 929 void ParserTraits::SkipLazyFunctionBody(const AstRawString* function_name, |
927 int* materialized_literal_count, | 930 int* materialized_literal_count, |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
995 } | 998 } |
996 | 999 |
997 | 1000 |
998 Expression* ParserTraits::CloseTemplateLiteral(TemplateLiteralState* state, | 1001 Expression* ParserTraits::CloseTemplateLiteral(TemplateLiteralState* state, |
999 int start, Expression* tag) { | 1002 int start, Expression* tag) { |
1000 return parser_->CloseTemplateLiteral(state, start, tag); | 1003 return parser_->CloseTemplateLiteral(state, start, tag); |
1001 } | 1004 } |
1002 } } // namespace v8::internal | 1005 } } // namespace v8::internal |
1003 | 1006 |
1004 #endif // V8_PARSER_H_ | 1007 #endif // V8_PARSER_H_ |
OLD | NEW |