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 2824 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2835 expected_property_count = function_state.expected_property_count(); | 2835 expected_property_count = function_state.expected_property_count(); |
2836 if (use_temp_zone) { | 2836 if (use_temp_zone) { |
2837 // If the preconditions are correct the function body should never be | 2837 // If the preconditions are correct the function body should never be |
2838 // accessed, but do this anyway for better behaviour if they're wrong. | 2838 // accessed, but do this anyway for better behaviour if they're wrong. |
2839 body = nullptr; | 2839 body = nullptr; |
2840 } | 2840 } |
2841 } | 2841 } |
2842 | 2842 |
2843 // Parsing the body may change the language mode in our scope. | 2843 // Parsing the body may change the language mode in our scope. |
2844 language_mode = scope->language_mode(); | 2844 language_mode = scope->language_mode(); |
2845 scope->DeclareArguments(ast_value_factory()); | |
2846 if (main_scope != scope) { | |
2847 main_scope->DeclareArguments(ast_value_factory()); | |
2848 } | |
2849 | 2845 |
2850 // Validate name and parameter names. We can do this only after parsing the | 2846 // Validate name and parameter names. We can do this only after parsing the |
2851 // function, since the function can declare itself strict. | 2847 // function, since the function can declare itself strict. |
2852 CheckFunctionName(language_mode, function_name, function_name_validity, | 2848 CheckFunctionName(language_mode, function_name, function_name_validity, |
2853 function_name_location, CHECK_OK); | 2849 function_name_location, CHECK_OK); |
2854 const bool allow_duplicate_parameters = | 2850 const bool allow_duplicate_parameters = |
2855 is_sloppy(language_mode) && formals.is_simple && !IsConciseMethod(kind); | 2851 is_sloppy(language_mode) && formals.is_simple && !IsConciseMethod(kind); |
2856 ValidateFormalParameters(language_mode, allow_duplicate_parameters, | 2852 ValidateFormalParameters(language_mode, allow_duplicate_parameters, |
2857 CHECK_OK); | 2853 CHECK_OK); |
2858 | 2854 |
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3427 | 3423 |
3428 result->Add(init_block, zone()); | 3424 result->Add(init_block, zone()); |
3429 result->Add(inner_block, zone()); | 3425 result->Add(inner_block, zone()); |
3430 } else { | 3426 } else { |
3431 DCHECK_EQ(inner_scope, function_scope); | 3427 DCHECK_EQ(inner_scope, function_scope); |
3432 if (is_sloppy(function_scope->language_mode())) { | 3428 if (is_sloppy(function_scope->language_mode())) { |
3433 InsertSloppyBlockFunctionVarBindings(function_scope); | 3429 InsertSloppyBlockFunctionVarBindings(function_scope); |
3434 } | 3430 } |
3435 } | 3431 } |
3436 | 3432 |
3433 if (!IsArrowFunction(kind)) { | |
3434 function_scope->DeclareArguments(ast_value_factory()); | |
adamk
2016/09/22 18:16:57
Please add a comment here about why this must be d
| |
3435 } | |
3436 | |
3437 if (function_type == FunctionLiteral::kNamedExpression) { | 3437 if (function_type == FunctionLiteral::kNamedExpression) { |
3438 Statement* statement; | 3438 Statement* statement; |
3439 if (function_scope->LookupLocal(function_name) == nullptr) { | 3439 if (function_scope->LookupLocal(function_name) == nullptr) { |
3440 // Now that we know the language mode, we can create the const assignment | 3440 // Now that we know the language mode, we can create the const assignment |
3441 // in the previously reserved spot. | 3441 // in the previously reserved spot. |
3442 DCHECK_EQ(function_scope, scope()); | 3442 DCHECK_EQ(function_scope, scope()); |
3443 Variable* fvar = function_scope->DeclareFunctionVar(function_name); | 3443 Variable* fvar = function_scope->DeclareFunctionVar(function_name); |
3444 VariableProxy* fproxy = factory()->NewVariableProxy(fvar); | 3444 VariableProxy* fproxy = factory()->NewVariableProxy(fvar); |
3445 statement = factory()->NewExpressionStatement( | 3445 statement = factory()->NewExpressionStatement( |
3446 factory()->NewAssignment(Token::INIT, fproxy, | 3446 factory()->NewAssignment(Token::INIT, fproxy, |
(...skipping 2156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5603 | 5603 |
5604 return final_loop; | 5604 return final_loop; |
5605 } | 5605 } |
5606 | 5606 |
5607 #undef CHECK_OK | 5607 #undef CHECK_OK |
5608 #undef CHECK_OK_VOID | 5608 #undef CHECK_OK_VOID |
5609 #undef CHECK_FAILED | 5609 #undef CHECK_FAILED |
5610 | 5610 |
5611 } // namespace internal | 5611 } // namespace internal |
5612 } // namespace v8 | 5612 } // namespace v8 |
OLD | NEW |