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 <memory> | 7 #include <memory> |
8 | 8 |
9 #include "src/api.h" | 9 #include "src/api.h" |
10 #include "src/ast/ast-expression-rewriter.h" | 10 #include "src/ast/ast-expression-rewriter.h" |
(...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
667 | 667 |
668 set_default_eager_compile_hint(can_compile_lazily | 668 set_default_eager_compile_hint(can_compile_lazily |
669 ? FunctionLiteral::kShouldLazyCompile | 669 ? FunctionLiteral::kShouldLazyCompile |
670 : FunctionLiteral::kShouldEagerCompile); | 670 : FunctionLiteral::kShouldEagerCompile); |
671 set_allow_lazy(FLAG_lazy && info->allow_lazy_parsing() && | 671 set_allow_lazy(FLAG_lazy && info->allow_lazy_parsing() && |
672 !info->is_native() && info->extension() == nullptr); | 672 !info->is_native() && info->extension() == nullptr); |
673 set_allow_natives(FLAG_allow_natives_syntax || info->is_native()); | 673 set_allow_natives(FLAG_allow_natives_syntax || info->is_native()); |
674 set_allow_tailcalls(FLAG_harmony_tailcalls && !info->is_native() && | 674 set_allow_tailcalls(FLAG_harmony_tailcalls && !info->is_native() && |
675 info->isolate()->is_tail_call_elimination_enabled()); | 675 info->isolate()->is_tail_call_elimination_enabled()); |
676 set_allow_harmony_do_expressions(FLAG_harmony_do_expressions); | 676 set_allow_harmony_do_expressions(FLAG_harmony_do_expressions); |
677 set_allow_harmony_for_in(FLAG_harmony_for_in); | |
678 set_allow_harmony_function_sent(FLAG_harmony_function_sent); | 677 set_allow_harmony_function_sent(FLAG_harmony_function_sent); |
679 set_allow_harmony_restrictive_declarations( | 678 set_allow_harmony_restrictive_declarations( |
680 FLAG_harmony_restrictive_declarations); | 679 FLAG_harmony_restrictive_declarations); |
681 set_allow_harmony_async_await(FLAG_harmony_async_await); | 680 set_allow_harmony_async_await(FLAG_harmony_async_await); |
682 set_allow_harmony_restrictive_generators(FLAG_harmony_restrictive_generators); | 681 set_allow_harmony_restrictive_generators(FLAG_harmony_restrictive_generators); |
683 set_allow_harmony_trailing_commas(FLAG_harmony_trailing_commas); | 682 set_allow_harmony_trailing_commas(FLAG_harmony_trailing_commas); |
684 set_allow_harmony_class_fields(FLAG_harmony_class_fields); | 683 set_allow_harmony_class_fields(FLAG_harmony_class_fields); |
685 for (int feature = 0; feature < v8::Isolate::kUseCounterFeatureCount; | 684 for (int feature = 0; feature < v8::Isolate::kUseCounterFeatureCount; |
686 ++feature) { | 685 ++feature) { |
687 use_counts_[feature] = 0; | 686 use_counts_[feature] = 0; |
(...skipping 1274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1962 // so that (later on during parsing), the equivalent of | 1961 // so that (later on during parsing), the equivalent of |
1963 // | 1962 // |
1964 // for (x in enumerable) body | 1963 // for (x in enumerable) body |
1965 // | 1964 // |
1966 // is added as a second statement to it. | 1965 // is added as a second statement to it. |
1967 Block* Parser::RewriteForVarInLegacy(const ForInfo& for_info) { | 1966 Block* Parser::RewriteForVarInLegacy(const ForInfo& for_info) { |
1968 const DeclarationParsingResult::Declaration& decl = | 1967 const DeclarationParsingResult::Declaration& decl = |
1969 for_info.parsing_result.declarations[0]; | 1968 for_info.parsing_result.declarations[0]; |
1970 if (!IsLexicalVariableMode(for_info.parsing_result.descriptor.mode) && | 1969 if (!IsLexicalVariableMode(for_info.parsing_result.descriptor.mode) && |
1971 decl.pattern->IsVariableProxy() && decl.initializer != nullptr) { | 1970 decl.pattern->IsVariableProxy() && decl.initializer != nullptr) { |
1972 DCHECK(!allow_harmony_for_in()); | |
1973 ++use_counts_[v8::Isolate::kForInInitializer]; | 1971 ++use_counts_[v8::Isolate::kForInInitializer]; |
1974 const AstRawString* name = decl.pattern->AsVariableProxy()->raw_name(); | 1972 const AstRawString* name = decl.pattern->AsVariableProxy()->raw_name(); |
1975 VariableProxy* single_var = NewUnresolved(name); | 1973 VariableProxy* single_var = NewUnresolved(name); |
1976 Block* init_block = factory()->NewBlock( | 1974 Block* init_block = factory()->NewBlock( |
1977 nullptr, 2, true, for_info.parsing_result.descriptor.declaration_pos); | 1975 nullptr, 2, true, for_info.parsing_result.descriptor.declaration_pos); |
1978 init_block->statements()->Add( | 1976 init_block->statements()->Add( |
1979 factory()->NewExpressionStatement( | 1977 factory()->NewExpressionStatement( |
1980 factory()->NewAssignment(Token::ASSIGN, single_var, | 1978 factory()->NewAssignment(Token::ASSIGN, single_var, |
1981 decl.initializer, kNoSourcePosition), | 1979 decl.initializer, kNoSourcePosition), |
1982 kNoSourcePosition), | 1980 kNoSourcePosition), |
(...skipping 1336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3319 | 3317 |
3320 DCHECK_EQ(Token::LBRACE, scanner()->current_token()); | 3318 DCHECK_EQ(Token::LBRACE, scanner()->current_token()); |
3321 | 3319 |
3322 if (reusable_preparser_ == NULL) { | 3320 if (reusable_preparser_ == NULL) { |
3323 reusable_preparser_ = new PreParser(zone(), &scanner_, ast_value_factory(), | 3321 reusable_preparser_ = new PreParser(zone(), &scanner_, ast_value_factory(), |
3324 NULL, stack_limit_); | 3322 NULL, stack_limit_); |
3325 reusable_preparser_->set_allow_lazy(true); | 3323 reusable_preparser_->set_allow_lazy(true); |
3326 #define SET_ALLOW(name) reusable_preparser_->set_allow_##name(allow_##name()); | 3324 #define SET_ALLOW(name) reusable_preparser_->set_allow_##name(allow_##name()); |
3327 SET_ALLOW(natives); | 3325 SET_ALLOW(natives); |
3328 SET_ALLOW(harmony_do_expressions); | 3326 SET_ALLOW(harmony_do_expressions); |
3329 SET_ALLOW(harmony_for_in); | |
3330 SET_ALLOW(harmony_function_sent); | 3327 SET_ALLOW(harmony_function_sent); |
3331 SET_ALLOW(harmony_restrictive_declarations); | 3328 SET_ALLOW(harmony_restrictive_declarations); |
3332 SET_ALLOW(harmony_async_await); | 3329 SET_ALLOW(harmony_async_await); |
3333 SET_ALLOW(harmony_trailing_commas); | 3330 SET_ALLOW(harmony_trailing_commas); |
3334 SET_ALLOW(harmony_class_fields); | 3331 SET_ALLOW(harmony_class_fields); |
3335 #undef SET_ALLOW | 3332 #undef SET_ALLOW |
3336 } | 3333 } |
3337 // Aborting inner function preparsing would leave scopes in an inconsistent | 3334 // Aborting inner function preparsing would leave scopes in an inconsistent |
3338 // state; we don't parse inner functions in the abortable mode anyway. | 3335 // state; we don't parse inner functions in the abortable mode anyway. |
3339 DCHECK(!is_inner_function || !may_abort); | 3336 DCHECK(!is_inner_function || !may_abort); |
(...skipping 2124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5464 | 5461 |
5465 return final_loop; | 5462 return final_loop; |
5466 } | 5463 } |
5467 | 5464 |
5468 #undef CHECK_OK | 5465 #undef CHECK_OK |
5469 #undef CHECK_OK_VOID | 5466 #undef CHECK_OK_VOID |
5470 #undef CHECK_FAILED | 5467 #undef CHECK_FAILED |
5471 | 5468 |
5472 } // namespace internal | 5469 } // namespace internal |
5473 } // namespace v8 | 5470 } // namespace v8 |
OLD | NEW |