OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
540 scanner_(isolate_->unicode_cache()), | 540 scanner_(isolate_->unicode_cache()), |
541 reusable_preparser_(NULL), | 541 reusable_preparser_(NULL), |
542 top_scope_(NULL), | 542 top_scope_(NULL), |
543 current_function_state_(NULL), | 543 current_function_state_(NULL), |
544 target_stack_(NULL), | 544 target_stack_(NULL), |
545 extension_(extension), | 545 extension_(extension), |
546 pre_data_(pre_data), | 546 pre_data_(pre_data), |
547 fni_(NULL), | 547 fni_(NULL), |
548 allow_natives_syntax_((parser_flags & kAllowNativesSyntax) != 0), | 548 allow_natives_syntax_((parser_flags & kAllowNativesSyntax) != 0), |
549 allow_lazy_((parser_flags & kAllowLazy) != 0), | 549 allow_lazy_((parser_flags & kAllowLazy) != 0), |
| 550 allow_modules_((parser_flags & kAllowModules) != 0), |
550 stack_overflow_(false), | 551 stack_overflow_(false), |
551 parenthesized_function_(false) { | 552 parenthesized_function_(false) { |
552 AstNode::ResetIds(); | 553 AstNode::ResetIds(); |
553 if ((parser_flags & kLanguageModeMask) == EXTENDED_MODE) { | 554 if ((parser_flags & kLanguageModeMask) == EXTENDED_MODE) { |
554 scanner().SetHarmonyScoping(true); | 555 scanner().SetHarmonyScoping(true); |
555 } | 556 } |
| 557 if ((parser_flags & kAllowModules) != 0) { |
| 558 scanner().SetHarmonyModules(true); |
| 559 } |
556 } | 560 } |
557 | 561 |
558 | 562 |
559 FunctionLiteral* Parser::ParseProgram(CompilationInfo* info) { | 563 FunctionLiteral* Parser::ParseProgram(CompilationInfo* info) { |
560 ZoneScope zone_scope(isolate(), DONT_DELETE_ON_EXIT); | 564 ZoneScope zone_scope(isolate(), DONT_DELETE_ON_EXIT); |
561 | 565 |
562 HistogramTimerScope timer(isolate()->counters()->parse()); | 566 HistogramTimerScope timer(isolate()->counters()->parse()); |
563 Handle<String> source(String::cast(script_->source())); | 567 Handle<String> source(String::cast(script_->source())); |
564 isolate()->counters()->total_parse_size()->Increment(source->length()); | 568 isolate()->counters()->total_parse_size()->Increment(source->length()); |
565 fni_ = new(zone()) FuncNameInferrer(isolate()); | 569 fni_ = new(zone()) FuncNameInferrer(isolate()); |
(...skipping 3698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4264 HistogramTimerScope preparse_scope(isolate()->counters()->pre_parse()); | 4268 HistogramTimerScope preparse_scope(isolate()->counters()->pre_parse()); |
4265 ASSERT_EQ(Token::LBRACE, scanner().current_token()); | 4269 ASSERT_EQ(Token::LBRACE, scanner().current_token()); |
4266 | 4270 |
4267 if (reusable_preparser_ == NULL) { | 4271 if (reusable_preparser_ == NULL) { |
4268 intptr_t stack_limit = isolate()->stack_guard()->real_climit(); | 4272 intptr_t stack_limit = isolate()->stack_guard()->real_climit(); |
4269 bool do_allow_lazy = true; | 4273 bool do_allow_lazy = true; |
4270 reusable_preparser_ = new preparser::PreParser(&scanner_, | 4274 reusable_preparser_ = new preparser::PreParser(&scanner_, |
4271 NULL, | 4275 NULL, |
4272 stack_limit, | 4276 stack_limit, |
4273 do_allow_lazy, | 4277 do_allow_lazy, |
4274 allow_natives_syntax_); | 4278 allow_natives_syntax_, |
| 4279 allow_modules_); |
4275 } | 4280 } |
4276 preparser::PreParser::PreParseResult result = | 4281 preparser::PreParser::PreParseResult result = |
4277 reusable_preparser_->PreParseLazyFunction(top_scope_->language_mode(), | 4282 reusable_preparser_->PreParseLazyFunction(top_scope_->language_mode(), |
4278 logger); | 4283 logger); |
4279 return result; | 4284 return result; |
4280 } | 4285 } |
4281 | 4286 |
4282 | 4287 |
4283 Expression* Parser::ParseV8Intrinsic(bool* ok) { | 4288 Expression* Parser::ParseV8Intrinsic(bool* ok) { |
4284 // CallRuntime :: | 4289 // CallRuntime :: |
(...skipping 1287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5572 | 5577 |
5573 bool ParserApi::Parse(CompilationInfo* info, int parsing_flags) { | 5578 bool ParserApi::Parse(CompilationInfo* info, int parsing_flags) { |
5574 ASSERT(info->function() == NULL); | 5579 ASSERT(info->function() == NULL); |
5575 FunctionLiteral* result = NULL; | 5580 FunctionLiteral* result = NULL; |
5576 Handle<Script> script = info->script(); | 5581 Handle<Script> script = info->script(); |
5577 ASSERT((parsing_flags & kLanguageModeMask) == CLASSIC_MODE); | 5582 ASSERT((parsing_flags & kLanguageModeMask) == CLASSIC_MODE); |
5578 if (!info->is_native() && FLAG_harmony_scoping) { | 5583 if (!info->is_native() && FLAG_harmony_scoping) { |
5579 // Harmony scoping is requested. | 5584 // Harmony scoping is requested. |
5580 parsing_flags |= EXTENDED_MODE; | 5585 parsing_flags |= EXTENDED_MODE; |
5581 } | 5586 } |
| 5587 if (!info->is_native() && FLAG_harmony_modules) { |
| 5588 parsing_flags |= kAllowModules; |
| 5589 } |
5582 if (FLAG_allow_natives_syntax || info->is_native()) { | 5590 if (FLAG_allow_natives_syntax || info->is_native()) { |
5583 // We require %identifier(..) syntax. | 5591 // We require %identifier(..) syntax. |
5584 parsing_flags |= kAllowNativesSyntax; | 5592 parsing_flags |= kAllowNativesSyntax; |
5585 } | 5593 } |
5586 if (info->is_lazy()) { | 5594 if (info->is_lazy()) { |
5587 ASSERT(!info->is_eval()); | 5595 ASSERT(!info->is_eval()); |
5588 Parser parser(script, parsing_flags, NULL, NULL); | 5596 Parser parser(script, parsing_flags, NULL, NULL); |
5589 result = parser.ParseLazy(info); | 5597 result = parser.ParseLazy(info); |
5590 } else { | 5598 } else { |
5591 ScriptDataImpl* pre_data = info->pre_parse_data(); | 5599 ScriptDataImpl* pre_data = info->pre_parse_data(); |
(...skipping 11 matching lines...) Expand all Loading... |
5603 ASSERT(info->isolate()->has_pending_exception()); | 5611 ASSERT(info->isolate()->has_pending_exception()); |
5604 } else { | 5612 } else { |
5605 result = parser.ParseProgram(info); | 5613 result = parser.ParseProgram(info); |
5606 } | 5614 } |
5607 } | 5615 } |
5608 info->SetFunction(result); | 5616 info->SetFunction(result); |
5609 return (result != NULL); | 5617 return (result != NULL); |
5610 } | 5618 } |
5611 | 5619 |
5612 } } // namespace v8::internal | 5620 } } // namespace v8::internal |
OLD | NEW |