Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/preparser.cc

Issue 12646003: Add parser support for generators. (Closed) Base URL: git://github.com/v8/v8.git@bleeding_edge
Patch Set: Fix bad initialization list in last preparser commit Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 289
288 default: 290 default:
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 '}'
299 // GeneratorDeclaration ::
300 // 'function' '*' Identifier '(' FormalParameterListopt ')'
301 // '{' FunctionBody '}'
297 Expect(i::Token::FUNCTION, CHECK_OK); 302 Expect(i::Token::FUNCTION, CHECK_OK);
298 303
304 bool is_generator = allow_generators_ && Check(i::Token::MUL);
299 Identifier identifier = ParseIdentifier(CHECK_OK); 305 Identifier identifier = ParseIdentifier(CHECK_OK);
300 i::Scanner::Location location = scanner_->location(); 306 i::Scanner::Location location = scanner_->location();
301 307
302 Expression function_value = ParseFunctionLiteral(CHECK_OK); 308 Expression function_value = ParseFunctionLiteral(is_generator, CHECK_OK);
303 309
304 if (function_value.IsStrictFunction() && 310 if (function_value.IsStrictFunction() &&
305 !identifier.IsValidStrictVariable()) { 311 !identifier.IsValidStrictVariable()) {
306 // Strict mode violation, using either reserved word or eval/arguments 312 // Strict mode violation, using either reserved word or eval/arguments
307 // as name of strict function. 313 // as name of strict function.
308 const char* type = "strict_function_name"; 314 const char* type = "strict_function_name";
309 if (identifier.IsFutureStrictReserved()) { 315 if (identifier.IsFutureStrictReserved() || identifier.IsYield()) {
310 type = "strict_reserved_word"; 316 type = "strict_reserved_word";
311 } 317 }
312 ReportMessageAt(location, type, NULL); 318 ReportMessageAt(location, type, NULL);
313 *ok = false; 319 *ok = false;
314 } 320 }
315 return Statement::FunctionDeclaration(); 321 return Statement::FunctionDeclaration();
316 } 322 }
317 323
318 324
319 PreParser::Statement PreParser::ParseBlock(bool* ok) { 325 PreParser::Statement PreParser::ParseBlock(bool* ok) {
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 474
469 475
470 PreParser::Statement PreParser::ParseExpressionOrLabelledStatement(bool* ok) { 476 PreParser::Statement PreParser::ParseExpressionOrLabelledStatement(bool* ok) {
471 // ExpressionStatement | LabelledStatement :: 477 // ExpressionStatement | LabelledStatement ::
472 // Expression ';' 478 // Expression ';'
473 // Identifier ':' Statement 479 // Identifier ':' Statement
474 480
475 Expression expr = ParseExpression(true, CHECK_OK); 481 Expression expr = ParseExpression(true, CHECK_OK);
476 if (expr.IsRawIdentifier()) { 482 if (expr.IsRawIdentifier()) {
477 ASSERT(!expr.AsIdentifier().IsFutureReserved()); 483 ASSERT(!expr.AsIdentifier().IsFutureReserved());
478 ASSERT(is_classic_mode() || !expr.AsIdentifier().IsFutureStrictReserved()); 484 ASSERT(is_classic_mode() ||
485 (!expr.AsIdentifier().IsFutureStrictReserved() &&
486 !expr.AsIdentifier().IsYield()));
479 if (peek() == i::Token::COLON) { 487 if (peek() == i::Token::COLON) {
480 Consume(i::Token::COLON); 488 Consume(i::Token::COLON);
481 return ParseStatement(ok); 489 return ParseStatement(ok);
482 } 490 }
483 // Preparsing is disabled for extensions (because the extension details 491 // Preparsing is disabled for extensions (because the extension details
484 // aren't passed to lazily compiled functions), so we don't 492 // aren't passed to lazily compiled functions), so we don't
485 // accept "native function" in the preparser. 493 // accept "native function" in the preparser.
486 } 494 }
487 // Parsed expression statement. 495 // Parsed expression statement.
488 ExpectSemicolon(CHECK_OK); 496 ExpectSemicolon(CHECK_OK);
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
803 } 811 }
804 return result; 812 return result;
805 } 813 }
806 814
807 815
808 // Precedence = 2 816 // Precedence = 2
809 PreParser::Expression PreParser::ParseAssignmentExpression(bool accept_IN, 817 PreParser::Expression PreParser::ParseAssignmentExpression(bool accept_IN,
810 bool* ok) { 818 bool* ok) {
811 // AssignmentExpression :: 819 // AssignmentExpression ::
812 // ConditionalExpression 820 // ConditionalExpression
821 // YieldExpression
813 // LeftHandSideExpression AssignmentOperator AssignmentExpression 822 // LeftHandSideExpression AssignmentOperator AssignmentExpression
814 823
824 if (scope_->is_generator() && peek() == i::Token::YIELD) {
825 return ParseYieldExpression(ok);
826 }
827
815 i::Scanner::Location before = scanner_->peek_location(); 828 i::Scanner::Location before = scanner_->peek_location();
816 Expression expression = ParseConditionalExpression(accept_IN, CHECK_OK); 829 Expression expression = ParseConditionalExpression(accept_IN, CHECK_OK);
817 830
818 if (!i::Token::IsAssignmentOp(peek())) { 831 if (!i::Token::IsAssignmentOp(peek())) {
819 // Parsed conditional expression only (no assignment). 832 // Parsed conditional expression only (no assignment).
820 return expression; 833 return expression;
821 } 834 }
822 835
823 if (!is_classic_mode() && 836 if (!is_classic_mode() &&
824 expression.IsIdentifier() && 837 expression.IsIdentifier() &&
(...skipping 10 matching lines...) Expand all
835 848
836 if ((op == i::Token::ASSIGN) && expression.IsThisProperty()) { 849 if ((op == i::Token::ASSIGN) && expression.IsThisProperty()) {
837 scope_->AddProperty(); 850 scope_->AddProperty();
838 } 851 }
839 852
840 return Expression::Default(); 853 return Expression::Default();
841 } 854 }
842 855
843 856
844 // Precedence = 3 857 // Precedence = 3
858 PreParser::Expression PreParser::ParseYieldExpression(bool* ok) {
859 // YieldExpression ::
860 // 'yield' '*'? AssignmentExpression
861 Consume(i::Token::YIELD);
862 Check(i::Token::MUL);
863
864 ParseAssignmentExpression(false, CHECK_OK);
865
866 return Expression::Default();
867 }
868
869
870 // Precedence = 3
845 PreParser::Expression PreParser::ParseConditionalExpression(bool accept_IN, 871 PreParser::Expression PreParser::ParseConditionalExpression(bool accept_IN,
846 bool* ok) { 872 bool* ok) {
847 // ConditionalExpression :: 873 // ConditionalExpression ::
848 // LogicalOrExpression 874 // LogicalOrExpression
849 // LogicalOrExpression '?' AssignmentExpression ':' AssignmentExpression 875 // LogicalOrExpression '?' AssignmentExpression ':' AssignmentExpression
850 876
851 // We start using the binary expression parser for prec >= 4 only! 877 // We start using the binary expression parser for prec >= 4 only!
852 Expression expression = ParseBinaryExpression(4, accept_IN, CHECK_OK); 878 Expression expression = ParseBinaryExpression(4, accept_IN, CHECK_OK);
853 if (peek() != i::Token::CONDITIONAL) return expression; 879 if (peek() != i::Token::CONDITIONAL) return expression;
854 Consume(i::Token::CONDITIONAL); 880 Consume(i::Token::CONDITIONAL);
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
1027 PreParser::Expression PreParser::ParseMemberWithNewPrefixesExpression( 1053 PreParser::Expression PreParser::ParseMemberWithNewPrefixesExpression(
1028 unsigned new_count, bool* ok) { 1054 unsigned new_count, bool* ok) {
1029 // MemberExpression :: 1055 // MemberExpression ::
1030 // (PrimaryExpression | FunctionLiteral) 1056 // (PrimaryExpression | FunctionLiteral)
1031 // ('[' Expression ']' | '.' Identifier | Arguments)* 1057 // ('[' Expression ']' | '.' Identifier | Arguments)*
1032 1058
1033 // Parse the initial primary or function expression. 1059 // Parse the initial primary or function expression.
1034 Expression result = Expression::Default(); 1060 Expression result = Expression::Default();
1035 if (peek() == i::Token::FUNCTION) { 1061 if (peek() == i::Token::FUNCTION) {
1036 Consume(i::Token::FUNCTION); 1062 Consume(i::Token::FUNCTION);
1063
1064 bool is_generator = allow_generators_ && Check(i::Token::MUL);
1037 Identifier identifier = Identifier::Default(); 1065 Identifier identifier = Identifier::Default();
1038 if (peek_any_identifier()) { 1066 if (peek_any_identifier()) {
1039 identifier = ParseIdentifier(CHECK_OK); 1067 identifier = ParseIdentifier(CHECK_OK);
1040 } 1068 }
1041 result = ParseFunctionLiteral(CHECK_OK); 1069 result = ParseFunctionLiteral(is_generator, CHECK_OK);
1042 if (result.IsStrictFunction() && !identifier.IsValidStrictVariable()) { 1070 if (result.IsStrictFunction() && !identifier.IsValidStrictVariable()) {
1043 StrictModeIdentifierViolation(scanner_->location(), 1071 StrictModeIdentifierViolation(scanner_->location(),
1044 "strict_function_name", 1072 "strict_function_name",
1045 identifier, 1073 identifier,
1046 ok); 1074 ok);
1047 return Expression::Default(); 1075 return Expression::Default();
1048 } 1076 }
1049 } else { 1077 } else {
1050 result = ParsePrimaryExpression(CHECK_OK); 1078 result = ParsePrimaryExpression(CHECK_OK);
1051 } 1079 }
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1105 Expression result = Expression::Default(); 1133 Expression result = Expression::Default();
1106 switch (peek()) { 1134 switch (peek()) {
1107 case i::Token::THIS: { 1135 case i::Token::THIS: {
1108 Next(); 1136 Next();
1109 result = Expression::This(); 1137 result = Expression::This();
1110 break; 1138 break;
1111 } 1139 }
1112 1140
1113 case i::Token::FUTURE_RESERVED_WORD: 1141 case i::Token::FUTURE_RESERVED_WORD:
1114 case i::Token::FUTURE_STRICT_RESERVED_WORD: 1142 case i::Token::FUTURE_STRICT_RESERVED_WORD:
1143 case i::Token::YIELD:
1115 case i::Token::IDENTIFIER: { 1144 case i::Token::IDENTIFIER: {
1116 Identifier id = ParseIdentifier(CHECK_OK); 1145 Identifier id = ParseIdentifier(CHECK_OK);
1117 result = Expression::FromIdentifier(id); 1146 result = Expression::FromIdentifier(id);
1118 break; 1147 break;
1119 } 1148 }
1120 1149
1121 case i::Token::NULL_LITERAL: 1150 case i::Token::NULL_LITERAL:
1122 case i::Token::TRUE_LITERAL: 1151 case i::Token::TRUE_LITERAL:
1123 case i::Token::FALSE_LITERAL: 1152 case i::Token::FALSE_LITERAL:
1124 case i::Token::NUMBER: { 1153 case i::Token::NUMBER: {
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
1250 name != i::Token::STRING && 1279 name != i::Token::STRING &&
1251 !is_keyword) { 1280 !is_keyword) {
1252 *ok = false; 1281 *ok = false;
1253 return Expression::Default(); 1282 return Expression::Default();
1254 } 1283 }
1255 if (!is_keyword) { 1284 if (!is_keyword) {
1256 LogSymbol(); 1285 LogSymbol();
1257 } 1286 }
1258 PropertyType type = is_getter ? kGetterProperty : kSetterProperty; 1287 PropertyType type = is_getter ? kGetterProperty : kSetterProperty;
1259 CheckDuplicate(&duplicate_finder, name, type, CHECK_OK); 1288 CheckDuplicate(&duplicate_finder, name, type, CHECK_OK);
1260 ParseFunctionLiteral(CHECK_OK); 1289 ParseFunctionLiteral(false, CHECK_OK);
1261 if (peek() != i::Token::RBRACE) { 1290 if (peek() != i::Token::RBRACE) {
1262 Expect(i::Token::COMMA, CHECK_OK); 1291 Expect(i::Token::COMMA, CHECK_OK);
1263 } 1292 }
1264 continue; // restart the while 1293 continue; // restart the while
1265 } 1294 }
1266 CheckDuplicate(&duplicate_finder, next, kValueProperty, CHECK_OK); 1295 CheckDuplicate(&duplicate_finder, next, kValueProperty, CHECK_OK);
1267 break; 1296 break;
1268 } 1297 }
1269 case i::Token::STRING: 1298 case i::Token::STRING:
1270 Consume(next); 1299 Consume(next);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1337 if (!done) { 1366 if (!done) {
1338 Expect(i::Token::COMMA, ok); 1367 Expect(i::Token::COMMA, ok);
1339 if (!*ok) return -1; 1368 if (!*ok) return -1;
1340 } 1369 }
1341 } 1370 }
1342 Expect(i::Token::RPAREN, ok); 1371 Expect(i::Token::RPAREN, ok);
1343 return argc; 1372 return argc;
1344 } 1373 }
1345 1374
1346 1375
1347 PreParser::Expression PreParser::ParseFunctionLiteral(bool* ok) { 1376 PreParser::Expression PreParser::ParseFunctionLiteral(bool is_generator,
1377 bool* ok) {
1348 // Function :: 1378 // Function ::
1349 // '(' FormalParameterList? ')' '{' FunctionBody '}' 1379 // '(' FormalParameterList? ')' '{' FunctionBody '}'
1350 1380
1351 // Parse function body. 1381 // Parse function body.
1352 ScopeType outer_scope_type = scope_->type(); 1382 ScopeType outer_scope_type = scope_->type();
1353 bool inside_with = scope_->IsInsideWith(); 1383 bool inside_with = scope_->IsInsideWith();
1354 Scope function_scope(&scope_, kFunctionScope); 1384 Scope function_scope(&scope_, kFunctionScope);
1385 function_scope.set_is_generator(is_generator);
1355 // FormalParameterList :: 1386 // FormalParameterList ::
1356 // '(' (Identifier)*[','] ')' 1387 // '(' (Identifier)*[','] ')'
1357 Expect(i::Token::LPAREN, CHECK_OK); 1388 Expect(i::Token::LPAREN, CHECK_OK);
1358 int start_position = scanner_->location().beg_pos; 1389 int start_position = scanner_->location().beg_pos;
1359 bool done = (peek() == i::Token::RPAREN); 1390 bool done = (peek() == i::Token::RPAREN);
1360 DuplicateFinder duplicate_finder(scanner_->unicode_cache()); 1391 DuplicateFinder duplicate_finder(scanner_->unicode_cache());
1361 while (!done) { 1392 while (!done) {
1362 Identifier id = ParseIdentifier(CHECK_OK); 1393 Identifier id = ParseIdentifier(CHECK_OK);
1363 if (!id.IsValidStrictVariable()) { 1394 if (!id.IsValidStrictVariable()) {
1364 StrictModeIdentifierViolation(scanner_->location(), 1395 StrictModeIdentifierViolation(scanner_->location(),
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
1490 } 1521 }
1491 1522
1492 1523
1493 PreParser::Identifier PreParser::GetIdentifierSymbol() { 1524 PreParser::Identifier PreParser::GetIdentifierSymbol() {
1494 LogSymbol(); 1525 LogSymbol();
1495 if (scanner_->current_token() == i::Token::FUTURE_RESERVED_WORD) { 1526 if (scanner_->current_token() == i::Token::FUTURE_RESERVED_WORD) {
1496 return Identifier::FutureReserved(); 1527 return Identifier::FutureReserved();
1497 } else if (scanner_->current_token() == 1528 } else if (scanner_->current_token() ==
1498 i::Token::FUTURE_STRICT_RESERVED_WORD) { 1529 i::Token::FUTURE_STRICT_RESERVED_WORD) {
1499 return Identifier::FutureStrictReserved(); 1530 return Identifier::FutureStrictReserved();
1531 } else if (scanner_->current_token() == i::Token::YIELD) {
1532 return Identifier::Yield();
1500 } 1533 }
1501 if (scanner_->is_literal_ascii()) { 1534 if (scanner_->is_literal_ascii()) {
1502 // Detect strict-mode poison words. 1535 // Detect strict-mode poison words.
1503 if (scanner_->literal_length() == 4 && 1536 if (scanner_->literal_length() == 4 &&
1504 !strncmp(scanner_->literal_ascii_string().start(), "eval", 4)) { 1537 !strncmp(scanner_->literal_ascii_string().start(), "eval", 4)) {
1505 return Identifier::Eval(); 1538 return Identifier::Eval();
1506 } 1539 }
1507 if (scanner_->literal_length() == 9 && 1540 if (scanner_->literal_length() == 9 &&
1508 !strncmp(scanner_->literal_ascii_string().start(), "arguments", 9)) { 1541 !strncmp(scanner_->literal_ascii_string().start(), "arguments", 9)) {
1509 return Identifier::Arguments(); 1542 return Identifier::Arguments();
1510 } 1543 }
1511 } 1544 }
1512 return Identifier::Default(); 1545 return Identifier::Default();
1513 } 1546 }
1514 1547
1515 1548
1516 PreParser::Identifier PreParser::ParseIdentifier(bool* ok) { 1549 PreParser::Identifier PreParser::ParseIdentifier(bool* ok) {
1517 i::Token::Value next = Next(); 1550 i::Token::Value next = Next();
1518 switch (next) { 1551 switch (next) {
1519 case i::Token::FUTURE_RESERVED_WORD: { 1552 case i::Token::FUTURE_RESERVED_WORD: {
1520 i::Scanner::Location location = scanner_->location(); 1553 i::Scanner::Location location = scanner_->location();
1521 ReportMessageAt(location.beg_pos, location.end_pos, 1554 ReportMessageAt(location.beg_pos, location.end_pos,
1522 "reserved_word", NULL); 1555 "reserved_word", NULL);
1523 *ok = false; 1556 *ok = false;
1524 return GetIdentifierSymbol(); 1557 return GetIdentifierSymbol();
1525 } 1558 }
1559 case i::Token::YIELD:
1560 if (scope_->is_generator()) {
1561 // 'yield' in a generator is only valid as part of a YieldExpression.
1562 ReportMessageAt(scanner_->location(), "unexpected_token", "yield");
1563 *ok = false;
1564 return Identifier::Yield();
1565 }
1566 // FALLTHROUGH
1526 case i::Token::FUTURE_STRICT_RESERVED_WORD: 1567 case i::Token::FUTURE_STRICT_RESERVED_WORD:
1527 if (!is_classic_mode()) { 1568 if (!is_classic_mode()) {
1528 i::Scanner::Location location = scanner_->location(); 1569 i::Scanner::Location location = scanner_->location();
1529 ReportMessageAt(location.beg_pos, location.end_pos, 1570 ReportMessageAt(location.beg_pos, location.end_pos,
1530 "strict_reserved_word", NULL); 1571 "strict_reserved_word", NULL);
1531 *ok = false; 1572 *ok = false;
1532 } 1573 }
1533 // FALLTHROUGH 1574 // FALLTHROUGH
1534 case i::Token::IDENTIFIER: 1575 case i::Token::IDENTIFIER:
1535 return GetIdentifierSymbol(); 1576 return GetIdentifierSymbol();
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1573 } 1614 }
1574 1615
1575 1616
1576 void PreParser::StrictModeIdentifierViolation(i::Scanner::Location location, 1617 void PreParser::StrictModeIdentifierViolation(i::Scanner::Location location,
1577 const char* eval_args_type, 1618 const char* eval_args_type,
1578 Identifier identifier, 1619 Identifier identifier,
1579 bool* ok) { 1620 bool* ok) {
1580 const char* type = eval_args_type; 1621 const char* type = eval_args_type;
1581 if (identifier.IsFutureReserved()) { 1622 if (identifier.IsFutureReserved()) {
1582 type = "reserved_word"; 1623 type = "reserved_word";
1583 } else if (identifier.IsFutureStrictReserved()) { 1624 } else if (identifier.IsFutureStrictReserved() || identifier.IsYield()) {
1584 type = "strict_reserved_word"; 1625 type = "strict_reserved_word";
1585 } 1626 }
1586 if (!is_classic_mode()) { 1627 if (!is_classic_mode()) {
1587 ReportMessageAt(location, type, NULL); 1628 ReportMessageAt(location, type, NULL);
1588 *ok = false; 1629 *ok = false;
1589 return; 1630 return;
1590 } 1631 }
1591 strict_mode_violation_location_ = location; 1632 strict_mode_violation_location_ = location;
1592 strict_mode_violation_type_ = type; 1633 strict_mode_violation_type_ = type;
1593 } 1634 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1627 *is_get = strncmp(token, "get", 3) == 0; 1668 *is_get = strncmp(token, "get", 3) == 0;
1628 *is_set = !*is_get && strncmp(token, "set", 3) == 0; 1669 *is_set = !*is_get && strncmp(token, "set", 3) == 0;
1629 } 1670 }
1630 return result; 1671 return result;
1631 } 1672 }
1632 1673
1633 bool PreParser::peek_any_identifier() { 1674 bool PreParser::peek_any_identifier() {
1634 i::Token::Value next = peek(); 1675 i::Token::Value next = peek();
1635 return next == i::Token::IDENTIFIER || 1676 return next == i::Token::IDENTIFIER ||
1636 next == i::Token::FUTURE_RESERVED_WORD || 1677 next == i::Token::FUTURE_RESERVED_WORD ||
1637 next == i::Token::FUTURE_STRICT_RESERVED_WORD; 1678 next == i::Token::FUTURE_STRICT_RESERVED_WORD ||
1679 next == i::Token::YIELD;
1638 } 1680 }
1639 1681
1640 1682
1641 int DuplicateFinder::AddAsciiSymbol(i::Vector<const char> key, int value) { 1683 int DuplicateFinder::AddAsciiSymbol(i::Vector<const char> key, int value) {
1642 return AddSymbol(i::Vector<const byte>::cast(key), true, value); 1684 return AddSymbol(i::Vector<const byte>::cast(key), true, value);
1643 } 1685 }
1644 1686
1645 int DuplicateFinder::AddUtf16Symbol(i::Vector<const uint16_t> key, int value) { 1687 int DuplicateFinder::AddUtf16Symbol(i::Vector<const uint16_t> key, int value) {
1646 return AddSymbol(i::Vector<const byte>::cast(key), false, value); 1688 return AddSymbol(i::Vector<const byte>::cast(key), false, value);
1647 } 1689 }
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
1764 backing_store_.Add(static_cast<byte>((ascii_length >> 14) | 0x80u)); 1806 backing_store_.Add(static_cast<byte>((ascii_length >> 14) | 0x80u));
1765 } 1807 }
1766 backing_store_.Add(static_cast<byte>((ascii_length >> 7) | 0x80u)); 1808 backing_store_.Add(static_cast<byte>((ascii_length >> 7) | 0x80u));
1767 } 1809 }
1768 backing_store_.Add(static_cast<byte>(ascii_length & 0x7f)); 1810 backing_store_.Add(static_cast<byte>(ascii_length & 0x7f));
1769 1811
1770 backing_store_.AddBlock(bytes); 1812 backing_store_.AddBlock(bytes);
1771 return backing_store_.EndSequence().start(); 1813 return backing_store_.EndSequence().start();
1772 } 1814 }
1773 } } // v8::preparser 1815 } } // v8::preparser
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698