OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 bool PreParserTraits::is_classic_mode() const { | 58 bool PreParserTraits::is_classic_mode() const { |
59 return pre_parser_->scope_->language_mode() == CLASSIC_MODE; | 59 return pre_parser_->scope_->language_mode() == CLASSIC_MODE; |
60 } | 60 } |
61 | 61 |
62 | 62 |
63 bool PreParserTraits::is_generator() const { | 63 bool PreParserTraits::is_generator() const { |
64 return pre_parser_->scope_->is_generator(); | 64 return pre_parser_->scope_->is_generator(); |
65 } | 65 } |
66 | 66 |
67 | 67 |
| 68 int PreParserTraits::NextMaterializedLiteralIndex() { |
| 69 return pre_parser_->scope_->NextMaterializedLiteralIndex(); |
| 70 } |
| 71 |
| 72 |
68 void PreParserTraits::ReportMessageAt(Scanner::Location location, | 73 void PreParserTraits::ReportMessageAt(Scanner::Location location, |
69 const char* message, | 74 const char* message, |
70 Vector<const char*> args) { | 75 Vector<const char*> args) { |
71 ReportMessageAt(location.beg_pos, | 76 ReportMessageAt(location.beg_pos, |
72 location.end_pos, | 77 location.end_pos, |
73 message, | 78 message, |
74 args.length() > 0 ? args[0] : NULL); | 79 args.length() > 0 ? args[0] : NULL); |
75 } | 80 } |
76 | 81 |
77 | 82 |
(...skipping 1216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1294 // TODO(1240767): Consider allowing trailing comma. | 1299 // TODO(1240767): Consider allowing trailing comma. |
1295 if (peek() != Token::RBRACE) Expect(Token::COMMA, CHECK_OK); | 1300 if (peek() != Token::RBRACE) Expect(Token::COMMA, CHECK_OK); |
1296 } | 1301 } |
1297 Expect(Token::RBRACE, CHECK_OK); | 1302 Expect(Token::RBRACE, CHECK_OK); |
1298 | 1303 |
1299 scope_->NextMaterializedLiteralIndex(); | 1304 scope_->NextMaterializedLiteralIndex(); |
1300 return Expression::Default(); | 1305 return Expression::Default(); |
1301 } | 1306 } |
1302 | 1307 |
1303 | 1308 |
1304 PreParser::Expression PreParser::ParseRegExpLiteral(bool seen_equal, | |
1305 bool* ok) { | |
1306 if (!scanner()->ScanRegExpPattern(seen_equal)) { | |
1307 Next(); | |
1308 ReportMessageAt(scanner()->location(), "unterminated_regexp"); | |
1309 *ok = false; | |
1310 return Expression::Default(); | |
1311 } | |
1312 | |
1313 scope_->NextMaterializedLiteralIndex(); | |
1314 | |
1315 if (!scanner()->ScanRegExpFlags()) { | |
1316 Next(); | |
1317 ReportMessageAt(scanner()->location(), "invalid_regexp_flags"); | |
1318 *ok = false; | |
1319 return Expression::Default(); | |
1320 } | |
1321 Next(); | |
1322 return Expression::Default(); | |
1323 } | |
1324 | |
1325 | |
1326 PreParser::Arguments PreParser::ParseArguments(bool* ok) { | 1309 PreParser::Arguments PreParser::ParseArguments(bool* ok) { |
1327 // Arguments :: | 1310 // Arguments :: |
1328 // '(' (AssignmentExpression)*[','] ')' | 1311 // '(' (AssignmentExpression)*[','] ')' |
1329 | 1312 |
1330 Expect(Token::LPAREN, ok); | 1313 Expect(Token::LPAREN, ok); |
1331 if (!*ok) return -1; | 1314 if (!*ok) return -1; |
1332 bool done = (peek() == Token::RPAREN); | 1315 bool done = (peek() == Token::RPAREN); |
1333 int argc = 0; | 1316 int argc = 0; |
1334 while (!done) { | 1317 while (!done) { |
1335 ParseAssignmentExpression(true, ok); | 1318 ParseAssignmentExpression(true, ok); |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1510 !scanner()->literal_contains_escapes() && | 1493 !scanner()->literal_contains_escapes() && |
1511 !strncmp(scanner()->literal_ascii_string().start(), kUseStrictChars, | 1494 !strncmp(scanner()->literal_ascii_string().start(), kUseStrictChars, |
1512 kUseStrictLength)) { | 1495 kUseStrictLength)) { |
1513 return Expression::UseStrictStringLiteral(); | 1496 return Expression::UseStrictStringLiteral(); |
1514 } | 1497 } |
1515 return Expression::StringLiteral(); | 1498 return Expression::StringLiteral(); |
1516 } | 1499 } |
1517 | 1500 |
1518 | 1501 |
1519 } } // v8::internal | 1502 } } // v8::internal |
OLD | NEW |