| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 "src/parsing/parser.h" | 5 #include "src/parsing/parser.h" |
| 6 | 6 |
| 7 #include "src/api.h" | 7 #include "src/api.h" |
| 8 #include "src/ast/ast.h" | 8 #include "src/ast/ast.h" |
| 9 #include "src/ast/ast-expression-rewriter.h" | 9 #include "src/ast/ast-expression-rewriter.h" |
| 10 #include "src/ast/ast-expression-visitor.h" | 10 #include "src/ast/ast-expression-visitor.h" |
| (...skipping 911 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 922 FunctionState function_state(&function_state_, &scope_, scope, | 922 FunctionState function_state(&function_state_, &scope_, scope, |
| 923 kNormalFunction, &function_factory); | 923 kNormalFunction, &function_factory); |
| 924 | 924 |
| 925 // Don't count the mode in the use counters--give the program a chance | 925 // Don't count the mode in the use counters--give the program a chance |
| 926 // to enable script/module-wide strict mode below. | 926 // to enable script/module-wide strict mode below. |
| 927 scope_->SetLanguageMode(info->language_mode()); | 927 scope_->SetLanguageMode(info->language_mode()); |
| 928 ZoneList<Statement*>* body = new(zone()) ZoneList<Statement*>(16, zone()); | 928 ZoneList<Statement*>* body = new(zone()) ZoneList<Statement*>(16, zone()); |
| 929 bool ok = true; | 929 bool ok = true; |
| 930 int beg_pos = scanner()->location().beg_pos; | 930 int beg_pos = scanner()->location().beg_pos; |
| 931 if (info->is_module()) { | 931 if (info->is_module()) { |
| 932 parsing_module_ = true; |
| 932 ParseModuleItemList(body, &ok); | 933 ParseModuleItemList(body, &ok); |
| 933 } else { | 934 } else { |
| 935 parsing_module_ = false; |
| 934 ParseStatementList(body, Token::EOS, &ok); | 936 ParseStatementList(body, Token::EOS, &ok); |
| 935 } | 937 } |
| 936 | 938 |
| 937 // The parser will peek but not consume EOS. Our scope logically goes all | 939 // The parser will peek but not consume EOS. Our scope logically goes all |
| 938 // the way to the EOS, though. | 940 // the way to the EOS, though. |
| 939 scope->set_end_position(scanner()->peek_location().beg_pos); | 941 scope->set_end_position(scanner()->peek_location().beg_pos); |
| 940 | 942 |
| 941 if (ok && is_strict(language_mode())) { | 943 if (ok && is_strict(language_mode())) { |
| 942 CheckStrictOctalLiteral(beg_pos, scanner()->location().end_pos, &ok); | 944 CheckStrictOctalLiteral(beg_pos, scanner()->location().end_pos, &ok); |
| 943 } | 945 } |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1357 // IdentifierName | 1359 // IdentifierName |
| 1358 // IdentifierName 'as' IdentifierName | 1360 // IdentifierName 'as' IdentifierName |
| 1359 | 1361 |
| 1360 Expect(Token::LBRACE, CHECK_OK); | 1362 Expect(Token::LBRACE, CHECK_OK); |
| 1361 | 1363 |
| 1362 Token::Value name_tok; | 1364 Token::Value name_tok; |
| 1363 while ((name_tok = peek()) != Token::RBRACE) { | 1365 while ((name_tok = peek()) != Token::RBRACE) { |
| 1364 // Keep track of the first reserved word encountered in case our | 1366 // Keep track of the first reserved word encountered in case our |
| 1365 // caller needs to report an error. | 1367 // caller needs to report an error. |
| 1366 if (!reserved_loc->IsValid() && | 1368 if (!reserved_loc->IsValid() && |
| 1367 !Token::IsIdentifier(name_tok, STRICT, false)) { | 1369 !Token::IsIdentifier(name_tok, STRICT, false, true)) { |
| 1368 *reserved_loc = scanner()->location(); | 1370 *reserved_loc = scanner()->location(); |
| 1369 } | 1371 } |
| 1370 const AstRawString* local_name = ParseIdentifierName(CHECK_OK); | 1372 const AstRawString* local_name = ParseIdentifierName(CHECK_OK); |
| 1371 const AstRawString* export_name = NULL; | 1373 const AstRawString* export_name = NULL; |
| 1372 if (CheckContextualKeyword(CStrVector("as"))) { | 1374 if (CheckContextualKeyword(CStrVector("as"))) { |
| 1373 export_name = ParseIdentifierName(CHECK_OK); | 1375 export_name = ParseIdentifierName(CHECK_OK); |
| 1374 } | 1376 } |
| 1375 if (export_name == NULL) { | 1377 if (export_name == NULL) { |
| 1376 export_name = local_name; | 1378 export_name = local_name; |
| 1377 } | 1379 } |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1408 new (zone()) ZoneList<ImportDeclaration*>(1, zone()); | 1410 new (zone()) ZoneList<ImportDeclaration*>(1, zone()); |
| 1409 while (peek() != Token::RBRACE) { | 1411 while (peek() != Token::RBRACE) { |
| 1410 const AstRawString* import_name = ParseIdentifierName(CHECK_OK); | 1412 const AstRawString* import_name = ParseIdentifierName(CHECK_OK); |
| 1411 const AstRawString* local_name = import_name; | 1413 const AstRawString* local_name = import_name; |
| 1412 // In the presence of 'as', the left-side of the 'as' can | 1414 // In the presence of 'as', the left-side of the 'as' can |
| 1413 // be any IdentifierName. But without 'as', it must be a valid | 1415 // be any IdentifierName. But without 'as', it must be a valid |
| 1414 // BindingIdentifier. | 1416 // BindingIdentifier. |
| 1415 if (CheckContextualKeyword(CStrVector("as"))) { | 1417 if (CheckContextualKeyword(CStrVector("as"))) { |
| 1416 local_name = ParseIdentifierName(CHECK_OK); | 1418 local_name = ParseIdentifierName(CHECK_OK); |
| 1417 } | 1419 } |
| 1418 if (!Token::IsIdentifier(scanner()->current_token(), STRICT, false)) { | 1420 if (!Token::IsIdentifier(scanner()->current_token(), STRICT, false, true)) { |
| 1419 *ok = false; | 1421 *ok = false; |
| 1420 ReportMessage(MessageTemplate::kUnexpectedReserved); | 1422 ReportMessage(MessageTemplate::kUnexpectedReserved); |
| 1421 return NULL; | 1423 return NULL; |
| 1422 } else if (IsEvalOrArguments(local_name)) { | 1424 } else if (IsEvalOrArguments(local_name)) { |
| 1423 *ok = false; | 1425 *ok = false; |
| 1424 ReportMessage(MessageTemplate::kStrictEvalArguments); | 1426 ReportMessage(MessageTemplate::kStrictEvalArguments); |
| 1425 return NULL; | 1427 return NULL; |
| 1426 } | 1428 } |
| 1427 VariableProxy* proxy = NewUnresolved(local_name, IMPORT); | 1429 VariableProxy* proxy = NewUnresolved(local_name, IMPORT); |
| 1428 ImportDeclaration* declaration = | 1430 ImportDeclaration* declaration = |
| (...skipping 3245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4674 SET_ALLOW(harmony_sloppy_let); | 4676 SET_ALLOW(harmony_sloppy_let); |
| 4675 SET_ALLOW(harmony_do_expressions); | 4677 SET_ALLOW(harmony_do_expressions); |
| 4676 SET_ALLOW(harmony_function_name); | 4678 SET_ALLOW(harmony_function_name); |
| 4677 SET_ALLOW(harmony_function_sent); | 4679 SET_ALLOW(harmony_function_sent); |
| 4678 SET_ALLOW(harmony_exponentiation_operator); | 4680 SET_ALLOW(harmony_exponentiation_operator); |
| 4679 SET_ALLOW(harmony_restrictive_declarations); | 4681 SET_ALLOW(harmony_restrictive_declarations); |
| 4680 #undef SET_ALLOW | 4682 #undef SET_ALLOW |
| 4681 } | 4683 } |
| 4682 PreParser::PreParseResult result = reusable_preparser_->PreParseLazyFunction( | 4684 PreParser::PreParseResult result = reusable_preparser_->PreParseLazyFunction( |
| 4683 language_mode(), function_state_->kind(), scope_->has_simple_parameters(), | 4685 language_mode(), function_state_->kind(), scope_->has_simple_parameters(), |
| 4684 logger, bookmark); | 4686 parsing_module_, logger, bookmark); |
| 4685 if (pre_parse_timer_ != NULL) { | 4687 if (pre_parse_timer_ != NULL) { |
| 4686 pre_parse_timer_->Stop(); | 4688 pre_parse_timer_->Stop(); |
| 4687 } | 4689 } |
| 4688 return result; | 4690 return result; |
| 4689 } | 4691 } |
| 4690 | 4692 |
| 4691 | 4693 |
| 4692 ClassLiteral* Parser::ParseClassLiteral(const AstRawString* name, | 4694 ClassLiteral* Parser::ParseClassLiteral(const AstRawString* name, |
| 4693 Scanner::Location class_name_location, | 4695 Scanner::Location class_name_location, |
| 4694 bool name_is_strict_reserved, int pos, | 4696 bool name_is_strict_reserved, int pos, |
| (...skipping 2165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6860 try_block, target); | 6862 try_block, target); |
| 6861 final_loop = target; | 6863 final_loop = target; |
| 6862 } | 6864 } |
| 6863 | 6865 |
| 6864 return final_loop; | 6866 return final_loop; |
| 6865 } | 6867 } |
| 6866 | 6868 |
| 6867 | 6869 |
| 6868 } // namespace internal | 6870 } // namespace internal |
| 6869 } // namespace v8 | 6871 } // namespace v8 |
| OLD | NEW |