| 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 641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 652 // The following rewriting rules enable the collection of type feedback | 652 // The following rewriting rules enable the collection of type feedback |
| 653 // without any special stub and the multiplication is removed later in | 653 // without any special stub and the multiplication is removed later in |
| 654 // Crankshaft's canonicalization pass. | 654 // Crankshaft's canonicalization pass. |
| 655 // + foo -> foo * 1 | 655 // + foo -> foo * 1 |
| 656 // - foo -> foo * (-1) | 656 // - foo -> foo * (-1) |
| 657 // ~ foo -> foo ^(~0) | 657 // ~ foo -> foo ^(~0) |
| 658 Expression* BuildUnaryExpression(Expression* expression, Token::Value op, | 658 Expression* BuildUnaryExpression(Expression* expression, Token::Value op, |
| 659 int pos, AstNodeFactory* factory); | 659 int pos, AstNodeFactory* factory); |
| 660 | 660 |
| 661 // Generate AST node that throws a ReferenceError with the given type. | 661 // Generate AST node that throws a ReferenceError with the given type. |
| 662 Expression* NewThrowReferenceError(const char* type, int pos); | 662 Expression* NewThrowReferenceError(MessageTemplate::Template message, |
| 663 int pos); |
| 663 | 664 |
| 664 // Generate AST node that throws a SyntaxError with the given | 665 // Generate AST node that throws a SyntaxError with the given |
| 665 // type. The first argument may be null (in the handle sense) in | 666 // type. The first argument may be null (in the handle sense) in |
| 666 // which case no arguments are passed to the constructor. | 667 // which case no arguments are passed to the constructor. |
| 667 Expression* NewThrowSyntaxError( | 668 Expression* NewThrowSyntaxError(MessageTemplate::Template message, |
| 668 const char* type, const AstRawString* arg, int pos); | 669 const AstRawString* arg, int pos); |
| 669 | 670 |
| 670 // Generate AST node that throws a TypeError with the given | 671 // Generate AST node that throws a TypeError with the given |
| 671 // type. Both arguments must be non-null (in the handle sense). | 672 // type. Both arguments must be non-null (in the handle sense). |
| 672 Expression* NewThrowTypeError(const char* type, const AstRawString* arg, | 673 Expression* NewThrowTypeError(MessageTemplate::Template message, |
| 673 int pos); | 674 const AstRawString* arg, int pos); |
| 674 | 675 |
| 675 // Generic AST generator for throwing errors from compiled code. | 676 // Generic AST generator for throwing errors from compiled code. |
| 676 Expression* NewThrowError( | 677 Expression* NewThrowError(const AstRawString* constructor, |
| 677 const AstRawString* constructor, const char* type, | 678 MessageTemplate::Template message, |
| 678 const AstRawString* arg, int pos); | 679 const AstRawString* arg, int pos); |
| 679 | 680 |
| 680 // Reporting errors. | 681 // Reporting errors. |
| 681 void ReportMessageAt(Scanner::Location source_location, const char* message, | 682 void ReportMessageAt(Scanner::Location source_location, |
| 683 MessageTemplate::Template message, |
| 682 const char* arg = NULL, | 684 const char* arg = NULL, |
| 683 ParseErrorType error_type = kSyntaxError); | 685 ParseErrorType error_type = kSyntaxError); |
| 684 void ReportMessage(const char* message, const char* arg = NULL, | 686 void ReportMessage(MessageTemplate::Template message, const char* arg = NULL, |
| 685 ParseErrorType error_type = kSyntaxError); | 687 ParseErrorType error_type = kSyntaxError); |
| 686 void ReportMessage(const char* message, const AstRawString* arg, | 688 void ReportMessage(MessageTemplate::Template message, const AstRawString* arg, |
| 687 ParseErrorType error_type = kSyntaxError); | 689 ParseErrorType error_type = kSyntaxError); |
| 688 void ReportMessageAt(Scanner::Location source_location, const char* message, | 690 void ReportMessageAt(Scanner::Location source_location, |
| 691 MessageTemplate::Template message, |
| 689 const AstRawString* arg, | 692 const AstRawString* arg, |
| 690 ParseErrorType error_type = kSyntaxError); | 693 ParseErrorType error_type = kSyntaxError); |
| 691 | 694 |
| 692 // "null" return type creators. | 695 // "null" return type creators. |
| 693 static const AstRawString* EmptyIdentifier() { | 696 static const AstRawString* EmptyIdentifier() { |
| 694 return NULL; | 697 return NULL; |
| 695 } | 698 } |
| 696 static Expression* EmptyExpression() { | 699 static Expression* EmptyExpression() { |
| 697 return NULL; | 700 return NULL; |
| 698 } | 701 } |
| (...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1259 } | 1262 } |
| 1260 | 1263 |
| 1261 | 1264 |
| 1262 Expression* ParserTraits::SpreadCallNew( | 1265 Expression* ParserTraits::SpreadCallNew( |
| 1263 Expression* function, ZoneList<v8::internal::Expression*>* args, int pos) { | 1266 Expression* function, ZoneList<v8::internal::Expression*>* args, int pos) { |
| 1264 return parser_->SpreadCallNew(function, args, pos); | 1267 return parser_->SpreadCallNew(function, args, pos); |
| 1265 } | 1268 } |
| 1266 } } // namespace v8::internal | 1269 } } // namespace v8::internal |
| 1267 | 1270 |
| 1268 #endif // V8_PARSER_H_ | 1271 #endif // V8_PARSER_H_ |
| OLD | NEW |