Chromium Code Reviews| 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 3639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3650 result->Add(init_block, zone()); | 3650 result->Add(init_block, zone()); |
| 3651 result->Add(inner_block, zone()); | 3651 result->Add(inner_block, zone()); |
| 3652 } else { | 3652 } else { |
| 3653 DCHECK_EQ(inner_scope, function_scope); | 3653 DCHECK_EQ(inner_scope, function_scope); |
| 3654 if (is_sloppy(function_scope->language_mode())) { | 3654 if (is_sloppy(function_scope->language_mode())) { |
| 3655 InsertSloppyBlockFunctionVarBindings(function_scope); | 3655 InsertSloppyBlockFunctionVarBindings(function_scope); |
| 3656 } | 3656 } |
| 3657 } | 3657 } |
| 3658 | 3658 |
| 3659 if (function_type == FunctionLiteral::kNamedExpression) { | 3659 if (function_type == FunctionLiteral::kNamedExpression) { |
| 3660 // Now that we know the language mode, we can create the const assignment | 3660 Statement* statement; |
| 3661 // in the previously reserved spot. | 3661 if (function_scope->Lookup(function_name) == nullptr) { |
|
adamk
2016/09/19 18:00:39
Do you mean LookupLocal? Please add a test that wo
| |
| 3662 DCHECK_EQ(function_scope, scope()); | 3662 // Now that we know the language mode, we can create the const assignment |
| 3663 Variable* fvar = function_scope->DeclareFunctionVar(function_name); | 3663 // in the previously reserved spot. |
| 3664 VariableProxy* fproxy = factory()->NewVariableProxy(fvar); | 3664 DCHECK_EQ(function_scope, scope()); |
| 3665 result->Set(kFunctionNameAssignmentIndex, | 3665 Variable* fvar = function_scope->DeclareFunctionVar(function_name); |
| 3666 factory()->NewExpressionStatement( | 3666 VariableProxy* fproxy = factory()->NewVariableProxy(fvar); |
| 3667 factory()->NewAssignment(Token::INIT, fproxy, | 3667 statement = factory()->NewExpressionStatement( |
| 3668 factory()->NewThisFunction(pos), | 3668 factory()->NewAssignment(Token::INIT, fproxy, |
| 3669 kNoSourcePosition), | 3669 factory()->NewThisFunction(pos), |
| 3670 kNoSourcePosition)); | 3670 kNoSourcePosition), |
| 3671 kNoSourcePosition); | |
| 3672 } else { | |
| 3673 statement = factory()->NewEmptyStatement(0); | |
|
adamk
2016/09/19 18:00:39
Why 0 instead of kNoSourcePosition?
| |
| 3674 } | |
| 3675 result->Set(kFunctionNameAssignmentIndex, statement); | |
| 3671 } | 3676 } |
| 3672 | 3677 |
| 3673 MarkCollectedTailCallExpressions(); | 3678 MarkCollectedTailCallExpressions(); |
| 3674 return result; | 3679 return result; |
| 3675 } | 3680 } |
| 3676 | 3681 |
| 3677 PreParser::PreParseResult Parser::ParseLazyFunctionBodyWithPreParser( | 3682 PreParser::PreParseResult Parser::ParseLazyFunctionBodyWithPreParser( |
| 3678 SingletonLogger* logger, bool may_abort) { | 3683 SingletonLogger* logger, bool may_abort) { |
| 3679 // This function may be called on a background thread too; record only the | 3684 // This function may be called on a background thread too; record only the |
| 3680 // main thread preparse times. | 3685 // main thread preparse times. |
| (...skipping 2128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5809 node->Print(Isolate::Current()); | 5814 node->Print(Isolate::Current()); |
| 5810 } | 5815 } |
| 5811 #endif // DEBUG | 5816 #endif // DEBUG |
| 5812 | 5817 |
| 5813 #undef CHECK_OK | 5818 #undef CHECK_OK |
| 5814 #undef CHECK_OK_VOID | 5819 #undef CHECK_OK_VOID |
| 5815 #undef CHECK_FAILED | 5820 #undef CHECK_FAILED |
| 5816 | 5821 |
| 5817 } // namespace internal | 5822 } // namespace internal |
| 5818 } // namespace v8 | 5823 } // namespace v8 |
| OLD | NEW |