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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 | 46 |
47 #ifdef _MSC_VER | 47 #ifdef _MSC_VER |
48 // Usually defined in math.h, but not in MSVC. | 48 // Usually defined in math.h, but not in MSVC. |
49 // Abstracted to work | 49 // Abstracted to work |
50 int isfinite(double value); | 50 int isfinite(double value); |
51 #endif | 51 #endif |
52 | 52 |
53 namespace preparser { | 53 namespace preparser { |
54 | 54 |
55 PreParser::PreParseResult PreParser::PreParseLazyFunction( | 55 PreParser::PreParseResult PreParser::PreParseLazyFunction( |
56 i::LanguageMode mode, i::ParserRecorder* log) { | 56 i::LanguageMode mode, bool is_generator, i::ParserRecorder* log) { |
57 log_ = log; | 57 log_ = log; |
58 // Lazy functions always have trivial outer scopes (no with/catch scopes). | 58 // Lazy functions always have trivial outer scopes (no with/catch scopes). |
59 Scope top_scope(&scope_, kTopLevelScope); | 59 Scope top_scope(&scope_, kTopLevelScope); |
60 set_language_mode(mode); | 60 set_language_mode(mode); |
61 Scope function_scope(&scope_, kFunctionScope); | 61 Scope function_scope(&scope_, kFunctionScope); |
| 62 function_scope.set_is_generator(is_generator); |
62 ASSERT_EQ(i::Token::LBRACE, scanner_->current_token()); | 63 ASSERT_EQ(i::Token::LBRACE, scanner_->current_token()); |
63 bool ok = true; | 64 bool ok = true; |
64 int start_position = scanner_->peek_location().beg_pos; | 65 int start_position = scanner_->peek_location().beg_pos; |
65 ParseLazyFunctionLiteralBody(&ok); | 66 ParseLazyFunctionLiteralBody(&ok); |
66 if (stack_overflow_) return kPreParseStackOverflow; | 67 if (stack_overflow_) return kPreParseStackOverflow; |
67 if (!ok) { | 68 if (!ok) { |
68 ReportUnexpectedToken(scanner_->current_token()); | 69 ReportUnexpectedToken(scanner_->current_token()); |
69 } else { | 70 } else { |
70 ASSERT_EQ(i::Token::RBRACE, scanner_->peek()); | 71 ASSERT_EQ(i::Token::RBRACE, scanner_->peek()); |
71 if (!is_classic_mode()) { | 72 if (!is_classic_mode()) { |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 PreParser::Statement PreParser::ParseSourceElement(bool* ok) { | 148 PreParser::Statement PreParser::ParseSourceElement(bool* ok) { |
148 // (Ecma 262 5th Edition, clause 14): | 149 // (Ecma 262 5th Edition, clause 14): |
149 // SourceElement: | 150 // SourceElement: |
150 // Statement | 151 // Statement |
151 // FunctionDeclaration | 152 // FunctionDeclaration |
152 // | 153 // |
153 // In harmony mode we allow additionally the following productions | 154 // In harmony mode we allow additionally the following productions |
154 // SourceElement: | 155 // SourceElement: |
155 // LetDeclaration | 156 // LetDeclaration |
156 // ConstDeclaration | 157 // ConstDeclaration |
| 158 // GeneratorDeclaration |
157 | 159 |
158 switch (peek()) { | 160 switch (peek()) { |
159 case i::Token::FUNCTION: | 161 case i::Token::FUNCTION: |
160 return ParseFunctionDeclaration(ok); | 162 return ParseFunctionDeclaration(ok); |
161 case i::Token::LET: | 163 case i::Token::LET: |
162 case i::Token::CONST: | 164 case i::Token::CONST: |
163 return ParseVariableStatement(kSourceElement, ok); | 165 return ParseVariableStatement(kSourceElement, ok); |
164 default: | 166 default: |
165 return ParseStatement(ok); | 167 return ParseStatement(ok); |
166 } | 168 } |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 return ParseExpressionOrLabelledStatement(ok); | 291 return ParseExpressionOrLabelledStatement(ok); |
290 } | 292 } |
291 } | 293 } |
292 | 294 |
293 | 295 |
294 PreParser::Statement PreParser::ParseFunctionDeclaration(bool* ok) { | 296 PreParser::Statement PreParser::ParseFunctionDeclaration(bool* ok) { |
295 // FunctionDeclaration :: | 297 // FunctionDeclaration :: |
296 // 'function' Identifier '(' FormalParameterListopt ')' '{' FunctionBody '}' | 298 // 'function' Identifier '(' FormalParameterListopt ')' '{' FunctionBody '}' |
297 Expect(i::Token::FUNCTION, CHECK_OK); | 299 Expect(i::Token::FUNCTION, CHECK_OK); |
298 | 300 |
| 301 bool is_generator = Check(i::Token::MUL); |
299 Identifier identifier = ParseIdentifier(CHECK_OK); | 302 Identifier identifier = ParseIdentifier(CHECK_OK); |
300 i::Scanner::Location location = scanner_->location(); | 303 i::Scanner::Location location = scanner_->location(); |
301 | 304 |
302 Expression function_value = ParseFunctionLiteral(CHECK_OK); | 305 Expression function_value = ParseFunctionLiteral(is_generator, CHECK_OK); |
303 | 306 |
304 if (function_value.IsStrictFunction() && | 307 if (function_value.IsStrictFunction() && |
305 !identifier.IsValidStrictVariable()) { | 308 !identifier.IsValidStrictVariable()) { |
306 // Strict mode violation, using either reserved word or eval/arguments | 309 // Strict mode violation, using either reserved word or eval/arguments |
307 // as name of strict function. | 310 // as name of strict function. |
308 const char* type = "strict_function_name"; | 311 const char* type = "strict_function_name"; |
309 if (identifier.IsFutureStrictReserved()) { | 312 if (identifier.IsFutureStrictReserved()) { |
310 type = "strict_reserved_word"; | 313 type = "strict_reserved_word"; |
311 } | 314 } |
312 ReportMessageAt(location, type, NULL); | 315 ReportMessageAt(location, type, NULL); |
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
803 } | 806 } |
804 return result; | 807 return result; |
805 } | 808 } |
806 | 809 |
807 | 810 |
808 // Precedence = 2 | 811 // Precedence = 2 |
809 PreParser::Expression PreParser::ParseAssignmentExpression(bool accept_IN, | 812 PreParser::Expression PreParser::ParseAssignmentExpression(bool accept_IN, |
810 bool* ok) { | 813 bool* ok) { |
811 // AssignmentExpression :: | 814 // AssignmentExpression :: |
812 // ConditionalExpression | 815 // ConditionalExpression |
| 816 // YieldExpression |
813 // LeftHandSideExpression AssignmentOperator AssignmentExpression | 817 // LeftHandSideExpression AssignmentOperator AssignmentExpression |
814 | 818 |
| 819 if (scope_->is_generator() && peek() == i::Token::YIELD) { |
| 820 return ParseYieldExpression(ok); |
| 821 } |
| 822 |
815 i::Scanner::Location before = scanner_->peek_location(); | 823 i::Scanner::Location before = scanner_->peek_location(); |
816 Expression expression = ParseConditionalExpression(accept_IN, CHECK_OK); | 824 Expression expression = ParseConditionalExpression(accept_IN, CHECK_OK); |
817 | 825 |
818 if (!i::Token::IsAssignmentOp(peek())) { | 826 if (!i::Token::IsAssignmentOp(peek())) { |
819 // Parsed conditional expression only (no assignment). | 827 // Parsed conditional expression only (no assignment). |
820 return expression; | 828 return expression; |
821 } | 829 } |
822 | 830 |
823 if (!is_classic_mode() && | 831 if (!is_classic_mode() && |
824 expression.IsIdentifier() && | 832 expression.IsIdentifier() && |
(...skipping 10 matching lines...) Expand all Loading... |
835 | 843 |
836 if ((op == i::Token::ASSIGN) && expression.IsThisProperty()) { | 844 if ((op == i::Token::ASSIGN) && expression.IsThisProperty()) { |
837 scope_->AddProperty(); | 845 scope_->AddProperty(); |
838 } | 846 } |
839 | 847 |
840 return Expression::Default(); | 848 return Expression::Default(); |
841 } | 849 } |
842 | 850 |
843 | 851 |
844 // Precedence = 3 | 852 // Precedence = 3 |
| 853 PreParser::Expression PreParser::ParseYieldExpression(bool* ok) { |
| 854 // YieldExpression :: |
| 855 // 'yield' '*'? AssignmentExpression |
| 856 Consume(i::Token::YIELD); |
| 857 Check(i::Token::MUL); |
| 858 |
| 859 ParseAssignmentExpression(false, CHECK_OK); |
| 860 |
| 861 return Expression::Default(); |
| 862 } |
| 863 |
| 864 |
| 865 // Precedence = 3 |
845 PreParser::Expression PreParser::ParseConditionalExpression(bool accept_IN, | 866 PreParser::Expression PreParser::ParseConditionalExpression(bool accept_IN, |
846 bool* ok) { | 867 bool* ok) { |
847 // ConditionalExpression :: | 868 // ConditionalExpression :: |
848 // LogicalOrExpression | 869 // LogicalOrExpression |
849 // LogicalOrExpression '?' AssignmentExpression ':' AssignmentExpression | 870 // LogicalOrExpression '?' AssignmentExpression ':' AssignmentExpression |
850 | 871 |
851 // We start using the binary expression parser for prec >= 4 only! | 872 // We start using the binary expression parser for prec >= 4 only! |
852 Expression expression = ParseBinaryExpression(4, accept_IN, CHECK_OK); | 873 Expression expression = ParseBinaryExpression(4, accept_IN, CHECK_OK); |
853 if (peek() != i::Token::CONDITIONAL) return expression; | 874 if (peek() != i::Token::CONDITIONAL) return expression; |
854 Consume(i::Token::CONDITIONAL); | 875 Consume(i::Token::CONDITIONAL); |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1027 PreParser::Expression PreParser::ParseMemberWithNewPrefixesExpression( | 1048 PreParser::Expression PreParser::ParseMemberWithNewPrefixesExpression( |
1028 unsigned new_count, bool* ok) { | 1049 unsigned new_count, bool* ok) { |
1029 // MemberExpression :: | 1050 // MemberExpression :: |
1030 // (PrimaryExpression | FunctionLiteral) | 1051 // (PrimaryExpression | FunctionLiteral) |
1031 // ('[' Expression ']' | '.' Identifier | Arguments)* | 1052 // ('[' Expression ']' | '.' Identifier | Arguments)* |
1032 | 1053 |
1033 // Parse the initial primary or function expression. | 1054 // Parse the initial primary or function expression. |
1034 Expression result = Expression::Default(); | 1055 Expression result = Expression::Default(); |
1035 if (peek() == i::Token::FUNCTION) { | 1056 if (peek() == i::Token::FUNCTION) { |
1036 Consume(i::Token::FUNCTION); | 1057 Consume(i::Token::FUNCTION); |
| 1058 |
| 1059 bool is_generator = Check(i::Token::MUL); |
1037 Identifier identifier = Identifier::Default(); | 1060 Identifier identifier = Identifier::Default(); |
1038 if (peek_any_identifier()) { | 1061 if (peek_any_identifier()) { |
1039 identifier = ParseIdentifier(CHECK_OK); | 1062 identifier = ParseIdentifier(CHECK_OK); |
1040 } | 1063 } |
1041 result = ParseFunctionLiteral(CHECK_OK); | 1064 result = ParseFunctionLiteral(is_generator, CHECK_OK); |
1042 if (result.IsStrictFunction() && !identifier.IsValidStrictVariable()) { | 1065 if (result.IsStrictFunction() && !identifier.IsValidStrictVariable()) { |
1043 StrictModeIdentifierViolation(scanner_->location(), | 1066 StrictModeIdentifierViolation(scanner_->location(), |
1044 "strict_function_name", | 1067 "strict_function_name", |
1045 identifier, | 1068 identifier, |
1046 ok); | 1069 ok); |
1047 return Expression::Default(); | 1070 return Expression::Default(); |
1048 } | 1071 } |
1049 } else { | 1072 } else { |
1050 result = ParsePrimaryExpression(CHECK_OK); | 1073 result = ParsePrimaryExpression(CHECK_OK); |
1051 } | 1074 } |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1105 Expression result = Expression::Default(); | 1128 Expression result = Expression::Default(); |
1106 switch (peek()) { | 1129 switch (peek()) { |
1107 case i::Token::THIS: { | 1130 case i::Token::THIS: { |
1108 Next(); | 1131 Next(); |
1109 result = Expression::This(); | 1132 result = Expression::This(); |
1110 break; | 1133 break; |
1111 } | 1134 } |
1112 | 1135 |
1113 case i::Token::FUTURE_RESERVED_WORD: | 1136 case i::Token::FUTURE_RESERVED_WORD: |
1114 case i::Token::FUTURE_STRICT_RESERVED_WORD: | 1137 case i::Token::FUTURE_STRICT_RESERVED_WORD: |
| 1138 case i::Token::YIELD: |
1115 case i::Token::IDENTIFIER: { | 1139 case i::Token::IDENTIFIER: { |
1116 Identifier id = ParseIdentifier(CHECK_OK); | 1140 Identifier id = ParseIdentifier(CHECK_OK); |
1117 result = Expression::FromIdentifier(id); | 1141 result = Expression::FromIdentifier(id); |
1118 break; | 1142 break; |
1119 } | 1143 } |
1120 | 1144 |
1121 case i::Token::NULL_LITERAL: | 1145 case i::Token::NULL_LITERAL: |
1122 case i::Token::TRUE_LITERAL: | 1146 case i::Token::TRUE_LITERAL: |
1123 case i::Token::FALSE_LITERAL: | 1147 case i::Token::FALSE_LITERAL: |
1124 case i::Token::NUMBER: { | 1148 case i::Token::NUMBER: { |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1250 name != i::Token::STRING && | 1274 name != i::Token::STRING && |
1251 !is_keyword) { | 1275 !is_keyword) { |
1252 *ok = false; | 1276 *ok = false; |
1253 return Expression::Default(); | 1277 return Expression::Default(); |
1254 } | 1278 } |
1255 if (!is_keyword) { | 1279 if (!is_keyword) { |
1256 LogSymbol(); | 1280 LogSymbol(); |
1257 } | 1281 } |
1258 PropertyType type = is_getter ? kGetterProperty : kSetterProperty; | 1282 PropertyType type = is_getter ? kGetterProperty : kSetterProperty; |
1259 CheckDuplicate(&duplicate_finder, name, type, CHECK_OK); | 1283 CheckDuplicate(&duplicate_finder, name, type, CHECK_OK); |
1260 ParseFunctionLiteral(CHECK_OK); | 1284 ParseFunctionLiteral(false, CHECK_OK); |
1261 if (peek() != i::Token::RBRACE) { | 1285 if (peek() != i::Token::RBRACE) { |
1262 Expect(i::Token::COMMA, CHECK_OK); | 1286 Expect(i::Token::COMMA, CHECK_OK); |
1263 } | 1287 } |
1264 continue; // restart the while | 1288 continue; // restart the while |
1265 } | 1289 } |
1266 CheckDuplicate(&duplicate_finder, next, kValueProperty, CHECK_OK); | 1290 CheckDuplicate(&duplicate_finder, next, kValueProperty, CHECK_OK); |
1267 break; | 1291 break; |
1268 } | 1292 } |
1269 case i::Token::STRING: | 1293 case i::Token::STRING: |
1270 Consume(next); | 1294 Consume(next); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1337 if (!done) { | 1361 if (!done) { |
1338 Expect(i::Token::COMMA, ok); | 1362 Expect(i::Token::COMMA, ok); |
1339 if (!*ok) return -1; | 1363 if (!*ok) return -1; |
1340 } | 1364 } |
1341 } | 1365 } |
1342 Expect(i::Token::RPAREN, ok); | 1366 Expect(i::Token::RPAREN, ok); |
1343 return argc; | 1367 return argc; |
1344 } | 1368 } |
1345 | 1369 |
1346 | 1370 |
1347 PreParser::Expression PreParser::ParseFunctionLiteral(bool* ok) { | 1371 PreParser::Expression PreParser::ParseFunctionLiteral(bool is_generator, |
| 1372 bool* ok) { |
1348 // Function :: | 1373 // Function :: |
1349 // '(' FormalParameterList? ')' '{' FunctionBody '}' | 1374 // '(' FormalParameterList? ')' '{' FunctionBody '}' |
1350 | 1375 |
1351 // Parse function body. | 1376 // Parse function body. |
1352 ScopeType outer_scope_type = scope_->type(); | 1377 ScopeType outer_scope_type = scope_->type(); |
1353 bool inside_with = scope_->IsInsideWith(); | 1378 bool inside_with = scope_->IsInsideWith(); |
1354 Scope function_scope(&scope_, kFunctionScope); | 1379 Scope function_scope(&scope_, kFunctionScope); |
| 1380 function_scope.set_is_generator(is_generator); |
1355 // FormalParameterList :: | 1381 // FormalParameterList :: |
1356 // '(' (Identifier)*[','] ')' | 1382 // '(' (Identifier)*[','] ')' |
1357 Expect(i::Token::LPAREN, CHECK_OK); | 1383 Expect(i::Token::LPAREN, CHECK_OK); |
1358 int start_position = scanner_->location().beg_pos; | 1384 int start_position = scanner_->location().beg_pos; |
1359 bool done = (peek() == i::Token::RPAREN); | 1385 bool done = (peek() == i::Token::RPAREN); |
1360 DuplicateFinder duplicate_finder(scanner_->unicode_cache()); | 1386 DuplicateFinder duplicate_finder(scanner_->unicode_cache()); |
1361 while (!done) { | 1387 while (!done) { |
1362 Identifier id = ParseIdentifier(CHECK_OK); | 1388 Identifier id = ParseIdentifier(CHECK_OK); |
1363 if (!id.IsValidStrictVariable()) { | 1389 if (!id.IsValidStrictVariable()) { |
1364 StrictModeIdentifierViolation(scanner_->location(), | 1390 StrictModeIdentifierViolation(scanner_->location(), |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1490 } | 1516 } |
1491 | 1517 |
1492 | 1518 |
1493 PreParser::Identifier PreParser::GetIdentifierSymbol() { | 1519 PreParser::Identifier PreParser::GetIdentifierSymbol() { |
1494 LogSymbol(); | 1520 LogSymbol(); |
1495 if (scanner_->current_token() == i::Token::FUTURE_RESERVED_WORD) { | 1521 if (scanner_->current_token() == i::Token::FUTURE_RESERVED_WORD) { |
1496 return Identifier::FutureReserved(); | 1522 return Identifier::FutureReserved(); |
1497 } else if (scanner_->current_token() == | 1523 } else if (scanner_->current_token() == |
1498 i::Token::FUTURE_STRICT_RESERVED_WORD) { | 1524 i::Token::FUTURE_STRICT_RESERVED_WORD) { |
1499 return Identifier::FutureStrictReserved(); | 1525 return Identifier::FutureStrictReserved(); |
| 1526 } else if (scanner_->current_token() == i::Token::YIELD) { |
| 1527 return Identifier::Yield(); |
1500 } | 1528 } |
1501 if (scanner_->is_literal_ascii()) { | 1529 if (scanner_->is_literal_ascii()) { |
1502 // Detect strict-mode poison words. | 1530 // Detect strict-mode poison words. |
1503 if (scanner_->literal_length() == 4 && | 1531 if (scanner_->literal_length() == 4 && |
1504 !strncmp(scanner_->literal_ascii_string().start(), "eval", 4)) { | 1532 !strncmp(scanner_->literal_ascii_string().start(), "eval", 4)) { |
1505 return Identifier::Eval(); | 1533 return Identifier::Eval(); |
1506 } | 1534 } |
1507 if (scanner_->literal_length() == 9 && | 1535 if (scanner_->literal_length() == 9 && |
1508 !strncmp(scanner_->literal_ascii_string().start(), "arguments", 9)) { | 1536 !strncmp(scanner_->literal_ascii_string().start(), "arguments", 9)) { |
1509 return Identifier::Arguments(); | 1537 return Identifier::Arguments(); |
1510 } | 1538 } |
1511 } | 1539 } |
1512 return Identifier::Default(); | 1540 return Identifier::Default(); |
1513 } | 1541 } |
1514 | 1542 |
1515 | 1543 |
1516 PreParser::Identifier PreParser::ParseIdentifier(bool* ok) { | 1544 PreParser::Identifier PreParser::ParseIdentifier(bool* ok) { |
1517 i::Token::Value next = Next(); | 1545 i::Token::Value next = Next(); |
1518 switch (next) { | 1546 switch (next) { |
1519 case i::Token::FUTURE_RESERVED_WORD: { | 1547 case i::Token::FUTURE_RESERVED_WORD: { |
1520 i::Scanner::Location location = scanner_->location(); | 1548 i::Scanner::Location location = scanner_->location(); |
1521 ReportMessageAt(location.beg_pos, location.end_pos, | 1549 ReportMessageAt(location.beg_pos, location.end_pos, |
1522 "reserved_word", NULL); | 1550 "reserved_word", NULL); |
1523 *ok = false; | 1551 *ok = false; |
1524 return GetIdentifierSymbol(); | 1552 return GetIdentifierSymbol(); |
1525 } | 1553 } |
| 1554 case i::Token::YIELD: |
| 1555 if (scope_->is_generator()) { |
| 1556 // 'yield' in a generator is only valid as part of a YieldExpression. |
| 1557 ReportMessageAt(scanner_->location(), "unexpected_token", "yield"); |
| 1558 *ok = false; |
| 1559 return Identifier::Yield(); |
| 1560 } |
| 1561 // FALLTHROUGH |
1526 case i::Token::FUTURE_STRICT_RESERVED_WORD: | 1562 case i::Token::FUTURE_STRICT_RESERVED_WORD: |
1527 if (!is_classic_mode()) { | 1563 if (!is_classic_mode()) { |
1528 i::Scanner::Location location = scanner_->location(); | 1564 i::Scanner::Location location = scanner_->location(); |
1529 ReportMessageAt(location.beg_pos, location.end_pos, | 1565 ReportMessageAt(location.beg_pos, location.end_pos, |
1530 "strict_reserved_word", NULL); | 1566 "strict_reserved_word", NULL); |
1531 *ok = false; | 1567 *ok = false; |
1532 } | 1568 } |
1533 // FALLTHROUGH | 1569 // FALLTHROUGH |
1534 case i::Token::IDENTIFIER: | 1570 case i::Token::IDENTIFIER: |
1535 return GetIdentifierSymbol(); | 1571 return GetIdentifierSymbol(); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1573 } | 1609 } |
1574 | 1610 |
1575 | 1611 |
1576 void PreParser::StrictModeIdentifierViolation(i::Scanner::Location location, | 1612 void PreParser::StrictModeIdentifierViolation(i::Scanner::Location location, |
1577 const char* eval_args_type, | 1613 const char* eval_args_type, |
1578 Identifier identifier, | 1614 Identifier identifier, |
1579 bool* ok) { | 1615 bool* ok) { |
1580 const char* type = eval_args_type; | 1616 const char* type = eval_args_type; |
1581 if (identifier.IsFutureReserved()) { | 1617 if (identifier.IsFutureReserved()) { |
1582 type = "reserved_word"; | 1618 type = "reserved_word"; |
1583 } else if (identifier.IsFutureStrictReserved()) { | 1619 } else if (identifier.IsFutureStrictReserved() || identifier.IsYield()) { |
1584 type = "strict_reserved_word"; | 1620 type = "strict_reserved_word"; |
1585 } | 1621 } |
1586 if (!is_classic_mode()) { | 1622 if (!is_classic_mode()) { |
1587 ReportMessageAt(location, type, NULL); | 1623 ReportMessageAt(location, type, NULL); |
1588 *ok = false; | 1624 *ok = false; |
1589 return; | 1625 return; |
1590 } | 1626 } |
1591 strict_mode_violation_location_ = location; | 1627 strict_mode_violation_location_ = location; |
1592 strict_mode_violation_type_ = type; | 1628 strict_mode_violation_type_ = type; |
1593 } | 1629 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1627 *is_get = strncmp(token, "get", 3) == 0; | 1663 *is_get = strncmp(token, "get", 3) == 0; |
1628 *is_set = !*is_get && strncmp(token, "set", 3) == 0; | 1664 *is_set = !*is_get && strncmp(token, "set", 3) == 0; |
1629 } | 1665 } |
1630 return result; | 1666 return result; |
1631 } | 1667 } |
1632 | 1668 |
1633 bool PreParser::peek_any_identifier() { | 1669 bool PreParser::peek_any_identifier() { |
1634 i::Token::Value next = peek(); | 1670 i::Token::Value next = peek(); |
1635 return next == i::Token::IDENTIFIER || | 1671 return next == i::Token::IDENTIFIER || |
1636 next == i::Token::FUTURE_RESERVED_WORD || | 1672 next == i::Token::FUTURE_RESERVED_WORD || |
1637 next == i::Token::FUTURE_STRICT_RESERVED_WORD; | 1673 next == i::Token::FUTURE_STRICT_RESERVED_WORD || |
| 1674 next == i::Token::YIELD; |
1638 } | 1675 } |
1639 | 1676 |
1640 | 1677 |
1641 int DuplicateFinder::AddAsciiSymbol(i::Vector<const char> key, int value) { | 1678 int DuplicateFinder::AddAsciiSymbol(i::Vector<const char> key, int value) { |
1642 return AddSymbol(i::Vector<const byte>::cast(key), true, value); | 1679 return AddSymbol(i::Vector<const byte>::cast(key), true, value); |
1643 } | 1680 } |
1644 | 1681 |
1645 int DuplicateFinder::AddUtf16Symbol(i::Vector<const uint16_t> key, int value) { | 1682 int DuplicateFinder::AddUtf16Symbol(i::Vector<const uint16_t> key, int value) { |
1646 return AddSymbol(i::Vector<const byte>::cast(key), false, value); | 1683 return AddSymbol(i::Vector<const byte>::cast(key), false, value); |
1647 } | 1684 } |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1764 backing_store_.Add(static_cast<byte>((ascii_length >> 14) | 0x80u)); | 1801 backing_store_.Add(static_cast<byte>((ascii_length >> 14) | 0x80u)); |
1765 } | 1802 } |
1766 backing_store_.Add(static_cast<byte>((ascii_length >> 7) | 0x80u)); | 1803 backing_store_.Add(static_cast<byte>((ascii_length >> 7) | 0x80u)); |
1767 } | 1804 } |
1768 backing_store_.Add(static_cast<byte>(ascii_length & 0x7f)); | 1805 backing_store_.Add(static_cast<byte>(ascii_length & 0x7f)); |
1769 | 1806 |
1770 backing_store_.AddBlock(bytes); | 1807 backing_store_.AddBlock(bytes); |
1771 return backing_store_.EndSequence().start(); | 1808 return backing_store_.EndSequence().start(); |
1772 } | 1809 } |
1773 } } // v8::preparser | 1810 } } // v8::preparser |
OLD | NEW |