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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 | 43 |
44 | 44 |
45 PreParserIdentifier PreParserTraits::GetSymbol(Scanner* scanner) { | 45 PreParserIdentifier PreParserTraits::GetSymbol(Scanner* scanner) { |
46 if (scanner->current_token() == Token::FUTURE_RESERVED_WORD) { | 46 if (scanner->current_token() == Token::FUTURE_RESERVED_WORD) { |
47 return PreParserIdentifier::FutureReserved(); | 47 return PreParserIdentifier::FutureReserved(); |
48 } else if (scanner->current_token() == | 48 } else if (scanner->current_token() == |
49 Token::FUTURE_STRICT_RESERVED_WORD) { | 49 Token::FUTURE_STRICT_RESERVED_WORD) { |
50 return PreParserIdentifier::FutureStrictReserved(); | 50 return PreParserIdentifier::FutureStrictReserved(); |
51 } else if (scanner->current_token() == Token::LET) { | 51 } else if (scanner->current_token() == Token::LET) { |
52 return PreParserIdentifier::Let(); | 52 return PreParserIdentifier::Let(); |
| 53 } else if (scanner->current_token() == Token::STATIC) { |
| 54 return PreParserIdentifier::Static(); |
53 } else if (scanner->current_token() == Token::YIELD) { | 55 } else if (scanner->current_token() == Token::YIELD) { |
54 return PreParserIdentifier::Yield(); | 56 return PreParserIdentifier::Yield(); |
55 } | 57 } |
56 if (scanner->UnescapedLiteralMatches("eval", 4)) { | 58 if (scanner->UnescapedLiteralMatches("eval", 4)) { |
57 return PreParserIdentifier::Eval(); | 59 return PreParserIdentifier::Eval(); |
58 } | 60 } |
59 if (scanner->UnescapedLiteralMatches("arguments", 9)) { | 61 if (scanner->UnescapedLiteralMatches("arguments", 9)) { |
60 return PreParserIdentifier::Arguments(); | 62 return PreParserIdentifier::Arguments(); |
61 } | 63 } |
62 if (scanner->LiteralMatches("prototype", 9)) { | 64 if (scanner->LiteralMatches("prototype", 9)) { |
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
484 bool starts_with_identifier = peek_any_identifier(); | 486 bool starts_with_identifier = peek_any_identifier(); |
485 Expression expr = ParseExpression(true, CHECK_OK); | 487 Expression expr = ParseExpression(true, CHECK_OK); |
486 // Even if the expression starts with an identifier, it is not necessarily an | 488 // Even if the expression starts with an identifier, it is not necessarily an |
487 // identifier. For example, "foo + bar" starts with an identifier but is not | 489 // identifier. For example, "foo + bar" starts with an identifier but is not |
488 // an identifier. | 490 // an identifier. |
489 if (starts_with_identifier && expr.IsIdentifier() && peek() == Token::COLON) { | 491 if (starts_with_identifier && expr.IsIdentifier() && peek() == Token::COLON) { |
490 // Expression is a single identifier, and not, e.g., a parenthesized | 492 // Expression is a single identifier, and not, e.g., a parenthesized |
491 // identifier. | 493 // identifier. |
492 DCHECK(!expr.AsIdentifier().IsFutureReserved()); | 494 DCHECK(!expr.AsIdentifier().IsFutureReserved()); |
493 DCHECK(strict_mode() == SLOPPY || | 495 DCHECK(strict_mode() == SLOPPY || |
494 (!expr.AsIdentifier().IsFutureStrictReserved() && | 496 !IsFutureStrictReserved(expr.AsIdentifier())); |
495 !expr.AsIdentifier().IsYield())); | |
496 Consume(Token::COLON); | 497 Consume(Token::COLON); |
497 return ParseStatement(ok); | 498 return ParseStatement(ok); |
498 // Preparsing is disabled for extensions (because the extension details | 499 // Preparsing is disabled for extensions (because the extension details |
499 // aren't passed to lazily compiled functions), so we don't | 500 // aren't passed to lazily compiled functions), so we don't |
500 // accept "native function" in the preparser. | 501 // accept "native function" in the preparser. |
501 } | 502 } |
502 // Parsed expression statement. | 503 // Parsed expression statement. |
503 ExpectSemicolon(CHECK_OK); | 504 ExpectSemicolon(CHECK_OK); |
504 return Statement::ExpressionStatement(expr); | 505 return Statement::ExpressionStatement(expr); |
505 } | 506 } |
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
939 ParseIdentifier(kAllowEvalOrArguments, CHECK_OK); | 940 ParseIdentifier(kAllowEvalOrArguments, CHECK_OK); |
940 ParseArguments(ok); | 941 ParseArguments(ok); |
941 | 942 |
942 return Expression::Default(); | 943 return Expression::Default(); |
943 } | 944 } |
944 | 945 |
945 #undef CHECK_OK | 946 #undef CHECK_OK |
946 | 947 |
947 | 948 |
948 } } // v8::internal | 949 } } // v8::internal |
OLD | NEW |