OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 // JAVASCRIPT PARSING | 405 // JAVASCRIPT PARSING |
406 | 406 |
407 class Parser; | 407 class Parser; |
408 class SingletonLogger; | 408 class SingletonLogger; |
409 | 409 |
410 class ParserTraits { | 410 class ParserTraits { |
411 public: | 411 public: |
412 typedef Parser* ParserType; | 412 typedef Parser* ParserType; |
413 // Return types for traversing functions. | 413 // Return types for traversing functions. |
414 typedef Handle<String> IdentifierType; | 414 typedef Handle<String> IdentifierType; |
| 415 typedef Expression* ExpressionType; |
415 | 416 |
416 explicit ParserTraits(Parser* parser) : parser_(parser) {} | 417 explicit ParserTraits(Parser* parser) : parser_(parser) {} |
417 | 418 |
418 // Helper functions for recursive descent. | 419 // Helper functions for recursive descent. |
419 bool is_classic_mode() const; | 420 bool is_classic_mode() const; |
420 bool is_generator() const; | 421 bool is_generator() const; |
421 bool IsEvalOrArguments(Handle<String> identifier) const; | 422 bool IsEvalOrArguments(Handle<String> identifier) const; |
| 423 int NextMaterializedLiteralIndex(); |
422 | 424 |
423 // Reporting errors. | 425 // Reporting errors. |
424 void ReportMessageAt(Scanner::Location source_location, | 426 void ReportMessageAt(Scanner::Location source_location, |
425 const char* message, | 427 const char* message, |
426 Vector<const char*> args); | 428 Vector<const char*> args); |
427 void ReportMessage(const char* message, Vector<Handle<String> > args); | 429 void ReportMessage(const char* message, Vector<Handle<String> > args); |
428 void ReportMessageAt(Scanner::Location source_location, | 430 void ReportMessageAt(Scanner::Location source_location, |
429 const char* message, | 431 const char* message, |
430 Vector<Handle<String> > args); | 432 Vector<Handle<String> > args); |
431 | 433 |
432 // Identifiers: | 434 // "null" return type creators. |
433 static IdentifierType EmptyIdentifier() { | 435 static IdentifierType EmptyIdentifier() { |
434 return Handle<String>(); | 436 return Handle<String>(); |
435 } | 437 } |
| 438 static ExpressionType EmptyExpression() { |
| 439 return NULL; |
| 440 } |
436 | 441 |
| 442 // Producing data during the recursive descent. |
437 IdentifierType GetSymbol(); | 443 IdentifierType GetSymbol(); |
| 444 IdentifierType NextLiteralString(PretenureFlag tenured); |
| 445 ExpressionType NewRegExpLiteral(IdentifierType js_pattern, |
| 446 IdentifierType js_flags, |
| 447 int literal_index, |
| 448 int pos); |
438 | 449 |
439 private: | 450 private: |
440 Parser* parser_; | 451 Parser* parser_; |
441 }; | 452 }; |
442 | 453 |
443 | 454 |
444 class Parser : public ParserBase<ParserTraits> { | 455 class Parser : public ParserBase<ParserTraits> { |
445 public: | 456 public: |
446 explicit Parser(CompilationInfo* info); | 457 explicit Parser(CompilationInfo* info); |
447 ~Parser() { | 458 ~Parser() { |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
650 Expression* ParsePostfixExpression(bool* ok); | 661 Expression* ParsePostfixExpression(bool* ok); |
651 Expression* ParseLeftHandSideExpression(bool* ok); | 662 Expression* ParseLeftHandSideExpression(bool* ok); |
652 Expression* ParseNewExpression(bool* ok); | 663 Expression* ParseNewExpression(bool* ok); |
653 Expression* ParseMemberExpression(bool* ok); | 664 Expression* ParseMemberExpression(bool* ok); |
654 Expression* ParseNewPrefix(PositionStack* stack, bool* ok); | 665 Expression* ParseNewPrefix(PositionStack* stack, bool* ok); |
655 Expression* ParseMemberWithNewPrefixesExpression(PositionStack* stack, | 666 Expression* ParseMemberWithNewPrefixesExpression(PositionStack* stack, |
656 bool* ok); | 667 bool* ok); |
657 Expression* ParsePrimaryExpression(bool* ok); | 668 Expression* ParsePrimaryExpression(bool* ok); |
658 Expression* ParseArrayLiteral(bool* ok); | 669 Expression* ParseArrayLiteral(bool* ok); |
659 Expression* ParseObjectLiteral(bool* ok); | 670 Expression* ParseObjectLiteral(bool* ok); |
660 Expression* ParseRegExpLiteral(bool seen_equal, bool* ok); | |
661 | 671 |
662 // Initialize the components of a for-in / for-of statement. | 672 // Initialize the components of a for-in / for-of statement. |
663 void InitializeForEachStatement(ForEachStatement* stmt, | 673 void InitializeForEachStatement(ForEachStatement* stmt, |
664 Expression* each, | 674 Expression* each, |
665 Expression* subject, | 675 Expression* subject, |
666 Statement* body); | 676 Statement* body); |
667 | 677 |
668 ZoneList<Expression*>* ParseArguments(bool* ok); | 678 ZoneList<Expression*>* ParseArguments(bool* ok); |
669 FunctionLiteral* ParseFunctionLiteral( | 679 FunctionLiteral* ParseFunctionLiteral( |
670 Handle<String> name, | 680 Handle<String> name, |
(...skipping 12 matching lines...) Expand all Loading... |
683 Handle<String> LiteralString(PretenureFlag tenured) { | 693 Handle<String> LiteralString(PretenureFlag tenured) { |
684 if (scanner().is_literal_ascii()) { | 694 if (scanner().is_literal_ascii()) { |
685 return isolate_->factory()->NewStringFromAscii( | 695 return isolate_->factory()->NewStringFromAscii( |
686 scanner().literal_ascii_string(), tenured); | 696 scanner().literal_ascii_string(), tenured); |
687 } else { | 697 } else { |
688 return isolate_->factory()->NewStringFromTwoByte( | 698 return isolate_->factory()->NewStringFromTwoByte( |
689 scanner().literal_utf16_string(), tenured); | 699 scanner().literal_utf16_string(), tenured); |
690 } | 700 } |
691 } | 701 } |
692 | 702 |
693 Handle<String> NextLiteralString(PretenureFlag tenured) { | |
694 if (scanner().is_next_literal_ascii()) { | |
695 return isolate_->factory()->NewStringFromAscii( | |
696 scanner().next_literal_ascii_string(), tenured); | |
697 } else { | |
698 return isolate_->factory()->NewStringFromTwoByte( | |
699 scanner().next_literal_utf16_string(), tenured); | |
700 } | |
701 } | |
702 | |
703 // Get odd-ball literals. | 703 // Get odd-ball literals. |
704 Literal* GetLiteralUndefined(int position); | 704 Literal* GetLiteralUndefined(int position); |
705 Literal* GetLiteralTheHole(int position); | 705 Literal* GetLiteralTheHole(int position); |
706 | 706 |
707 // Determine if the expression is a variable proxy and mark it as being used | 707 // Determine if the expression is a variable proxy and mark it as being used |
708 // in an assignment or with a increment/decrement operator. This is currently | 708 // in an assignment or with a increment/decrement operator. This is currently |
709 // used on for the statically checking assignments to harmony const bindings. | 709 // used on for the statically checking assignments to harmony const bindings. |
710 void MarkAsLValue(Expression* expression); | 710 void MarkAsLValue(Expression* expression); |
711 | 711 |
712 // Strict mode validation of LValue expressions | 712 // Strict mode validation of LValue expressions |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
822 private: | 822 private: |
823 static const int kLiteralTypeSlot = 0; | 823 static const int kLiteralTypeSlot = 0; |
824 static const int kElementsSlot = 1; | 824 static const int kElementsSlot = 1; |
825 | 825 |
826 DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue); | 826 DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue); |
827 }; | 827 }; |
828 | 828 |
829 } } // namespace v8::internal | 829 } } // namespace v8::internal |
830 | 830 |
831 #endif // V8_PARSER_H_ | 831 #endif // V8_PARSER_H_ |
OLD | NEW |