OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
652 | 652 |
653 Expect(i::Token::WHILE, CHECK_OK); | 653 Expect(i::Token::WHILE, CHECK_OK); |
654 Expect(i::Token::LPAREN, CHECK_OK); | 654 Expect(i::Token::LPAREN, CHECK_OK); |
655 ParseExpression(true, CHECK_OK); | 655 ParseExpression(true, CHECK_OK); |
656 Expect(i::Token::RPAREN, CHECK_OK); | 656 Expect(i::Token::RPAREN, CHECK_OK); |
657 ParseStatement(ok); | 657 ParseStatement(ok); |
658 return Statement::Default(); | 658 return Statement::Default(); |
659 } | 659 } |
660 | 660 |
661 | 661 |
| 662 bool PreParser::CheckInOrOf() { |
| 663 if (peek() == i::Token::IN || |
| 664 (allow_for_of() && |
| 665 scanner_->is_next_contextual_keyword(v8::internal::CStrVector("of")))) { |
| 666 Next(); |
| 667 return true; |
| 668 } |
| 669 return false; |
| 670 } |
| 671 |
| 672 |
662 PreParser::Statement PreParser::ParseForStatement(bool* ok) { | 673 PreParser::Statement PreParser::ParseForStatement(bool* ok) { |
663 // ForStatement :: | 674 // ForStatement :: |
664 // 'for' '(' Expression? ';' Expression? ';' Expression? ')' Statement | 675 // 'for' '(' Expression? ';' Expression? ';' Expression? ')' Statement |
665 | 676 |
666 Expect(i::Token::FOR, CHECK_OK); | 677 Expect(i::Token::FOR, CHECK_OK); |
667 Expect(i::Token::LPAREN, CHECK_OK); | 678 Expect(i::Token::LPAREN, CHECK_OK); |
668 if (peek() != i::Token::SEMICOLON) { | 679 if (peek() != i::Token::SEMICOLON) { |
669 if (peek() == i::Token::VAR || peek() == i::Token::CONST || | 680 if (peek() == i::Token::VAR || peek() == i::Token::CONST || |
670 peek() == i::Token::LET) { | 681 peek() == i::Token::LET) { |
671 bool is_let = peek() == i::Token::LET; | 682 bool is_let = peek() == i::Token::LET; |
672 int decl_count; | 683 int decl_count; |
673 VariableDeclarationProperties decl_props = kHasNoInitializers; | 684 VariableDeclarationProperties decl_props = kHasNoInitializers; |
674 ParseVariableDeclarations( | 685 ParseVariableDeclarations( |
675 kForStatement, &decl_props, &decl_count, CHECK_OK); | 686 kForStatement, &decl_props, &decl_count, CHECK_OK); |
676 bool accept_IN = decl_count == 1 && | 687 bool accept_IN = decl_count == 1 && |
677 !(is_let && decl_props == kHasInitializers); | 688 !(is_let && decl_props == kHasInitializers); |
678 if (peek() == i::Token::IN && accept_IN) { | 689 if (accept_IN && CheckInOrOf()) { |
679 Expect(i::Token::IN, CHECK_OK); | |
680 ParseExpression(true, CHECK_OK); | 690 ParseExpression(true, CHECK_OK); |
681 Expect(i::Token::RPAREN, CHECK_OK); | 691 Expect(i::Token::RPAREN, CHECK_OK); |
682 | 692 |
683 ParseStatement(CHECK_OK); | 693 ParseStatement(CHECK_OK); |
684 return Statement::Default(); | 694 return Statement::Default(); |
685 } | 695 } |
686 } else { | 696 } else { |
687 ParseExpression(false, CHECK_OK); | 697 ParseExpression(false, CHECK_OK); |
688 if (peek() == i::Token::IN) { | 698 if (CheckInOrOf()) { |
689 Expect(i::Token::IN, CHECK_OK); | |
690 ParseExpression(true, CHECK_OK); | 699 ParseExpression(true, CHECK_OK); |
691 Expect(i::Token::RPAREN, CHECK_OK); | 700 Expect(i::Token::RPAREN, CHECK_OK); |
692 | 701 |
693 ParseStatement(CHECK_OK); | 702 ParseStatement(CHECK_OK); |
694 return Statement::Default(); | 703 return Statement::Default(); |
695 } | 704 } |
696 } | 705 } |
697 } | 706 } |
698 | 707 |
699 // Parsed initializer at this point. | 708 // Parsed initializer at this point. |
(...skipping 1110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1810 backing_store_.Add(static_cast<byte>((ascii_length >> 14) | 0x80u)); | 1819 backing_store_.Add(static_cast<byte>((ascii_length >> 14) | 0x80u)); |
1811 } | 1820 } |
1812 backing_store_.Add(static_cast<byte>((ascii_length >> 7) | 0x80u)); | 1821 backing_store_.Add(static_cast<byte>((ascii_length >> 7) | 0x80u)); |
1813 } | 1822 } |
1814 backing_store_.Add(static_cast<byte>(ascii_length & 0x7f)); | 1823 backing_store_.Add(static_cast<byte>(ascii_length & 0x7f)); |
1815 | 1824 |
1816 backing_store_.AddBlock(bytes); | 1825 backing_store_.AddBlock(bytes); |
1817 return backing_store_.EndSequence().start(); | 1826 return backing_store_.EndSequence().start(); |
1818 } | 1827 } |
1819 } } // v8::preparser | 1828 } } // v8::preparser |
OLD | NEW |