Chromium Code Reviews| 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 1801 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1812 case Token::DO: | 1812 case Token::DO: |
| 1813 return ParseDoWhileStatement(labels, ok); | 1813 return ParseDoWhileStatement(labels, ok); |
| 1814 | 1814 |
| 1815 case Token::WHILE: | 1815 case Token::WHILE: |
| 1816 return ParseWhileStatement(labels, ok); | 1816 return ParseWhileStatement(labels, ok); |
| 1817 | 1817 |
| 1818 case Token::FOR: | 1818 case Token::FOR: |
| 1819 return ParseForStatement(labels, ok); | 1819 return ParseForStatement(labels, ok); |
| 1820 | 1820 |
| 1821 case Token::CONTINUE: | 1821 case Token::CONTINUE: |
| 1822 return ParseContinueStatement(ok); | 1822 if (labels == NULL) { |
|
rossberg
2015/04/14 20:19:49
To avoid the code duplication, how about introduci
conradw
2015/04/15 11:40:03
Done, with the caveat that the ordering is kind of
| |
| 1823 return ParseContinueStatement(ok); | |
| 1824 } else { | |
| 1825 Block* result = | |
| 1826 factory()->NewBlock(labels, 1, false, RelocInfo::kNoPosition); | |
| 1827 Target target(&this->target_stack_, result); | |
| 1828 Statement* statement = ParseContinueStatement(CHECK_OK); | |
| 1829 if (result) result->AddStatement(statement, zone()); | |
| 1830 return result; | |
| 1831 } | |
| 1823 | 1832 |
| 1824 case Token::BREAK: | 1833 case Token::BREAK: |
| 1825 return ParseBreakStatement(labels, ok); | 1834 if (labels == NULL) { |
| 1835 return ParseBreakStatement(labels, ok); | |
| 1836 } else { | |
| 1837 Block* result = | |
| 1838 factory()->NewBlock(labels, 1, false, RelocInfo::kNoPosition); | |
| 1839 Target target(&this->target_stack_, result); | |
| 1840 Statement* statement = ParseBreakStatement(labels, CHECK_OK); | |
| 1841 if (result) result->AddStatement(statement, zone()); | |
| 1842 return result; | |
| 1843 } | |
| 1826 | 1844 |
| 1827 case Token::RETURN: | 1845 case Token::RETURN: |
| 1828 return ParseReturnStatement(ok); | 1846 if (labels == NULL) { |
| 1847 return ParseReturnStatement(ok); | |
| 1848 } else { | |
| 1849 Block* result = | |
| 1850 factory()->NewBlock(labels, 1, false, RelocInfo::kNoPosition); | |
| 1851 Target target(&this->target_stack_, result); | |
| 1852 Statement* statement = ParseReturnStatement(CHECK_OK); | |
| 1853 if (result) result->AddStatement(statement, zone()); | |
| 1854 return result; | |
| 1855 } | |
| 1829 | 1856 |
| 1830 case Token::WITH: | 1857 case Token::WITH: |
| 1831 return ParseWithStatement(labels, ok); | 1858 return ParseWithStatement(labels, ok); |
| 1832 | 1859 |
| 1833 case Token::SWITCH: | 1860 case Token::SWITCH: |
| 1834 return ParseSwitchStatement(labels, ok); | 1861 return ParseSwitchStatement(labels, ok); |
| 1835 | 1862 |
| 1836 case Token::THROW: | 1863 case Token::THROW: |
| 1837 return ParseThrowStatement(ok); | 1864 if (labels == NULL) { |
| 1865 return ParseThrowStatement(ok); | |
| 1866 } else { | |
| 1867 Block* result = | |
| 1868 factory()->NewBlock(labels, 1, false, RelocInfo::kNoPosition); | |
| 1869 Target target(&this->target_stack_, result); | |
| 1870 Statement* statement = ParseThrowStatement(CHECK_OK); | |
| 1871 if (result) result->AddStatement(statement, zone()); | |
| 1872 return result; | |
| 1873 } | |
| 1838 | 1874 |
| 1839 case Token::TRY: { | 1875 case Token::TRY: { |
| 1840 // NOTE: It is somewhat complicated to have labels on | 1876 // NOTE: It is somewhat complicated to have labels on |
| 1841 // try-statements. When breaking out of a try-finally statement, | 1877 // try-statements. When breaking out of a try-finally statement, |
| 1842 // one must take great care not to treat it as a | 1878 // one must take great care not to treat it as a |
| 1843 // fall-through. It is much easier just to wrap the entire | 1879 // fall-through. It is much easier just to wrap the entire |
| 1844 // try-statement in a statement block and put the labels there | 1880 // try-statement in a statement block and put the labels there |
| 1845 Block* result = | 1881 Block* result = |
| 1846 factory()->NewBlock(labels, 1, false, RelocInfo::kNoPosition); | 1882 factory()->NewBlock(labels, 1, false, RelocInfo::kNoPosition); |
| 1847 Target target(&this->target_stack_, result); | 1883 Target target(&this->target_stack_, result); |
| (...skipping 990 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2838 ReportMessage("multiple_defaults_in_switch"); | 2874 ReportMessage("multiple_defaults_in_switch"); |
| 2839 *ok = false; | 2875 *ok = false; |
| 2840 return NULL; | 2876 return NULL; |
| 2841 } | 2877 } |
| 2842 *default_seen_ptr = true; | 2878 *default_seen_ptr = true; |
| 2843 } | 2879 } |
| 2844 Expect(Token::COLON, CHECK_OK); | 2880 Expect(Token::COLON, CHECK_OK); |
| 2845 int pos = position(); | 2881 int pos = position(); |
| 2846 ZoneList<Statement*>* statements = | 2882 ZoneList<Statement*>* statements = |
| 2847 new(zone()) ZoneList<Statement*>(5, zone()); | 2883 new(zone()) ZoneList<Statement*>(5, zone()); |
| 2884 Statement* stat = NULL; | |
| 2848 while (peek() != Token::CASE && | 2885 while (peek() != Token::CASE && |
| 2849 peek() != Token::DEFAULT && | 2886 peek() != Token::DEFAULT && |
| 2850 peek() != Token::RBRACE) { | 2887 peek() != Token::RBRACE) { |
| 2851 Statement* stat = ParseStatementListItem(CHECK_OK); | 2888 stat = ParseStatementListItem(CHECK_OK); |
| 2852 statements->Add(stat, zone()); | 2889 statements->Add(stat, zone()); |
| 2853 } | 2890 } |
| 2854 | 2891 if (is_strong(language_mode()) && stat != NULL && |
| 2892 !stat->IsStrongSwitchTerminatingStatement()) { | |
| 2893 ReportMessageAt(scanner()->location(), "strong_unterminated_switch"); | |
| 2894 *ok = false; | |
| 2895 return NULL; | |
| 2896 } | |
| 2855 return factory()->NewCaseClause(label, statements, pos); | 2897 return factory()->NewCaseClause(label, statements, pos); |
| 2856 } | 2898 } |
| 2857 | 2899 |
| 2858 | 2900 |
| 2859 SwitchStatement* Parser::ParseSwitchStatement( | 2901 SwitchStatement* Parser::ParseSwitchStatement( |
| 2860 ZoneList<const AstRawString*>* labels, bool* ok) { | 2902 ZoneList<const AstRawString*>* labels, bool* ok) { |
| 2861 // SwitchStatement :: | 2903 // SwitchStatement :: |
| 2862 // 'switch' '(' Expression ')' '{' CaseClause* '}' | 2904 // 'switch' '(' Expression ')' '{' CaseClause* '}' |
| 2863 | 2905 |
| 2864 SwitchStatement* statement = | 2906 SwitchStatement* statement = |
| (...skipping 2908 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5773 | 5815 |
| 5774 Expression* Parser::SpreadCallNew(Expression* function, | 5816 Expression* Parser::SpreadCallNew(Expression* function, |
| 5775 ZoneList<v8::internal::Expression*>* args, | 5817 ZoneList<v8::internal::Expression*>* args, |
| 5776 int pos) { | 5818 int pos) { |
| 5777 args->InsertAt(0, function, zone()); | 5819 args->InsertAt(0, function, zone()); |
| 5778 | 5820 |
| 5779 return factory()->NewCallRuntime( | 5821 return factory()->NewCallRuntime( |
| 5780 ast_value_factory()->reflect_construct_string(), NULL, args, pos); | 5822 ast_value_factory()->reflect_construct_string(), NULL, args, pos); |
| 5781 } | 5823 } |
| 5782 } } // namespace v8::internal | 5824 } } // namespace v8::internal |
| OLD | NEW |