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