| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 <cmath> | 5 #include <cmath> |
| 6 | 6 |
| 7 #include "src/allocation.h" | 7 #include "src/allocation.h" |
| 8 #include "src/base/logging.h" | 8 #include "src/base/logging.h" |
| 9 #include "src/conversions-inl.h" | 9 #include "src/conversions-inl.h" |
| 10 #include "src/conversions.h" | 10 #include "src/conversions.h" |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 if (allow_harmony_restrictive_declarations()) { | 193 if (allow_harmony_restrictive_declarations()) { |
| 194 ReportMessageAt(scanner()->location(), | 194 ReportMessageAt(scanner()->location(), |
| 195 MessageTemplate::kGeneratorInLegacyContext); | 195 MessageTemplate::kGeneratorInLegacyContext); |
| 196 *ok = false; | 196 *ok = false; |
| 197 return Statement::Default(); | 197 return Statement::Default(); |
| 198 } | 198 } |
| 199 } | 199 } |
| 200 return ParseHoistableDeclaration(pos, flags, nullptr, false, ok); | 200 return ParseHoistableDeclaration(pos, flags, nullptr, false, ok); |
| 201 } | 201 } |
| 202 | 202 |
| 203 PreParser::Statement PreParser::ParseSwitchStatement( | |
| 204 ZoneList<const AstRawString*>* labels, bool* ok) { | |
| 205 // SwitchStatement :: | |
| 206 // 'switch' '(' Expression ')' '{' CaseClause* '}' | |
| 207 | |
| 208 Expect(Token::SWITCH, CHECK_OK); | |
| 209 Expect(Token::LPAREN, CHECK_OK); | |
| 210 ParseExpression(true, CHECK_OK); | |
| 211 Expect(Token::RPAREN, CHECK_OK); | |
| 212 | |
| 213 { | |
| 214 BlockState cases_block_state(&scope_state_); | |
| 215 Expect(Token::LBRACE, CHECK_OK); | |
| 216 Token::Value token = peek(); | |
| 217 while (token != Token::RBRACE) { | |
| 218 if (token == Token::CASE) { | |
| 219 Expect(Token::CASE, CHECK_OK); | |
| 220 ParseExpression(true, CHECK_OK); | |
| 221 } else { | |
| 222 Expect(Token::DEFAULT, CHECK_OK); | |
| 223 } | |
| 224 Expect(Token::COLON, CHECK_OK); | |
| 225 token = peek(); | |
| 226 Statement statement = Statement::Jump(); | |
| 227 while (token != Token::CASE && | |
| 228 token != Token::DEFAULT && | |
| 229 token != Token::RBRACE) { | |
| 230 statement = ParseStatementListItem(CHECK_OK); | |
| 231 token = peek(); | |
| 232 } | |
| 233 } | |
| 234 } | |
| 235 Expect(Token::RBRACE, ok); | |
| 236 return Statement::Default(); | |
| 237 } | |
| 238 | |
| 239 PreParser::Statement PreParser::ParseForStatement( | 203 PreParser::Statement PreParser::ParseForStatement( |
| 240 ZoneList<const AstRawString*>* labels, bool* ok) { | 204 ZoneList<const AstRawString*>* labels, bool* ok) { |
| 241 // ForStatement :: | 205 // ForStatement :: |
| 242 // 'for' '(' Expression? ';' Expression? ';' Expression? ')' Statement | 206 // 'for' '(' Expression? ';' Expression? ';' Expression? ')' Statement |
| 243 | 207 |
| 244 // Create an in-between scope for let-bound iteration variables. | 208 // Create an in-between scope for let-bound iteration variables. |
| 245 bool has_lexical = false; | 209 bool has_lexical = false; |
| 246 | 210 |
| 247 BlockState block_state(&scope_state_); | 211 BlockState block_state(&scope_state_); |
| 248 Expect(Token::FOR, CHECK_OK); | 212 Expect(Token::FOR, CHECK_OK); |
| (...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 611 | 575 |
| 612 body->Add(PreParserStatement::ExpressionStatement(return_value), zone()); | 576 body->Add(PreParserStatement::ExpressionStatement(return_value), zone()); |
| 613 } | 577 } |
| 614 | 578 |
| 615 #undef CHECK_OK | 579 #undef CHECK_OK |
| 616 #undef CHECK_OK_CUSTOM | 580 #undef CHECK_OK_CUSTOM |
| 617 | 581 |
| 618 | 582 |
| 619 } // namespace internal | 583 } // namespace internal |
| 620 } // namespace v8 | 584 } // namespace v8 |
| OLD | NEW |