| 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 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 586 Scanner::Location class_name_location, | 586 Scanner::Location class_name_location, |
| 587 bool name_is_strict_reserved, int pos, | 587 bool name_is_strict_reserved, int pos, |
| 588 bool* ok); | 588 bool* ok); |
| 589 | 589 |
| 590 V8_INLINE void CheckConflictingVarDeclarations(v8::internal::Scope* scope, | 590 V8_INLINE void CheckConflictingVarDeclarations(v8::internal::Scope* scope, |
| 591 bool* ok); | 591 bool* ok); |
| 592 | 592 |
| 593 class TemplateLiteral : public ZoneObject { | 593 class TemplateLiteral : public ZoneObject { |
| 594 public: | 594 public: |
| 595 TemplateLiteral(Zone* zone, int pos) | 595 TemplateLiteral(Zone* zone, int pos) |
| 596 : cooked_(8, zone), | 596 : cooked_(8, zone), raw_(8, zone), expressions_(8, zone), pos_(pos) {} |
| 597 lengths_(8, zone), | |
| 598 expressions_(8, zone), | |
| 599 pos_(pos) {} | |
| 600 | 597 |
| 601 const ZoneList<Expression*>* cooked() const { return &cooked_; } | 598 const ZoneList<Expression*>* cooked() const { return &cooked_; } |
| 602 const ZoneList<int>* lengths() const { return &lengths_; } | 599 const ZoneList<Expression*>* raw() const { return &raw_; } |
| 603 const ZoneList<Expression*>* expressions() const { return &expressions_; } | 600 const ZoneList<Expression*>* expressions() const { return &expressions_; } |
| 604 int position() const { return pos_; } | 601 int position() const { return pos_; } |
| 605 | 602 |
| 606 void AddTemplateSpan(Literal* cooked, int end, Zone* zone) { | 603 void AddTemplateSpan(Literal* cooked, Literal* raw, int end, Zone* zone) { |
| 607 DCHECK_NOT_NULL(cooked); | 604 DCHECK_NOT_NULL(cooked); |
| 605 DCHECK_NOT_NULL(raw); |
| 608 cooked_.Add(cooked, zone); | 606 cooked_.Add(cooked, zone); |
| 609 lengths_.Add(end - cooked->position(), zone); | 607 raw_.Add(raw, zone); |
| 610 } | 608 } |
| 611 | 609 |
| 612 void AddExpression(Expression* expression, Zone* zone) { | 610 void AddExpression(Expression* expression, Zone* zone) { |
| 613 DCHECK_NOT_NULL(expression); | 611 DCHECK_NOT_NULL(expression); |
| 614 expressions_.Add(expression, zone); | 612 expressions_.Add(expression, zone); |
| 615 } | 613 } |
| 616 | 614 |
| 617 private: | 615 private: |
| 618 ZoneList<Expression*> cooked_; | 616 ZoneList<Expression*> cooked_; |
| 619 ZoneList<int> lengths_; | 617 ZoneList<Expression*> raw_; |
| 620 ZoneList<Expression*> expressions_; | 618 ZoneList<Expression*> expressions_; |
| 621 int pos_; | 619 int pos_; |
| 622 }; | 620 }; |
| 623 | 621 |
| 624 typedef TemplateLiteral* TemplateLiteralState; | 622 typedef TemplateLiteral* TemplateLiteralState; |
| 625 | 623 |
| 626 V8_INLINE TemplateLiteralState OpenTemplateLiteral(int pos); | 624 V8_INLINE TemplateLiteralState OpenTemplateLiteral(int pos); |
| 627 V8_INLINE void AddTemplateSpan(TemplateLiteralState* state, bool tail); | 625 V8_INLINE void AddTemplateSpan(TemplateLiteralState* state, bool tail); |
| 628 V8_INLINE void AddTemplateExpression(TemplateLiteralState* state, | 626 V8_INLINE void AddTemplateExpression(TemplateLiteralState* state, |
| 629 Expression* expression); | 627 Expression* expression); |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 877 void HandleSourceURLComments(); | 875 void HandleSourceURLComments(); |
| 878 | 876 |
| 879 void ThrowPendingError(); | 877 void ThrowPendingError(); |
| 880 | 878 |
| 881 TemplateLiteralState OpenTemplateLiteral(int pos); | 879 TemplateLiteralState OpenTemplateLiteral(int pos); |
| 882 void AddTemplateSpan(TemplateLiteralState* state, bool tail); | 880 void AddTemplateSpan(TemplateLiteralState* state, bool tail); |
| 883 void AddTemplateExpression(TemplateLiteralState* state, | 881 void AddTemplateExpression(TemplateLiteralState* state, |
| 884 Expression* expression); | 882 Expression* expression); |
| 885 Expression* CloseTemplateLiteral(TemplateLiteralState* state, int start, | 883 Expression* CloseTemplateLiteral(TemplateLiteralState* state, int start, |
| 886 Expression* tag); | 884 Expression* tag); |
| 887 ZoneList<Expression*>* TemplateRawStrings(const TemplateLiteral* lit, | 885 uint32_t ComputeTemplateLiteralHash(const TemplateLiteral* lit); |
| 888 uint32_t* hash); | 886 |
| 889 Scanner scanner_; | 887 Scanner scanner_; |
| 890 PreParser* reusable_preparser_; | 888 PreParser* reusable_preparser_; |
| 891 Scope* original_scope_; // for ES5 function declarations in sloppy eval | 889 Scope* original_scope_; // for ES5 function declarations in sloppy eval |
| 892 Target* target_stack_; // for break, continue statements | 890 Target* target_stack_; // for break, continue statements |
| 893 ParseData* cached_parse_data_; | 891 ParseData* cached_parse_data_; |
| 894 | 892 |
| 895 CompilationInfo* info_; | 893 CompilationInfo* info_; |
| 896 | 894 |
| 897 // Pending errors. | 895 // Pending errors. |
| 898 bool has_pending_error_; | 896 bool has_pending_error_; |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 998 } | 996 } |
| 999 | 997 |
| 1000 | 998 |
| 1001 Expression* ParserTraits::CloseTemplateLiteral(TemplateLiteralState* state, | 999 Expression* ParserTraits::CloseTemplateLiteral(TemplateLiteralState* state, |
| 1002 int start, Expression* tag) { | 1000 int start, Expression* tag) { |
| 1003 return parser_->CloseTemplateLiteral(state, start, tag); | 1001 return parser_->CloseTemplateLiteral(state, start, tag); |
| 1004 } | 1002 } |
| 1005 } } // namespace v8::internal | 1003 } } // namespace v8::internal |
| 1006 | 1004 |
| 1007 #endif // V8_PARSER_H_ | 1005 #endif // V8_PARSER_H_ |
| OLD | NEW |