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 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/api.h" | 7 #include "src/api.h" |
8 #include "src/ast.h" | 8 #include "src/ast.h" |
9 #include "src/bailout-reason.h" | 9 #include "src/bailout-reason.h" |
10 #include "src/base/platform/platform.h" | 10 #include "src/base/platform/platform.h" |
(...skipping 2740 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2751 with_scope->set_start_position(scanner()->peek_location().beg_pos); | 2751 with_scope->set_start_position(scanner()->peek_location().beg_pos); |
2752 stmt = ParseSubStatement(labels, CHECK_OK); | 2752 stmt = ParseSubStatement(labels, CHECK_OK); |
2753 with_scope->set_end_position(scanner()->location().end_pos); | 2753 with_scope->set_end_position(scanner()->location().end_pos); |
2754 } | 2754 } |
2755 return factory()->NewWithStatement(with_scope, expr, stmt, pos); | 2755 return factory()->NewWithStatement(with_scope, expr, stmt, pos); |
2756 } | 2756 } |
2757 | 2757 |
2758 | 2758 |
2759 CaseClause* Parser::ParseCaseClause(bool* default_seen_ptr, bool* ok) { | 2759 CaseClause* Parser::ParseCaseClause(bool* default_seen_ptr, bool* ok) { |
2760 // CaseClause :: | 2760 // CaseClause :: |
2761 // 'case' Expression ':' Statement* | 2761 // 'case' Expression ':' StatementList |
2762 // 'default' ':' Statement* | 2762 // 'default' ':' StatementList |
2763 | 2763 |
2764 Expression* label = NULL; // NULL expression indicates default case | 2764 Expression* label = NULL; // NULL expression indicates default case |
2765 if (peek() == Token::CASE) { | 2765 if (peek() == Token::CASE) { |
2766 Expect(Token::CASE, CHECK_OK); | 2766 Expect(Token::CASE, CHECK_OK); |
2767 label = ParseExpression(true, CHECK_OK); | 2767 label = ParseExpression(true, CHECK_OK); |
2768 } else { | 2768 } else { |
2769 Expect(Token::DEFAULT, CHECK_OK); | 2769 Expect(Token::DEFAULT, CHECK_OK); |
2770 if (*default_seen_ptr) { | 2770 if (*default_seen_ptr) { |
2771 ReportMessage("multiple_defaults_in_switch"); | 2771 ReportMessage("multiple_defaults_in_switch"); |
2772 *ok = false; | 2772 *ok = false; |
2773 return NULL; | 2773 return NULL; |
2774 } | 2774 } |
2775 *default_seen_ptr = true; | 2775 *default_seen_ptr = true; |
2776 } | 2776 } |
2777 Expect(Token::COLON, CHECK_OK); | 2777 Expect(Token::COLON, CHECK_OK); |
2778 int pos = position(); | 2778 int pos = position(); |
2779 ZoneList<Statement*>* statements = | 2779 ZoneList<Statement*>* statements = |
2780 new(zone()) ZoneList<Statement*>(5, zone()); | 2780 new(zone()) ZoneList<Statement*>(5, zone()); |
2781 while (peek() != Token::CASE && | 2781 while (peek() != Token::CASE && |
2782 peek() != Token::DEFAULT && | 2782 peek() != Token::DEFAULT && |
2783 peek() != Token::RBRACE) { | 2783 peek() != Token::RBRACE) { |
2784 Statement* stat = ParseStatement(NULL, CHECK_OK); | 2784 Statement* stat = ParseStatementListItem(CHECK_OK); |
2785 statements->Add(stat, zone()); | 2785 statements->Add(stat, zone()); |
2786 } | 2786 } |
2787 | 2787 |
2788 return factory()->NewCaseClause(label, statements, pos); | 2788 return factory()->NewCaseClause(label, statements, pos); |
2789 } | 2789 } |
2790 | 2790 |
2791 | 2791 |
2792 SwitchStatement* Parser::ParseSwitchStatement( | 2792 SwitchStatement* Parser::ParseSwitchStatement( |
2793 ZoneList<const AstRawString*>* labels, bool* ok) { | 2793 ZoneList<const AstRawString*>* labels, bool* ok) { |
2794 // SwitchStatement :: | 2794 // SwitchStatement :: |
(...skipping 2713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5508 } else { | 5508 } else { |
5509 const uc16* data = reinterpret_cast<const uc16*>(raw_string->raw_data()); | 5509 const uc16* data = reinterpret_cast<const uc16*>(raw_string->raw_data()); |
5510 running_hash = StringHasher::ComputeRunningHash(running_hash, data, | 5510 running_hash = StringHasher::ComputeRunningHash(running_hash, data, |
5511 raw_string->length()); | 5511 raw_string->length()); |
5512 } | 5512 } |
5513 } | 5513 } |
5514 | 5514 |
5515 return running_hash; | 5515 return running_hash; |
5516 } | 5516 } |
5517 } } // namespace v8::internal | 5517 } } // namespace v8::internal |
OLD | NEW |