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 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
595 scanner_(isolate_->unicode_cache()), | 595 scanner_(isolate_->unicode_cache()), |
596 reusable_preparser_(NULL), | 596 reusable_preparser_(NULL), |
597 top_scope_(NULL), | 597 top_scope_(NULL), |
598 current_function_state_(NULL), | 598 current_function_state_(NULL), |
599 target_stack_(NULL), | 599 target_stack_(NULL), |
600 extension_(extension), | 600 extension_(extension), |
601 pre_data_(pre_data), | 601 pre_data_(pre_data), |
602 fni_(NULL), | 602 fni_(NULL), |
603 allow_natives_syntax_((parser_flags & kAllowNativesSyntax) != 0), | 603 allow_natives_syntax_((parser_flags & kAllowNativesSyntax) != 0), |
604 allow_lazy_((parser_flags & kAllowLazy) != 0), | 604 allow_lazy_((parser_flags & kAllowLazy) != 0), |
| 605 allow_modules_((parser_flags & kAllowModules) != 0), |
605 stack_overflow_(false), | 606 stack_overflow_(false), |
606 parenthesized_function_(false) { | 607 parenthesized_function_(false) { |
607 AstNode::ResetIds(); | 608 AstNode::ResetIds(); |
608 if ((parser_flags & kLanguageModeMask) == EXTENDED_MODE) { | 609 if ((parser_flags & kLanguageModeMask) == EXTENDED_MODE) { |
609 scanner().SetHarmonyScoping(true); | 610 scanner().SetHarmonyScoping(true); |
610 } | 611 } |
| 612 if ((parser_flags & kAllowModules) != 0) { |
| 613 scanner().SetHarmonyModules(true); |
| 614 } |
611 } | 615 } |
612 | 616 |
613 | 617 |
614 FunctionLiteral* Parser::ParseProgram(CompilationInfo* info) { | 618 FunctionLiteral* Parser::ParseProgram(CompilationInfo* info) { |
615 ZoneScope zone_scope(isolate(), DONT_DELETE_ON_EXIT); | 619 ZoneScope zone_scope(isolate(), DONT_DELETE_ON_EXIT); |
616 | 620 |
617 HistogramTimerScope timer(isolate()->counters()->parse()); | 621 HistogramTimerScope timer(isolate()->counters()->parse()); |
618 Handle<String> source(String::cast(script_->source())); | 622 Handle<String> source(String::cast(script_->source())); |
619 isolate()->counters()->total_parse_size()->Increment(source->length()); | 623 isolate()->counters()->total_parse_size()->Increment(source->length()); |
620 fni_ = new(zone()) FuncNameInferrer(isolate()); | 624 fni_ = new(zone()) FuncNameInferrer(isolate()); |
(...skipping 3715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4336 HistogramTimerScope preparse_scope(isolate()->counters()->pre_parse()); | 4340 HistogramTimerScope preparse_scope(isolate()->counters()->pre_parse()); |
4337 ASSERT_EQ(Token::LBRACE, scanner().current_token()); | 4341 ASSERT_EQ(Token::LBRACE, scanner().current_token()); |
4338 | 4342 |
4339 if (reusable_preparser_ == NULL) { | 4343 if (reusable_preparser_ == NULL) { |
4340 intptr_t stack_limit = isolate()->stack_guard()->real_climit(); | 4344 intptr_t stack_limit = isolate()->stack_guard()->real_climit(); |
4341 bool do_allow_lazy = true; | 4345 bool do_allow_lazy = true; |
4342 reusable_preparser_ = new preparser::PreParser(&scanner_, | 4346 reusable_preparser_ = new preparser::PreParser(&scanner_, |
4343 NULL, | 4347 NULL, |
4344 stack_limit, | 4348 stack_limit, |
4345 do_allow_lazy, | 4349 do_allow_lazy, |
4346 allow_natives_syntax_); | 4350 allow_natives_syntax_, |
| 4351 allow_modules_); |
4347 } | 4352 } |
4348 preparser::PreParser::PreParseResult result = | 4353 preparser::PreParser::PreParseResult result = |
4349 reusable_preparser_->PreParseLazyFunction(top_scope_->language_mode(), | 4354 reusable_preparser_->PreParseLazyFunction(top_scope_->language_mode(), |
4350 logger); | 4355 logger); |
4351 return result; | 4356 return result; |
4352 } | 4357 } |
4353 | 4358 |
4354 | 4359 |
4355 Expression* Parser::ParseV8Intrinsic(bool* ok) { | 4360 Expression* Parser::ParseV8Intrinsic(bool* ok) { |
4356 // CallRuntime :: | 4361 // CallRuntime :: |
(...skipping 1301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5658 | 5663 |
5659 bool ParserApi::Parse(CompilationInfo* info, int parsing_flags) { | 5664 bool ParserApi::Parse(CompilationInfo* info, int parsing_flags) { |
5660 ASSERT(info->function() == NULL); | 5665 ASSERT(info->function() == NULL); |
5661 FunctionLiteral* result = NULL; | 5666 FunctionLiteral* result = NULL; |
5662 Handle<Script> script = info->script(); | 5667 Handle<Script> script = info->script(); |
5663 ASSERT((parsing_flags & kLanguageModeMask) == CLASSIC_MODE); | 5668 ASSERT((parsing_flags & kLanguageModeMask) == CLASSIC_MODE); |
5664 if (!info->is_native() && FLAG_harmony_scoping) { | 5669 if (!info->is_native() && FLAG_harmony_scoping) { |
5665 // Harmony scoping is requested. | 5670 // Harmony scoping is requested. |
5666 parsing_flags |= EXTENDED_MODE; | 5671 parsing_flags |= EXTENDED_MODE; |
5667 } | 5672 } |
| 5673 if (!info->is_native() && FLAG_harmony_modules) { |
| 5674 parsing_flags |= kAllowModules; |
| 5675 } |
5668 if (FLAG_allow_natives_syntax || info->is_native()) { | 5676 if (FLAG_allow_natives_syntax || info->is_native()) { |
5669 // We requre %identifier(..) syntax. | 5677 // We requre %identifier(..) syntax. |
5670 parsing_flags |= kAllowNativesSyntax; | 5678 parsing_flags |= kAllowNativesSyntax; |
5671 } | 5679 } |
5672 if (info->is_lazy()) { | 5680 if (info->is_lazy()) { |
5673 ASSERT(!info->is_eval()); | 5681 ASSERT(!info->is_eval()); |
5674 Parser parser(script, parsing_flags, NULL, NULL); | 5682 Parser parser(script, parsing_flags, NULL, NULL); |
5675 result = parser.ParseLazy(info); | 5683 result = parser.ParseLazy(info); |
5676 } else { | 5684 } else { |
5677 ScriptDataImpl* pre_data = info->pre_parse_data(); | 5685 ScriptDataImpl* pre_data = info->pre_parse_data(); |
(...skipping 11 matching lines...) Expand all Loading... |
5689 ASSERT(info->isolate()->has_pending_exception()); | 5697 ASSERT(info->isolate()->has_pending_exception()); |
5690 } else { | 5698 } else { |
5691 result = parser.ParseProgram(info); | 5699 result = parser.ParseProgram(info); |
5692 } | 5700 } |
5693 } | 5701 } |
5694 info->SetFunction(result); | 5702 info->SetFunction(result); |
5695 return (result != NULL); | 5703 return (result != NULL); |
5696 } | 5704 } |
5697 | 5705 |
5698 } } // namespace v8::internal | 5706 } } // namespace v8::internal |
OLD | NEW |