Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(175)

Side by Side Diff: src/parsing/parser.cc

Issue 2232633002: Function name variable does not need a VariableDeclaration (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebased Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/ast/scopes.cc ('k') | test/cctest/test-parsing.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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.h" 10 #include "src/ast/ast.h"
(...skipping 4914 matching lines...) Expand 10 before | Expand all | Expand 10 after
4925 } else { 4925 } else {
4926 DCHECK_EQ(inner_scope, function_scope); 4926 DCHECK_EQ(inner_scope, function_scope);
4927 if (is_sloppy(function_scope->language_mode())) { 4927 if (is_sloppy(function_scope->language_mode())) {
4928 InsertSloppyBlockFunctionVarBindings(function_scope, nullptr, CHECK_OK); 4928 InsertSloppyBlockFunctionVarBindings(function_scope, nullptr, CHECK_OK);
4929 } 4929 }
4930 } 4930 }
4931 4931
4932 if (function_type == FunctionLiteral::kNamedExpression) { 4932 if (function_type == FunctionLiteral::kNamedExpression) {
4933 // Now that we know the language mode, we can create the const assignment 4933 // Now that we know the language mode, we can create the const assignment
4934 // in the previously reserved spot. 4934 // in the previously reserved spot.
4935 // NOTE: We create a proxy and resolve it here so that in the
4936 // future we can change the AST to only refer to VariableProxies
4937 // instead of Variables and Proxies as is the case now.
4938 DCHECK_EQ(function_scope, scope()); 4935 DCHECK_EQ(function_scope, scope());
4939 VariableMode fvar_mode = is_strict(language_mode()) ? CONST : CONST_LEGACY; 4936 Variable* fvar = function_scope->DeclareFunctionVar(function_name);
4940 Variable* fvar = new (zone())
4941 Variable(scope(), function_name, fvar_mode, Variable::NORMAL,
4942 kCreatedInitialized, kNotAssigned);
4943 VariableProxy* proxy = factory()->NewVariableProxy(fvar);
4944 VariableDeclaration* fvar_declaration =
4945 factory()->NewVariableDeclaration(proxy, scope(), kNoSourcePosition);
4946 function_scope->DeclareFunctionVar(fvar_declaration);
4947
4948 VariableProxy* fproxy = factory()->NewVariableProxy(fvar); 4937 VariableProxy* fproxy = factory()->NewVariableProxy(fvar);
4949 result->Set(kFunctionNameAssignmentIndex, 4938 result->Set(kFunctionNameAssignmentIndex,
4950 factory()->NewExpressionStatement( 4939 factory()->NewExpressionStatement(
4951 factory()->NewAssignment(Token::INIT, fproxy, 4940 factory()->NewAssignment(Token::INIT, fproxy,
4952 factory()->NewThisFunction(pos), 4941 factory()->NewThisFunction(pos),
4953 kNoSourcePosition), 4942 kNoSourcePosition),
4954 kNoSourcePosition)); 4943 kNoSourcePosition));
4955 } 4944 }
4956 4945
4957 MarkCollectedTailCallExpressions(); 4946 MarkCollectedTailCallExpressions();
(...skipping 2136 matching lines...) Expand 10 before | Expand all | Expand 10 after
7094 node->Print(Isolate::Current()); 7083 node->Print(Isolate::Current());
7095 } 7084 }
7096 #endif // DEBUG 7085 #endif // DEBUG
7097 7086
7098 #undef CHECK_OK 7087 #undef CHECK_OK
7099 #undef CHECK_OK_VOID 7088 #undef CHECK_OK_VOID
7100 #undef CHECK_FAILED 7089 #undef CHECK_FAILED
7101 7090
7102 } // namespace internal 7091 } // namespace internal
7103 } // namespace v8 7092 } // namespace v8
OLDNEW
« no previous file with comments | « src/ast/scopes.cc ('k') | test/cctest/test-parsing.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698