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/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/api.h" | 7 #include "src/api.h" |
8 #include "src/ast.h" | 8 #include "src/ast.h" |
9 #include "src/base/platform/platform.h" | 9 #include "src/base/platform/platform.h" |
10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
(...skipping 711 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
722 pending_error_message_(NULL), | 722 pending_error_message_(NULL), |
723 pending_error_arg_(NULL), | 723 pending_error_arg_(NULL), |
724 pending_error_char_arg_(NULL) { | 724 pending_error_char_arg_(NULL) { |
725 DCHECK(!script_.is_null()); | 725 DCHECK(!script_.is_null()); |
726 isolate_->set_ast_node_id(0); | 726 isolate_->set_ast_node_id(0); |
727 set_allow_harmony_scoping(!info->is_native() && FLAG_harmony_scoping); | 727 set_allow_harmony_scoping(!info->is_native() && FLAG_harmony_scoping); |
728 set_allow_modules(!info->is_native() && FLAG_harmony_modules); | 728 set_allow_modules(!info->is_native() && FLAG_harmony_modules); |
729 set_allow_natives_syntax(FLAG_allow_natives_syntax || info->is_native()); | 729 set_allow_natives_syntax(FLAG_allow_natives_syntax || info->is_native()); |
730 set_allow_lazy(false); // Must be explicitly enabled. | 730 set_allow_lazy(false); // Must be explicitly enabled. |
731 set_allow_generators(FLAG_harmony_generators); | 731 set_allow_generators(FLAG_harmony_generators); |
732 set_allow_for_of(FLAG_harmony_iteration); | |
733 set_allow_arrow_functions(FLAG_harmony_arrow_functions); | 732 set_allow_arrow_functions(FLAG_harmony_arrow_functions); |
734 set_allow_harmony_numeric_literals(FLAG_harmony_numeric_literals); | 733 set_allow_harmony_numeric_literals(FLAG_harmony_numeric_literals); |
735 for (int feature = 0; feature < v8::Isolate::kUseCounterFeatureCount; | 734 for (int feature = 0; feature < v8::Isolate::kUseCounterFeatureCount; |
736 ++feature) { | 735 ++feature) { |
737 use_counts_[feature] = 0; | 736 use_counts_[feature] = 0; |
738 } | 737 } |
739 } | 738 } |
740 | 739 |
741 | 740 |
742 FunctionLiteral* Parser::ParseProgram() { | 741 FunctionLiteral* Parser::ParseProgram() { |
(...skipping 2009 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2752 if (loop != NULL) loop->Initialize(cond, body); | 2751 if (loop != NULL) loop->Initialize(cond, body); |
2753 return loop; | 2752 return loop; |
2754 } | 2753 } |
2755 | 2754 |
2756 | 2755 |
2757 bool Parser::CheckInOrOf(bool accept_OF, | 2756 bool Parser::CheckInOrOf(bool accept_OF, |
2758 ForEachStatement::VisitMode* visit_mode) { | 2757 ForEachStatement::VisitMode* visit_mode) { |
2759 if (Check(Token::IN)) { | 2758 if (Check(Token::IN)) { |
2760 *visit_mode = ForEachStatement::ENUMERATE; | 2759 *visit_mode = ForEachStatement::ENUMERATE; |
2761 return true; | 2760 return true; |
2762 } else if (allow_for_of() && accept_OF && | 2761 } else if (accept_OF && CheckContextualKeyword(CStrVector("of"))) { |
2763 CheckContextualKeyword(CStrVector("of"))) { | |
2764 *visit_mode = ForEachStatement::ITERATE; | 2762 *visit_mode = ForEachStatement::ITERATE; |
2765 return true; | 2763 return true; |
2766 } | 2764 } |
2767 return false; | 2765 return false; |
2768 } | 2766 } |
2769 | 2767 |
2770 | 2768 |
2771 void Parser::InitializeForEachStatement(ForEachStatement* stmt, | 2769 void Parser::InitializeForEachStatement(ForEachStatement* stmt, |
2772 Expression* each, | 2770 Expression* each, |
2773 Expression* subject, | 2771 Expression* subject, |
(...skipping 960 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3734 DCHECK_EQ(Token::LBRACE, scanner()->current_token()); | 3732 DCHECK_EQ(Token::LBRACE, scanner()->current_token()); |
3735 | 3733 |
3736 if (reusable_preparser_ == NULL) { | 3734 if (reusable_preparser_ == NULL) { |
3737 intptr_t stack_limit = isolate()->stack_guard()->real_climit(); | 3735 intptr_t stack_limit = isolate()->stack_guard()->real_climit(); |
3738 reusable_preparser_ = new PreParser(&scanner_, NULL, stack_limit); | 3736 reusable_preparser_ = new PreParser(&scanner_, NULL, stack_limit); |
3739 reusable_preparser_->set_allow_harmony_scoping(allow_harmony_scoping()); | 3737 reusable_preparser_->set_allow_harmony_scoping(allow_harmony_scoping()); |
3740 reusable_preparser_->set_allow_modules(allow_modules()); | 3738 reusable_preparser_->set_allow_modules(allow_modules()); |
3741 reusable_preparser_->set_allow_natives_syntax(allow_natives_syntax()); | 3739 reusable_preparser_->set_allow_natives_syntax(allow_natives_syntax()); |
3742 reusable_preparser_->set_allow_lazy(true); | 3740 reusable_preparser_->set_allow_lazy(true); |
3743 reusable_preparser_->set_allow_generators(allow_generators()); | 3741 reusable_preparser_->set_allow_generators(allow_generators()); |
3744 reusable_preparser_->set_allow_for_of(allow_for_of()); | |
3745 reusable_preparser_->set_allow_arrow_functions(allow_arrow_functions()); | 3742 reusable_preparser_->set_allow_arrow_functions(allow_arrow_functions()); |
3746 reusable_preparser_->set_allow_harmony_numeric_literals( | 3743 reusable_preparser_->set_allow_harmony_numeric_literals( |
3747 allow_harmony_numeric_literals()); | 3744 allow_harmony_numeric_literals()); |
3748 } | 3745 } |
3749 PreParser::PreParseResult result = | 3746 PreParser::PreParseResult result = |
3750 reusable_preparser_->PreParseLazyFunction(strict_mode(), | 3747 reusable_preparser_->PreParseLazyFunction(strict_mode(), |
3751 is_generator(), | 3748 is_generator(), |
3752 logger); | 3749 logger); |
3753 return result; | 3750 return result; |
3754 } | 3751 } |
(...skipping 1050 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4805 info()->SetAstValueFactory(ast_value_factory_); | 4802 info()->SetAstValueFactory(ast_value_factory_); |
4806 } | 4803 } |
4807 ast_value_factory_ = NULL; | 4804 ast_value_factory_ = NULL; |
4808 | 4805 |
4809 InternalizeUseCounts(); | 4806 InternalizeUseCounts(); |
4810 | 4807 |
4811 return (result != NULL); | 4808 return (result != NULL); |
4812 } | 4809 } |
4813 | 4810 |
4814 } } // namespace v8::internal | 4811 } } // namespace v8::internal |
OLD | NEW |