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 737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
748 pending_error_message_(NULL), | 748 pending_error_message_(NULL), |
749 pending_error_arg_(NULL), | 749 pending_error_arg_(NULL), |
750 pending_error_char_arg_(NULL), | 750 pending_error_char_arg_(NULL), |
751 total_preparse_skipped_(0), | 751 total_preparse_skipped_(0), |
752 pre_parse_timer_(NULL) { | 752 pre_parse_timer_(NULL) { |
753 DCHECK(!script().is_null() || info->source_stream() != NULL); | 753 DCHECK(!script().is_null() || info->source_stream() != NULL); |
754 set_allow_harmony_scoping(!info->is_native() && FLAG_harmony_scoping); | 754 set_allow_harmony_scoping(!info->is_native() && FLAG_harmony_scoping); |
755 set_allow_modules(!info->is_native() && FLAG_harmony_modules); | 755 set_allow_modules(!info->is_native() && FLAG_harmony_modules); |
756 set_allow_natives_syntax(FLAG_allow_natives_syntax || info->is_native()); | 756 set_allow_natives_syntax(FLAG_allow_natives_syntax || info->is_native()); |
757 set_allow_lazy(false); // Must be explicitly enabled. | 757 set_allow_lazy(false); // Must be explicitly enabled. |
758 set_allow_generators(FLAG_harmony_generators); | |
759 set_allow_arrow_functions(FLAG_harmony_arrow_functions); | 758 set_allow_arrow_functions(FLAG_harmony_arrow_functions); |
760 set_allow_harmony_numeric_literals(FLAG_harmony_numeric_literals); | 759 set_allow_harmony_numeric_literals(FLAG_harmony_numeric_literals); |
761 set_allow_classes(FLAG_harmony_classes); | 760 set_allow_classes(FLAG_harmony_classes); |
762 set_allow_harmony_object_literals(FLAG_harmony_object_literals); | 761 set_allow_harmony_object_literals(FLAG_harmony_object_literals); |
763 for (int feature = 0; feature < v8::Isolate::kUseCounterFeatureCount; | 762 for (int feature = 0; feature < v8::Isolate::kUseCounterFeatureCount; |
764 ++feature) { | 763 ++feature) { |
765 use_counts_[feature] = 0; | 764 use_counts_[feature] = 0; |
766 } | 765 } |
767 if (info->ast_value_factory() == NULL) { | 766 if (info->ast_value_factory() == NULL) { |
768 // info takes ownership of AstValueFactory. | 767 // info takes ownership of AstValueFactory. |
(...skipping 1117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1886 | 1885 |
1887 Statement* Parser::ParseFunctionDeclaration( | 1886 Statement* Parser::ParseFunctionDeclaration( |
1888 ZoneList<const AstRawString*>* names, bool* ok) { | 1887 ZoneList<const AstRawString*>* names, bool* ok) { |
1889 // FunctionDeclaration :: | 1888 // FunctionDeclaration :: |
1890 // 'function' Identifier '(' FormalParameterListopt ')' '{' FunctionBody '}' | 1889 // 'function' Identifier '(' FormalParameterListopt ')' '{' FunctionBody '}' |
1891 // GeneratorDeclaration :: | 1890 // GeneratorDeclaration :: |
1892 // 'function' '*' Identifier '(' FormalParameterListopt ')' | 1891 // 'function' '*' Identifier '(' FormalParameterListopt ')' |
1893 // '{' FunctionBody '}' | 1892 // '{' FunctionBody '}' |
1894 Expect(Token::FUNCTION, CHECK_OK); | 1893 Expect(Token::FUNCTION, CHECK_OK); |
1895 int pos = position(); | 1894 int pos = position(); |
1896 bool is_generator = allow_generators() && Check(Token::MUL); | 1895 bool is_generator = Check(Token::MUL); |
1897 bool is_strict_reserved = false; | 1896 bool is_strict_reserved = false; |
1898 const AstRawString* name = ParseIdentifierOrStrictReservedWord( | 1897 const AstRawString* name = ParseIdentifierOrStrictReservedWord( |
1899 &is_strict_reserved, CHECK_OK); | 1898 &is_strict_reserved, CHECK_OK); |
1900 FunctionLiteral* fun = | 1899 FunctionLiteral* fun = |
1901 ParseFunctionLiteral(name, scanner()->location(), is_strict_reserved, | 1900 ParseFunctionLiteral(name, scanner()->location(), is_strict_reserved, |
1902 is_generator ? FunctionKind::kGeneratorFunction | 1901 is_generator ? FunctionKind::kGeneratorFunction |
1903 : FunctionKind::kNormalFunction, | 1902 : FunctionKind::kNormalFunction, |
1904 pos, FunctionLiteral::DECLARATION, | 1903 pos, FunctionLiteral::DECLARATION, |
1905 FunctionLiteral::NORMAL_ARITY, CHECK_OK); | 1904 FunctionLiteral::NORMAL_ARITY, CHECK_OK); |
1906 // Even if we're not at the top-level of the global or a function | 1905 // Even if we're not at the top-level of the global or a function |
(...skipping 1853 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3760 pre_parse_timer_->Start(); | 3759 pre_parse_timer_->Start(); |
3761 } | 3760 } |
3762 DCHECK_EQ(Token::LBRACE, scanner()->current_token()); | 3761 DCHECK_EQ(Token::LBRACE, scanner()->current_token()); |
3763 | 3762 |
3764 if (reusable_preparser_ == NULL) { | 3763 if (reusable_preparser_ == NULL) { |
3765 reusable_preparser_ = new PreParser(&scanner_, NULL, stack_limit_); | 3764 reusable_preparser_ = new PreParser(&scanner_, NULL, stack_limit_); |
3766 reusable_preparser_->set_allow_harmony_scoping(allow_harmony_scoping()); | 3765 reusable_preparser_->set_allow_harmony_scoping(allow_harmony_scoping()); |
3767 reusable_preparser_->set_allow_modules(allow_modules()); | 3766 reusable_preparser_->set_allow_modules(allow_modules()); |
3768 reusable_preparser_->set_allow_natives_syntax(allow_natives_syntax()); | 3767 reusable_preparser_->set_allow_natives_syntax(allow_natives_syntax()); |
3769 reusable_preparser_->set_allow_lazy(true); | 3768 reusable_preparser_->set_allow_lazy(true); |
3770 reusable_preparser_->set_allow_generators(allow_generators()); | |
3771 reusable_preparser_->set_allow_arrow_functions(allow_arrow_functions()); | 3769 reusable_preparser_->set_allow_arrow_functions(allow_arrow_functions()); |
3772 reusable_preparser_->set_allow_harmony_numeric_literals( | 3770 reusable_preparser_->set_allow_harmony_numeric_literals( |
3773 allow_harmony_numeric_literals()); | 3771 allow_harmony_numeric_literals()); |
3774 reusable_preparser_->set_allow_classes(allow_classes()); | 3772 reusable_preparser_->set_allow_classes(allow_classes()); |
3775 reusable_preparser_->set_allow_harmony_object_literals( | 3773 reusable_preparser_->set_allow_harmony_object_literals( |
3776 allow_harmony_object_literals()); | 3774 allow_harmony_object_literals()); |
3777 } | 3775 } |
3778 PreParser::PreParseResult result = | 3776 PreParser::PreParseResult result = |
3779 reusable_preparser_->PreParseLazyFunction(strict_mode(), | 3777 reusable_preparser_->PreParseLazyFunction(strict_mode(), |
3780 is_generator(), | 3778 is_generator(), |
(...skipping 1104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4885 | 4883 |
4886 // We cannot internalize on a background thread; a foreground task will take | 4884 // We cannot internalize on a background thread; a foreground task will take |
4887 // care of calling Parser::Internalize just before compilation. | 4885 // care of calling Parser::Internalize just before compilation. |
4888 | 4886 |
4889 if (compile_options() == ScriptCompiler::kProduceParserCache) { | 4887 if (compile_options() == ScriptCompiler::kProduceParserCache) { |
4890 if (result != NULL) *info_->cached_data() = recorder.GetScriptData(); | 4888 if (result != NULL) *info_->cached_data() = recorder.GetScriptData(); |
4891 log_ = NULL; | 4889 log_ = NULL; |
4892 } | 4890 } |
4893 } | 4891 } |
4894 } } // namespace v8::internal | 4892 } } // namespace v8::internal |
OLD | NEW |