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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 | 51 |
52 void PreParserTraits::ReportMessageAt(Scanner::Location location, | 52 void PreParserTraits::ReportMessageAt(Scanner::Location location, |
53 MessageTemplate::Template message, | 53 MessageTemplate::Template message, |
54 const AstRawString* arg, | 54 const AstRawString* arg, |
55 ParseErrorType error_type) { | 55 ParseErrorType error_type) { |
56 UNREACHABLE(); | 56 UNREACHABLE(); |
57 } | 57 } |
58 | 58 |
59 | 59 |
60 PreParserIdentifier PreParserTraits::GetSymbol(Scanner* scanner) { | 60 PreParserIdentifier PreParserTraits::GetSymbol(Scanner* scanner) { |
61 if (scanner->current_token() == Token::ENUM) { | 61 switch (scanner->current_token()) { |
62 return PreParserIdentifier::Enum(); | 62 case Token::ENUM: |
63 } else if (scanner->current_token() == Token::AWAIT) { | 63 return PreParserIdentifier::Enum(); |
64 return PreParserIdentifier::Await(); | 64 case Token::AWAIT: |
65 } else if (scanner->current_token() == | 65 return PreParserIdentifier::Await(); |
66 Token::FUTURE_STRICT_RESERVED_WORD) { | 66 case Token::FUTURE_STRICT_RESERVED_WORD: |
67 return PreParserIdentifier::FutureStrictReserved(); | 67 return PreParserIdentifier::FutureStrictReserved(); |
68 } else if (scanner->current_token() == Token::LET) { | 68 case Token::LET: |
69 return PreParserIdentifier::Let(); | 69 return PreParserIdentifier::Let(); |
70 } else if (scanner->current_token() == Token::STATIC) { | 70 case Token::STATIC: |
71 return PreParserIdentifier::Static(); | 71 return PreParserIdentifier::Static(); |
72 } else if (scanner->current_token() == Token::YIELD) { | 72 case Token::YIELD: |
73 return PreParserIdentifier::Yield(); | 73 return PreParserIdentifier::Yield(); |
74 } else if (scanner->current_token() == Token::ASYNC) { | 74 case Token::ASYNC: |
75 return PreParserIdentifier::Async(); | 75 return PreParserIdentifier::Async(); |
| 76 default: |
| 77 if (scanner->UnescapedLiteralMatches("eval", 4)) |
| 78 return PreParserIdentifier::Eval(); |
| 79 if (scanner->UnescapedLiteralMatches("arguments", 9)) |
| 80 return PreParserIdentifier::Arguments(); |
| 81 if (scanner->UnescapedLiteralMatches("undefined", 9)) |
| 82 return PreParserIdentifier::Undefined(); |
| 83 if (scanner->LiteralMatches("prototype", 9)) |
| 84 return PreParserIdentifier::Prototype(); |
| 85 if (scanner->LiteralMatches("constructor", 11)) |
| 86 return PreParserIdentifier::Constructor(); |
| 87 return PreParserIdentifier::Default(); |
76 } | 88 } |
77 if (scanner->UnescapedLiteralMatches("eval", 4)) { | |
78 return PreParserIdentifier::Eval(); | |
79 } | |
80 if (scanner->UnescapedLiteralMatches("arguments", 9)) { | |
81 return PreParserIdentifier::Arguments(); | |
82 } | |
83 if (scanner->UnescapedLiteralMatches("undefined", 9)) { | |
84 return PreParserIdentifier::Undefined(); | |
85 } | |
86 if (scanner->LiteralMatches("prototype", 9)) { | |
87 return PreParserIdentifier::Prototype(); | |
88 } | |
89 if (scanner->LiteralMatches("constructor", 11)) { | |
90 return PreParserIdentifier::Constructor(); | |
91 } | |
92 return PreParserIdentifier::Default(); | |
93 } | 89 } |
94 | 90 |
95 | 91 |
96 PreParserExpression PreParserTraits::ExpressionFromString( | 92 PreParserExpression PreParserTraits::ExpressionFromString( |
97 int pos, Scanner* scanner, PreParserFactory* factory) { | 93 int pos, Scanner* scanner, PreParserFactory* factory) { |
98 if (scanner->UnescapedLiteralMatches("use strict", 10)) { | 94 if (scanner->UnescapedLiteralMatches("use strict", 10)) { |
99 return PreParserExpression::UseStrictStringLiteral(); | 95 return PreParserExpression::UseStrictStringLiteral(); |
100 } | 96 } |
101 return PreParserExpression::StringLiteral(); | 97 return PreParserExpression::StringLiteral(); |
102 } | 98 } |
(...skipping 1203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1306 | 1302 |
1307 body->Add(PreParserStatement::ExpressionStatement(return_value), zone()); | 1303 body->Add(PreParserStatement::ExpressionStatement(return_value), zone()); |
1308 } | 1304 } |
1309 | 1305 |
1310 #undef CHECK_OK | 1306 #undef CHECK_OK |
1311 #undef CHECK_OK_CUSTOM | 1307 #undef CHECK_OK_CUSTOM |
1312 | 1308 |
1313 | 1309 |
1314 } // namespace internal | 1310 } // namespace internal |
1315 } // namespace v8 | 1311 } // namespace v8 |
OLD | NEW |