| 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 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 514 } | 514 } |
| 515 ~ParsingModeScope() { | 515 ~ParsingModeScope() { |
| 516 parser_->mode_ = old_mode_; | 516 parser_->mode_ = old_mode_; |
| 517 } | 517 } |
| 518 | 518 |
| 519 private: | 519 private: |
| 520 Parser* parser_; | 520 Parser* parser_; |
| 521 Mode old_mode_; | 521 Mode old_mode_; |
| 522 }; | 522 }; |
| 523 | 523 |
| 524 virtual bool is_classic_mode() { |
| 525 return top_scope_->is_classic_mode(); |
| 526 } |
| 527 |
| 524 // Returns NULL if parsing failed. | 528 // Returns NULL if parsing failed. |
| 525 FunctionLiteral* ParseProgram(); | 529 FunctionLiteral* ParseProgram(); |
| 526 | 530 |
| 527 FunctionLiteral* ParseLazy(); | 531 FunctionLiteral* ParseLazy(); |
| 528 FunctionLiteral* ParseLazy(Utf16CharacterStream* source); | 532 FunctionLiteral* ParseLazy(Utf16CharacterStream* source); |
| 529 | 533 |
| 530 Isolate* isolate() { return isolate_; } | 534 Isolate* isolate() { return isolate_; } |
| 531 Zone* zone() const { return zone_; } | 535 Zone* zone() const { return zone_; } |
| 532 CompilationInfo* info() const { return info_; } | 536 CompilationInfo* info() const { return info_; } |
| 533 | 537 |
| 534 // Called by ParseProgram after setting up the scanner. | 538 // Called by ParseProgram after setting up the scanner. |
| 535 FunctionLiteral* DoParseProgram(CompilationInfo* info, | 539 FunctionLiteral* DoParseProgram(CompilationInfo* info, |
| 536 Handle<String> source); | 540 Handle<String> source); |
| 537 | 541 |
| 538 // Report syntax error | 542 // Report syntax error |
| 539 void ReportUnexpectedToken(Token::Value token); | |
| 540 void ReportInvalidPreparseData(Handle<String> name, bool* ok); | 543 void ReportInvalidPreparseData(Handle<String> name, bool* ok); |
| 541 void ReportMessage(const char* message, Vector<const char*> args); | 544 void ReportMessage(const char* message, Vector<const char*> args); |
| 542 void ReportMessage(const char* message, Vector<Handle<String> > args); | 545 void ReportMessage(const char* message, Vector<Handle<String> > args); |
| 543 void ReportMessageAt(Scanner::Location location, const char* type) { | 546 void ReportMessageAt(Scanner::Location location, const char* type) { |
| 544 ReportMessageAt(location, type, Vector<const char*>::empty()); | 547 ReportMessageAt(location, type, Vector<const char*>::empty()); |
| 545 } | 548 } |
| 546 void ReportMessageAt(Scanner::Location loc, | 549 void ReportMessageAt(Scanner::Location loc, |
| 547 const char* message, | 550 const char* message, |
| 548 Vector<const char*> args); | 551 Vector<const char*> args); |
| 549 void ReportMessageAt(Scanner::Location loc, | 552 void ReportMessageAt(Scanner::Location loc, |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 638 Expression* ParseObjectLiteral(bool* ok); | 641 Expression* ParseObjectLiteral(bool* ok); |
| 639 Expression* ParseRegExpLiteral(bool seen_equal, bool* ok); | 642 Expression* ParseRegExpLiteral(bool seen_equal, bool* ok); |
| 640 | 643 |
| 641 // Initialize the components of a for-in / for-of statement. | 644 // Initialize the components of a for-in / for-of statement. |
| 642 void InitializeForEachStatement(ForEachStatement* stmt, | 645 void InitializeForEachStatement(ForEachStatement* stmt, |
| 643 Expression* each, | 646 Expression* each, |
| 644 Expression* subject, | 647 Expression* subject, |
| 645 Statement* body); | 648 Statement* body); |
| 646 | 649 |
| 647 ZoneList<Expression*>* ParseArguments(bool* ok); | 650 ZoneList<Expression*>* ParseArguments(bool* ok); |
| 648 FunctionLiteral* ParseFunctionLiteral(Handle<String> var_name, | 651 FunctionLiteral* ParseFunctionLiteral( |
| 649 bool name_is_reserved, | 652 Handle<String> name, |
| 650 bool is_generator, | 653 Scanner::Location function_name_location, |
| 651 int function_token_position, | 654 bool name_is_strict_reserved, |
| 652 FunctionLiteral::FunctionType type, | 655 bool is_generator, |
| 653 bool* ok); | 656 int function_token_position, |
| 654 | 657 FunctionLiteral::FunctionType type, |
| 658 bool* ok); |
| 655 | 659 |
| 656 // Magical syntax support. | 660 // Magical syntax support. |
| 657 Expression* ParseV8Intrinsic(bool* ok); | 661 Expression* ParseV8Intrinsic(bool* ok); |
| 658 | 662 |
| 659 bool is_generator() const { return current_function_state_->is_generator(); } | 663 bool is_generator() const { return current_function_state_->is_generator(); } |
| 660 | 664 |
| 661 bool CheckInOrOf(bool accept_OF, ForEachStatement::VisitMode* visit_mode); | 665 bool CheckInOrOf(bool accept_OF, ForEachStatement::VisitMode* visit_mode); |
| 662 | 666 |
| 663 Handle<String> LiteralString(PretenureFlag tenured) { | 667 Handle<String> LiteralString(PretenureFlag tenured) { |
| 664 if (scanner().is_literal_ascii()) { | 668 if (scanner().is_literal_ascii()) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 679 scanner().next_literal_utf16_string(), tenured); | 683 scanner().next_literal_utf16_string(), tenured); |
| 680 } | 684 } |
| 681 } | 685 } |
| 682 | 686 |
| 683 Handle<String> GetSymbol(); | 687 Handle<String> GetSymbol(); |
| 684 | 688 |
| 685 // Get odd-ball literals. | 689 // Get odd-ball literals. |
| 686 Literal* GetLiteralUndefined(int position); | 690 Literal* GetLiteralUndefined(int position); |
| 687 Literal* GetLiteralTheHole(int position); | 691 Literal* GetLiteralTheHole(int position); |
| 688 | 692 |
| 689 Handle<String> ParseIdentifier(bool* ok); | 693 Handle<String> ParseIdentifier(AllowEvalOrArgumentsAsIdentifier, bool* ok); |
| 690 Handle<String> ParseIdentifierOrStrictReservedWord( | 694 Handle<String> ParseIdentifierOrStrictReservedWord( |
| 691 bool* is_strict_reserved, bool* ok); | 695 bool* is_strict_reserved, bool* ok); |
| 692 Handle<String> ParseIdentifierName(bool* ok); | 696 Handle<String> ParseIdentifierName(bool* ok); |
| 693 Handle<String> ParseIdentifierNameOrGetOrSet(bool* is_get, | 697 Handle<String> ParseIdentifierNameOrGetOrSet(bool* is_get, |
| 694 bool* is_set, | 698 bool* is_set, |
| 695 bool* ok); | 699 bool* ok); |
| 696 | 700 |
| 697 // Determine if the expression is a variable proxy and mark it as being used | 701 // Determine if the expression is a variable proxy and mark it as being used |
| 698 // in an assignment or with a increment/decrement operator. This is currently | 702 // in an assignment or with a increment/decrement operator. This is currently |
| 699 // used on for the statically checking assignments to harmony const bindings. | 703 // used on for the statically checking assignments to harmony const bindings. |
| 700 void MarkAsLValue(Expression* expression); | 704 void MarkAsLValue(Expression* expression); |
| 701 | 705 |
| 702 // Strict mode validation of LValue expressions | 706 // Strict mode validation of LValue expressions |
| 703 void CheckStrictModeLValue(Expression* expression, | 707 void CheckStrictModeLValue(Expression* expression, |
| 704 const char* error, | |
| 705 bool* ok); | 708 bool* ok); |
| 706 | 709 |
| 707 // For harmony block scoping mode: Check if the scope has conflicting var/let | 710 // For harmony block scoping mode: Check if the scope has conflicting var/let |
| 708 // declarations from different scopes. It covers for example | 711 // declarations from different scopes. It covers for example |
| 709 // | 712 // |
| 710 // function f() { { { var x; } let x; } } | 713 // function f() { { { var x; } let x; } } |
| 711 // function g() { { var x; let x; } } | 714 // function g() { { var x; let x; } } |
| 712 // | 715 // |
| 713 // The var declarations are hoisted to the function scope, but originate from | 716 // The var declarations are hoisted to the function scope, but originate from |
| 714 // a scope where the name has also been let bound or the var declaration is | 717 // a scope where the name has also been let bound or the var declaration is |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 813 private: | 816 private: |
| 814 static const int kLiteralTypeSlot = 0; | 817 static const int kLiteralTypeSlot = 0; |
| 815 static const int kElementsSlot = 1; | 818 static const int kElementsSlot = 1; |
| 816 | 819 |
| 817 DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue); | 820 DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue); |
| 818 }; | 821 }; |
| 819 | 822 |
| 820 } } // namespace v8::internal | 823 } } // namespace v8::internal |
| 821 | 824 |
| 822 #endif // V8_PARSER_H_ | 825 #endif // V8_PARSER_H_ |
| OLD | NEW |