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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 | 54 |
55 namespace v8 { | 55 namespace v8 { |
56 namespace internal { | 56 namespace internal { |
57 | 57 |
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_->function_state_->is_generator(); |
65 } | 65 } |
66 | 66 |
67 | 67 |
68 int PreParserTraits::NextMaterializedLiteralIndex() { | 68 int PreParserTraits::NextMaterializedLiteralIndex() { |
69 return pre_parser_->scope_->NextMaterializedLiteralIndex(); | 69 return pre_parser_->function_state_->NextMaterializedLiteralIndex(); |
70 } | 70 } |
71 | 71 |
72 | 72 |
73 void PreParserTraits::ReportMessageAt(Scanner::Location location, | 73 void PreParserTraits::ReportMessageAt(Scanner::Location location, |
74 const char* message, | 74 const char* message, |
75 Vector<const char*> args) { | 75 Vector<const char*> args) { |
76 ReportMessageAt(location.beg_pos, | 76 ReportMessageAt(location.beg_pos, |
77 location.end_pos, | 77 location.end_pos, |
78 message, | 78 message, |
79 args.length() > 0 ? args[0] : NULL); | 79 args.length() > 0 ? args[0] : NULL); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 } | 119 } |
120 } | 120 } |
121 return PreParserIdentifier::Default(); | 121 return PreParserIdentifier::Default(); |
122 } | 122 } |
123 | 123 |
124 | 124 |
125 PreParser::PreParseResult PreParser::PreParseLazyFunction( | 125 PreParser::PreParseResult PreParser::PreParseLazyFunction( |
126 LanguageMode mode, bool is_generator, ParserRecorder* log) { | 126 LanguageMode mode, bool is_generator, ParserRecorder* log) { |
127 log_ = log; | 127 log_ = log; |
128 // Lazy functions always have trivial outer scopes (no with/catch scopes). | 128 // Lazy functions always have trivial outer scopes (no with/catch scopes). |
129 Scope top_scope(&scope_, kTopLevelScope); | 129 FunctionState top_scope(&function_state_, &scope_, GLOBAL_SCOPE); |
130 set_language_mode(mode); | 130 scope_->SetLanguageMode(mode); |
131 Scope function_scope(&scope_, kFunctionScope); | 131 FunctionState function_scope(&function_state_, &scope_, FUNCTION_SCOPE); |
132 function_scope.set_is_generator(is_generator); | 132 function_scope.set_is_generator(is_generator); |
133 ASSERT_EQ(Token::LBRACE, scanner()->current_token()); | 133 ASSERT_EQ(Token::LBRACE, scanner()->current_token()); |
134 bool ok = true; | 134 bool ok = true; |
135 int start_position = peek_position(); | 135 int start_position = peek_position(); |
136 ParseLazyFunctionLiteralBody(&ok); | 136 ParseLazyFunctionLiteralBody(&ok); |
137 if (stack_overflow()) return kPreParseStackOverflow; | 137 if (stack_overflow()) return kPreParseStackOverflow; |
138 if (!ok) { | 138 if (!ok) { |
139 ReportUnexpectedToken(scanner()->current_token()); | 139 ReportUnexpectedToken(scanner()->current_token()); |
140 } else { | 140 } else { |
141 ASSERT_EQ(Token::RBRACE, scanner()->peek()); | 141 ASSERT_EQ(Token::RBRACE, scanner()->peek()); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 // (Statement)* <end_token> | 199 // (Statement)* <end_token> |
200 | 200 |
201 bool directive_prologue = true; | 201 bool directive_prologue = true; |
202 while (peek() != end_token) { | 202 while (peek() != end_token) { |
203 if (directive_prologue && peek() != Token::STRING) { | 203 if (directive_prologue && peek() != Token::STRING) { |
204 directive_prologue = false; | 204 directive_prologue = false; |
205 } | 205 } |
206 Statement statement = ParseSourceElement(CHECK_OK); | 206 Statement statement = ParseSourceElement(CHECK_OK); |
207 if (directive_prologue) { | 207 if (directive_prologue) { |
208 if (statement.IsUseStrictLiteral()) { | 208 if (statement.IsUseStrictLiteral()) { |
209 set_language_mode(allow_harmony_scoping() ? | 209 scope_->SetLanguageMode(allow_harmony_scoping() ? |
210 EXTENDED_MODE : STRICT_MODE); | 210 EXTENDED_MODE : STRICT_MODE); |
211 } else if (!statement.IsStringLiteral()) { | 211 } else if (!statement.IsStringLiteral()) { |
212 directive_prologue = false; | 212 directive_prologue = false; |
213 } | 213 } |
214 } | 214 } |
215 } | 215 } |
216 return kUnknownSourceElements; | 216 return kUnknownSourceElements; |
217 } | 217 } |
218 | 218 |
219 | 219 |
220 #undef CHECK_OK | 220 #undef CHECK_OK |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 | 345 |
346 PreParser::Statement PreParser::ParseBlock(bool* ok) { | 346 PreParser::Statement PreParser::ParseBlock(bool* ok) { |
347 // Block :: | 347 // Block :: |
348 // '{' Statement* '}' | 348 // '{' Statement* '}' |
349 | 349 |
350 // Note that a Block does not introduce a new execution scope! | 350 // Note that a Block does not introduce a new execution scope! |
351 // (ECMA-262, 3rd, 12.2) | 351 // (ECMA-262, 3rd, 12.2) |
352 // | 352 // |
353 Expect(Token::LBRACE, CHECK_OK); | 353 Expect(Token::LBRACE, CHECK_OK); |
354 while (peek() != Token::RBRACE) { | 354 while (peek() != Token::RBRACE) { |
355 if (is_extended_mode()) { | 355 if (scope_->is_extended_mode()) { |
356 ParseSourceElement(CHECK_OK); | 356 ParseSourceElement(CHECK_OK); |
357 } else { | 357 } else { |
358 ParseStatement(CHECK_OK); | 358 ParseStatement(CHECK_OK); |
359 } | 359 } |
360 } | 360 } |
361 Expect(Token::RBRACE, ok); | 361 Expect(Token::RBRACE, ok); |
362 return Statement::Default(); | 362 return Statement::Default(); |
363 } | 363 } |
364 | 364 |
365 | 365 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
409 // | 409 // |
410 // ConstDeclaration : const ConstBinding (',' ConstBinding)* ';' | 410 // ConstDeclaration : const ConstBinding (',' ConstBinding)* ';' |
411 // | 411 // |
412 // * It is a Syntax Error if the code that matches this production is not | 412 // * It is a Syntax Error if the code that matches this production is not |
413 // contained in extended code. | 413 // contained in extended code. |
414 // | 414 // |
415 // However disallowing const in classic mode will break compatibility with | 415 // However disallowing const in classic mode will break compatibility with |
416 // existing pages. Therefore we keep allowing const with the old | 416 // existing pages. Therefore we keep allowing const with the old |
417 // non-harmony semantics in classic mode. | 417 // non-harmony semantics in classic mode. |
418 Consume(Token::CONST); | 418 Consume(Token::CONST); |
419 switch (language_mode()) { | 419 switch (scope_->language_mode()) { |
420 case CLASSIC_MODE: | 420 case CLASSIC_MODE: |
421 break; | 421 break; |
422 case STRICT_MODE: { | 422 case STRICT_MODE: { |
423 Scanner::Location location = scanner()->peek_location(); | 423 Scanner::Location location = scanner()->peek_location(); |
424 ReportMessageAt(location, "strict_const"); | 424 ReportMessageAt(location, "strict_const"); |
425 *ok = false; | 425 *ok = false; |
426 return Statement::Default(); | 426 return Statement::Default(); |
427 } | 427 } |
428 case EXTENDED_MODE: | 428 case EXTENDED_MODE: |
429 if (var_context != kSourceElement && | 429 if (var_context != kSourceElement && |
430 var_context != kForStatement) { | 430 var_context != kForStatement) { |
431 ReportMessageAt(scanner()->peek_location(), "unprotected_const"); | 431 ReportMessageAt(scanner()->peek_location(), "unprotected_const"); |
432 *ok = false; | 432 *ok = false; |
433 return Statement::Default(); | 433 return Statement::Default(); |
434 } | 434 } |
435 require_initializer = true; | 435 require_initializer = true; |
436 break; | 436 break; |
437 } | 437 } |
438 } else if (peek() == Token::LET) { | 438 } else if (peek() == Token::LET) { |
439 // ES6 Draft Rev4 section 12.2.1: | 439 // ES6 Draft Rev4 section 12.2.1: |
440 // | 440 // |
441 // LetDeclaration : let LetBindingList ; | 441 // LetDeclaration : let LetBindingList ; |
442 // | 442 // |
443 // * It is a Syntax Error if the code that matches this production is not | 443 // * It is a Syntax Error if the code that matches this production is not |
444 // contained in extended code. | 444 // contained in extended code. |
445 if (!is_extended_mode()) { | 445 if (!scope_->is_extended_mode()) { |
446 ReportMessageAt(scanner()->peek_location(), "illegal_let"); | 446 ReportMessageAt(scanner()->peek_location(), "illegal_let"); |
447 *ok = false; | 447 *ok = false; |
448 return Statement::Default(); | 448 return Statement::Default(); |
449 } | 449 } |
450 Consume(Token::LET); | 450 Consume(Token::LET); |
451 if (var_context != kSourceElement && | 451 if (var_context != kSourceElement && |
452 var_context != kForStatement) { | 452 var_context != kForStatement) { |
453 ReportMessageAt(scanner()->peek_location(), "unprotected_let"); | 453 ReportMessageAt(scanner()->peek_location(), "unprotected_let"); |
454 *ok = false; | 454 *ok = false; |
455 return Statement::Default(); | 455 return Statement::Default(); |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
595 Expect(Token::WITH, CHECK_OK); | 595 Expect(Token::WITH, CHECK_OK); |
596 if (!scope_->is_classic_mode()) { | 596 if (!scope_->is_classic_mode()) { |
597 ReportMessageAt(scanner()->location(), "strict_mode_with"); | 597 ReportMessageAt(scanner()->location(), "strict_mode_with"); |
598 *ok = false; | 598 *ok = false; |
599 return Statement::Default(); | 599 return Statement::Default(); |
600 } | 600 } |
601 Expect(Token::LPAREN, CHECK_OK); | 601 Expect(Token::LPAREN, CHECK_OK); |
602 ParseExpression(true, CHECK_OK); | 602 ParseExpression(true, CHECK_OK); |
603 Expect(Token::RPAREN, CHECK_OK); | 603 Expect(Token::RPAREN, CHECK_OK); |
604 | 604 |
605 Scope::InsideWith iw(scope_); | 605 BlockState block_state(&scope_, WITH_SCOPE); |
606 ParseStatement(CHECK_OK); | 606 ParseStatement(CHECK_OK); |
607 return Statement::Default(); | 607 return Statement::Default(); |
608 } | 608 } |
609 | 609 |
610 | 610 |
611 PreParser::Statement PreParser::ParseSwitchStatement(bool* ok) { | 611 PreParser::Statement PreParser::ParseSwitchStatement(bool* ok) { |
612 // SwitchStatement :: | 612 // SwitchStatement :: |
613 // 'switch' '(' Expression ')' '{' CaseClause* '}' | 613 // 'switch' '(' Expression ')' '{' CaseClause* '}' |
614 | 614 |
615 Expect(Token::SWITCH, CHECK_OK); | 615 Expect(Token::SWITCH, CHECK_OK); |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
768 if (tok != Token::CATCH && tok != Token::FINALLY) { | 768 if (tok != Token::CATCH && tok != Token::FINALLY) { |
769 ReportMessageAt(scanner()->location(), "no_catch_or_finally"); | 769 ReportMessageAt(scanner()->location(), "no_catch_or_finally"); |
770 *ok = false; | 770 *ok = false; |
771 return Statement::Default(); | 771 return Statement::Default(); |
772 } | 772 } |
773 if (tok == Token::CATCH) { | 773 if (tok == Token::CATCH) { |
774 Consume(Token::CATCH); | 774 Consume(Token::CATCH); |
775 Expect(Token::LPAREN, CHECK_OK); | 775 Expect(Token::LPAREN, CHECK_OK); |
776 ParseIdentifier(kDontAllowEvalOrArguments, CHECK_OK); | 776 ParseIdentifier(kDontAllowEvalOrArguments, CHECK_OK); |
777 Expect(Token::RPAREN, CHECK_OK); | 777 Expect(Token::RPAREN, CHECK_OK); |
778 { Scope::InsideWith iw(scope_); | 778 { |
| 779 BlockState block_state(&scope_, WITH_SCOPE); |
779 ParseBlock(CHECK_OK); | 780 ParseBlock(CHECK_OK); |
780 } | 781 } |
781 tok = peek(); | 782 tok = peek(); |
782 } | 783 } |
783 if (tok == Token::FINALLY) { | 784 if (tok == Token::FINALLY) { |
784 Consume(Token::FINALLY); | 785 Consume(Token::FINALLY); |
785 ParseBlock(CHECK_OK); | 786 ParseBlock(CHECK_OK); |
786 } | 787 } |
787 return Statement::Default(); | 788 return Statement::Default(); |
788 } | 789 } |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
826 | 827 |
827 | 828 |
828 // Precedence = 2 | 829 // Precedence = 2 |
829 PreParser::Expression PreParser::ParseAssignmentExpression(bool accept_IN, | 830 PreParser::Expression PreParser::ParseAssignmentExpression(bool accept_IN, |
830 bool* ok) { | 831 bool* ok) { |
831 // AssignmentExpression :: | 832 // AssignmentExpression :: |
832 // ConditionalExpression | 833 // ConditionalExpression |
833 // YieldExpression | 834 // YieldExpression |
834 // LeftHandSideExpression AssignmentOperator AssignmentExpression | 835 // LeftHandSideExpression AssignmentOperator AssignmentExpression |
835 | 836 |
836 if (scope_->is_generator() && peek() == Token::YIELD) { | 837 if (function_state_->is_generator() && peek() == Token::YIELD) { |
837 return ParseYieldExpression(ok); | 838 return ParseYieldExpression(ok); |
838 } | 839 } |
839 | 840 |
840 Scanner::Location before = scanner()->peek_location(); | 841 Scanner::Location before = scanner()->peek_location(); |
841 Expression expression = ParseConditionalExpression(accept_IN, CHECK_OK); | 842 Expression expression = ParseConditionalExpression(accept_IN, CHECK_OK); |
842 | 843 |
843 if (!Token::IsAssignmentOp(peek())) { | 844 if (!Token::IsAssignmentOp(peek())) { |
844 // Parsed conditional expression only (no assignment). | 845 // Parsed conditional expression only (no assignment). |
845 return expression; | 846 return expression; |
846 } | 847 } |
847 | 848 |
848 if (!scope_->is_classic_mode() && | 849 if (!scope_->is_classic_mode() && |
849 expression.IsIdentifier() && | 850 expression.IsIdentifier() && |
850 expression.AsIdentifier().IsEvalOrArguments()) { | 851 expression.AsIdentifier().IsEvalOrArguments()) { |
851 Scanner::Location after = scanner()->location(); | 852 Scanner::Location after = scanner()->location(); |
852 PreParserTraits::ReportMessageAt(before.beg_pos, after.end_pos, | 853 PreParserTraits::ReportMessageAt(before.beg_pos, after.end_pos, |
853 "strict_eval_arguments", NULL); | 854 "strict_eval_arguments", NULL); |
854 *ok = false; | 855 *ok = false; |
855 return Expression::Default(); | 856 return Expression::Default(); |
856 } | 857 } |
857 | 858 |
858 Token::Value op = Next(); // Get assignment operator. | 859 Token::Value op = Next(); // Get assignment operator. |
859 ParseAssignmentExpression(accept_IN, CHECK_OK); | 860 ParseAssignmentExpression(accept_IN, CHECK_OK); |
860 | 861 |
861 if ((op == Token::ASSIGN) && expression.IsThisProperty()) { | 862 if ((op == Token::ASSIGN) && expression.IsThisProperty()) { |
862 scope_->AddProperty(); | 863 function_state_->AddProperty(); |
863 } | 864 } |
864 | 865 |
865 return Expression::Default(); | 866 return Expression::Default(); |
866 } | 867 } |
867 | 868 |
868 | 869 |
869 // Precedence = 3 | 870 // Precedence = 3 |
870 PreParser::Expression PreParser::ParseYieldExpression(bool* ok) { | 871 PreParser::Expression PreParser::ParseYieldExpression(bool* ok) { |
871 // YieldExpression :: | 872 // YieldExpression :: |
872 // 'yield' '*'? AssignmentExpression | 873 // 'yield' '*'? AssignmentExpression |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1212 while (peek() != Token::RBRACK) { | 1213 while (peek() != Token::RBRACK) { |
1213 if (peek() != Token::COMMA) { | 1214 if (peek() != Token::COMMA) { |
1214 ParseAssignmentExpression(true, CHECK_OK); | 1215 ParseAssignmentExpression(true, CHECK_OK); |
1215 } | 1216 } |
1216 if (peek() != Token::RBRACK) { | 1217 if (peek() != Token::RBRACK) { |
1217 Expect(Token::COMMA, CHECK_OK); | 1218 Expect(Token::COMMA, CHECK_OK); |
1218 } | 1219 } |
1219 } | 1220 } |
1220 Expect(Token::RBRACK, CHECK_OK); | 1221 Expect(Token::RBRACK, CHECK_OK); |
1221 | 1222 |
1222 scope_->NextMaterializedLiteralIndex(); | 1223 function_state_->NextMaterializedLiteralIndex(); |
1223 return Expression::Default(); | 1224 return Expression::Default(); |
1224 } | 1225 } |
1225 | 1226 |
1226 | 1227 |
1227 PreParser::Expression PreParser::ParseObjectLiteral(bool* ok) { | 1228 PreParser::Expression PreParser::ParseObjectLiteral(bool* ok) { |
1228 // ObjectLiteral :: | 1229 // ObjectLiteral :: |
1229 // '{' ( | 1230 // '{' ( |
1230 // ((IdentifierName | String | Number) ':' AssignmentExpression) | 1231 // ((IdentifierName | String | Number) ':' AssignmentExpression) |
1231 // | (('get' | 'set') (IdentifierName | String | Number) FunctionLiteral) | 1232 // | (('get' | 'set') (IdentifierName | String | Number) FunctionLiteral) |
1232 // )*[','] '}' | 1233 // )*[','] '}' |
1233 | 1234 |
1234 ObjectLiteralChecker checker(this, language_mode()); | 1235 ObjectLiteralChecker checker(this, scope_->language_mode()); |
1235 | 1236 |
1236 Expect(Token::LBRACE, CHECK_OK); | 1237 Expect(Token::LBRACE, CHECK_OK); |
1237 while (peek() != Token::RBRACE) { | 1238 while (peek() != Token::RBRACE) { |
1238 Token::Value next = peek(); | 1239 Token::Value next = peek(); |
1239 switch (next) { | 1240 switch (next) { |
1240 case Token::IDENTIFIER: | 1241 case Token::IDENTIFIER: |
1241 case Token::FUTURE_RESERVED_WORD: | 1242 case Token::FUTURE_RESERVED_WORD: |
1242 case Token::FUTURE_STRICT_RESERVED_WORD: { | 1243 case Token::FUTURE_STRICT_RESERVED_WORD: { |
1243 bool is_getter = false; | 1244 bool is_getter = false; |
1244 bool is_setter = false; | 1245 bool is_setter = false; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1294 } | 1295 } |
1295 | 1296 |
1296 Expect(Token::COLON, CHECK_OK); | 1297 Expect(Token::COLON, CHECK_OK); |
1297 ParseAssignmentExpression(true, CHECK_OK); | 1298 ParseAssignmentExpression(true, CHECK_OK); |
1298 | 1299 |
1299 // TODO(1240767): Consider allowing trailing comma. | 1300 // TODO(1240767): Consider allowing trailing comma. |
1300 if (peek() != Token::RBRACE) Expect(Token::COMMA, CHECK_OK); | 1301 if (peek() != Token::RBRACE) Expect(Token::COMMA, CHECK_OK); |
1301 } | 1302 } |
1302 Expect(Token::RBRACE, CHECK_OK); | 1303 Expect(Token::RBRACE, CHECK_OK); |
1303 | 1304 |
1304 scope_->NextMaterializedLiteralIndex(); | 1305 function_state_->NextMaterializedLiteralIndex(); |
1305 return Expression::Default(); | 1306 return Expression::Default(); |
1306 } | 1307 } |
1307 | 1308 |
1308 | 1309 |
1309 PreParser::Arguments PreParser::ParseArguments(bool* ok) { | 1310 PreParser::Arguments PreParser::ParseArguments(bool* ok) { |
1310 // Arguments :: | 1311 // Arguments :: |
1311 // '(' (AssignmentExpression)*[','] ')' | 1312 // '(' (AssignmentExpression)*[','] ')' |
1312 | 1313 |
1313 Expect(Token::LPAREN, ok); | 1314 Expect(Token::LPAREN, ok); |
1314 if (!*ok) return -1; | 1315 if (!*ok) return -1; |
(...skipping 17 matching lines...) Expand all Loading... |
1332 Identifier function_name, | 1333 Identifier function_name, |
1333 Scanner::Location function_name_location, | 1334 Scanner::Location function_name_location, |
1334 bool name_is_strict_reserved, | 1335 bool name_is_strict_reserved, |
1335 bool is_generator, | 1336 bool is_generator, |
1336 bool* ok) { | 1337 bool* ok) { |
1337 // Function :: | 1338 // Function :: |
1338 // '(' FormalParameterList? ')' '{' FunctionBody '}' | 1339 // '(' FormalParameterList? ')' '{' FunctionBody '}' |
1339 | 1340 |
1340 // Parse function body. | 1341 // Parse function body. |
1341 ScopeType outer_scope_type = scope_->type(); | 1342 ScopeType outer_scope_type = scope_->type(); |
1342 bool inside_with = scope_->IsInsideWith(); | 1343 bool inside_with = scope_->inside_with(); |
1343 Scope function_scope(&scope_, kFunctionScope); | 1344 FunctionState function_scope(&function_state_, &scope_, FUNCTION_SCOPE); |
1344 function_scope.set_is_generator(is_generator); | 1345 function_scope.set_is_generator(is_generator); |
1345 // FormalParameterList :: | 1346 // FormalParameterList :: |
1346 // '(' (Identifier)*[','] ')' | 1347 // '(' (Identifier)*[','] ')' |
1347 Expect(Token::LPAREN, CHECK_OK); | 1348 Expect(Token::LPAREN, CHECK_OK); |
1348 int start_position = position(); | 1349 int start_position = position(); |
1349 bool done = (peek() == Token::RPAREN); | 1350 bool done = (peek() == Token::RPAREN); |
1350 DuplicateFinder duplicate_finder(scanner()->unicode_cache()); | 1351 DuplicateFinder duplicate_finder(scanner()->unicode_cache()); |
1351 // We don't yet know if the function will be strict, so we cannot yet produce | 1352 // We don't yet know if the function will be strict, so we cannot yet produce |
1352 // errors for parameter names or duplicates. However, we remember the | 1353 // errors for parameter names or duplicates. However, we remember the |
1353 // locations of these errors if they occur and produce the errors later. | 1354 // locations of these errors if they occur and produce the errors later. |
(...skipping 27 matching lines...) Expand all Loading... |
1381 done = (peek() == Token::RPAREN); | 1382 done = (peek() == Token::RPAREN); |
1382 if (!done) { | 1383 if (!done) { |
1383 Expect(Token::COMMA, CHECK_OK); | 1384 Expect(Token::COMMA, CHECK_OK); |
1384 } | 1385 } |
1385 } | 1386 } |
1386 Expect(Token::RPAREN, CHECK_OK); | 1387 Expect(Token::RPAREN, CHECK_OK); |
1387 | 1388 |
1388 // Determine if the function will be lazily compiled. | 1389 // Determine if the function will be lazily compiled. |
1389 // Currently only happens to top-level functions. | 1390 // Currently only happens to top-level functions. |
1390 // Optimistically assume that all top-level functions are lazily compiled. | 1391 // Optimistically assume that all top-level functions are lazily compiled. |
1391 bool is_lazily_compiled = (outer_scope_type == kTopLevelScope && | 1392 bool is_lazily_compiled = (outer_scope_type == GLOBAL_SCOPE && |
1392 !inside_with && allow_lazy() && | 1393 !inside_with && allow_lazy() && |
1393 !parenthesized_function_); | 1394 !parenthesized_function_); |
1394 parenthesized_function_ = false; | 1395 parenthesized_function_ = false; |
1395 | 1396 |
1396 Expect(Token::LBRACE, CHECK_OK); | 1397 Expect(Token::LBRACE, CHECK_OK); |
1397 if (is_lazily_compiled) { | 1398 if (is_lazily_compiled) { |
1398 ParseLazyFunctionLiteralBody(CHECK_OK); | 1399 ParseLazyFunctionLiteralBody(CHECK_OK); |
1399 } else { | 1400 } else { |
1400 ParseSourceElements(Token::RBRACE, ok); | 1401 ParseSourceElements(Token::RBRACE, ok); |
1401 } | 1402 } |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1443 int body_start = position(); | 1444 int body_start = position(); |
1444 log_->PauseRecording(); | 1445 log_->PauseRecording(); |
1445 ParseSourceElements(Token::RBRACE, ok); | 1446 ParseSourceElements(Token::RBRACE, ok); |
1446 log_->ResumeRecording(); | 1447 log_->ResumeRecording(); |
1447 if (!*ok) return; | 1448 if (!*ok) return; |
1448 | 1449 |
1449 // Position right after terminal '}'. | 1450 // Position right after terminal '}'. |
1450 ASSERT_EQ(Token::RBRACE, scanner()->peek()); | 1451 ASSERT_EQ(Token::RBRACE, scanner()->peek()); |
1451 int body_end = scanner()->peek_location().end_pos; | 1452 int body_end = scanner()->peek_location().end_pos; |
1452 log_->LogFunction(body_start, body_end, | 1453 log_->LogFunction(body_start, body_end, |
1453 scope_->materialized_literal_count(), | 1454 function_state_->materialized_literal_count(), |
1454 scope_->expected_properties(), | 1455 function_state_->expected_properties(), |
1455 language_mode()); | 1456 scope_->language_mode()); |
1456 } | 1457 } |
1457 | 1458 |
1458 | 1459 |
1459 PreParser::Expression PreParser::ParseV8Intrinsic(bool* ok) { | 1460 PreParser::Expression PreParser::ParseV8Intrinsic(bool* ok) { |
1460 // CallRuntime :: | 1461 // CallRuntime :: |
1461 // '%' Identifier Arguments | 1462 // '%' Identifier Arguments |
1462 Expect(Token::MOD, CHECK_OK); | 1463 Expect(Token::MOD, CHECK_OK); |
1463 if (!allow_natives_syntax()) { | 1464 if (!allow_natives_syntax()) { |
1464 *ok = false; | 1465 *ok = false; |
1465 return Expression::Default(); | 1466 return Expression::Default(); |
(...skipping 27 matching lines...) Expand all Loading... |
1493 !scanner()->literal_contains_escapes() && | 1494 !scanner()->literal_contains_escapes() && |
1494 !strncmp(scanner()->literal_ascii_string().start(), kUseStrictChars, | 1495 !strncmp(scanner()->literal_ascii_string().start(), kUseStrictChars, |
1495 kUseStrictLength)) { | 1496 kUseStrictLength)) { |
1496 return Expression::UseStrictStringLiteral(); | 1497 return Expression::UseStrictStringLiteral(); |
1497 } | 1498 } |
1498 return Expression::StringLiteral(); | 1499 return Expression::StringLiteral(); |
1499 } | 1500 } |
1500 | 1501 |
1501 | 1502 |
1502 } } // v8::internal | 1503 } } // v8::internal |
OLD | NEW |