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 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
585 FunctionLiteral::ArityRestriction arity_restriction, bool* ok); | 585 FunctionLiteral::ArityRestriction arity_restriction, bool* ok); |
586 V8_INLINE void SkipLazyFunctionBody(const AstRawString* name, | 586 V8_INLINE void SkipLazyFunctionBody(const AstRawString* name, |
587 int* materialized_literal_count, | 587 int* materialized_literal_count, |
588 int* expected_property_count, bool* ok); | 588 int* expected_property_count, bool* ok); |
589 V8_INLINE ZoneList<Statement*>* ParseEagerFunctionBody( | 589 V8_INLINE ZoneList<Statement*>* ParseEagerFunctionBody( |
590 const AstRawString* name, int pos, Variable* fvar, | 590 const AstRawString* name, int pos, Variable* fvar, |
591 Token::Value fvar_init_op, bool is_generator, bool* ok); | 591 Token::Value fvar_init_op, bool is_generator, bool* ok); |
592 V8_INLINE void CheckConflictingVarDeclarations(v8::internal::Scope* scope, | 592 V8_INLINE void CheckConflictingVarDeclarations(v8::internal::Scope* scope, |
593 bool* ok); | 593 bool* ok); |
594 | 594 |
| 595 typedef TemplateLiteral* TemplateLiteralState; |
| 596 V8_INLINE TemplateLiteralState OpenTemplateLiteral(int pos); |
| 597 V8_INLINE void AddTemplateSpan(TemplateLiteralState* state); |
| 598 V8_INLINE void AddTemplateExpression(TemplateLiteralState* state, |
| 599 Expression* expression); |
| 600 V8_INLINE Expression* CloseTemplateLiteral(TemplateLiteralState* state, |
| 601 int start, Expression* tag); |
| 602 V8_INLINE Expression* NoTemplateTag() { return NULL; } |
| 603 |
595 private: | 604 private: |
596 Parser* parser_; | 605 Parser* parser_; |
597 }; | 606 }; |
598 | 607 |
599 | 608 |
600 class Parser : public ParserBase<ParserTraits> { | 609 class Parser : public ParserBase<ParserTraits> { |
601 public: | 610 public: |
602 // Note that the hash seed in ParseInfo must be the hash seed from the | 611 // Note that the hash seed in ParseInfo must be the hash seed from the |
603 // Isolate's heap, otherwise the heap will be in an inconsistent state once | 612 // Isolate's heap, otherwise the heap will be in an inconsistent state once |
604 // the strings created by the Parser are internalized. | 613 // the strings created by the Parser are internalized. |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
816 | 825 |
817 // Consumes the ending }. | 826 // Consumes the ending }. |
818 ZoneList<Statement*>* ParseEagerFunctionBody( | 827 ZoneList<Statement*>* ParseEagerFunctionBody( |
819 const AstRawString* function_name, int pos, Variable* fvar, | 828 const AstRawString* function_name, int pos, Variable* fvar, |
820 Token::Value fvar_init_op, bool is_generator, bool* ok); | 829 Token::Value fvar_init_op, bool is_generator, bool* ok); |
821 | 830 |
822 void HandleSourceURLComments(); | 831 void HandleSourceURLComments(); |
823 | 832 |
824 void ThrowPendingError(); | 833 void ThrowPendingError(); |
825 | 834 |
| 835 TemplateLiteralState OpenTemplateLiteral(int pos); |
| 836 void AddTemplateSpan(TemplateLiteralState* state); |
| 837 void AddTemplateExpression(TemplateLiteralState* state, |
| 838 Expression* expression); |
| 839 Expression* CloseTemplateLiteral(TemplateLiteralState* state, |
| 840 int start, Expression* tag); |
826 Scanner scanner_; | 841 Scanner scanner_; |
827 PreParser* reusable_preparser_; | 842 PreParser* reusable_preparser_; |
828 Scope* original_scope_; // for ES5 function declarations in sloppy eval | 843 Scope* original_scope_; // for ES5 function declarations in sloppy eval |
829 Target* target_stack_; // for break, continue statements | 844 Target* target_stack_; // for break, continue statements |
830 ParseData* cached_parse_data_; | 845 ParseData* cached_parse_data_; |
831 | 846 |
832 CompilationInfo* info_; | 847 CompilationInfo* info_; |
833 | 848 |
834 // Pending errors. | 849 // Pending errors. |
835 bool has_pending_error_; | 850 bool has_pending_error_; |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
916 // Get the elements array of a compile time value returned by GetValue(). | 931 // Get the elements array of a compile time value returned by GetValue(). |
917 static Handle<FixedArray> GetElements(Handle<FixedArray> value); | 932 static Handle<FixedArray> GetElements(Handle<FixedArray> value); |
918 | 933 |
919 private: | 934 private: |
920 static const int kLiteralTypeSlot = 0; | 935 static const int kLiteralTypeSlot = 0; |
921 static const int kElementsSlot = 1; | 936 static const int kElementsSlot = 1; |
922 | 937 |
923 DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue); | 938 DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue); |
924 }; | 939 }; |
925 | 940 |
| 941 ParserTraits::TemplateLiteralState ParserTraits::OpenTemplateLiteral(int pos) { |
| 942 return parser_->OpenTemplateLiteral(pos); |
| 943 } |
| 944 |
| 945 void ParserTraits::AddTemplateSpan(TemplateLiteralState* state) { |
| 946 parser_->AddTemplateSpan(state); |
| 947 } |
| 948 void ParserTraits::AddTemplateExpression(TemplateLiteralState* state, |
| 949 Expression* expression) { |
| 950 parser_->AddTemplateExpression(state, expression); |
| 951 } |
| 952 Expression* ParserTraits::CloseTemplateLiteral(TemplateLiteralState* state, |
| 953 int start, Expression* tag) { |
| 954 return parser_->CloseTemplateLiteral(state, start, tag); |
| 955 } |
926 } } // namespace v8::internal | 956 } } // namespace v8::internal |
927 | 957 |
928 #endif // V8_PARSER_H_ | 958 #endif // V8_PARSER_H_ |
OLD | NEW |