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

Side by Side Diff: src/parser.cc

Issue 1397513004: Don't throw on assignment to function name binding in harmony sloppy mode (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 2 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 | « no previous file | test/mjsunit/harmony/regress/regress-4482.js » ('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/parser.h" 5 #include "src/parser.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/ast-literal-reindexer.h" 9 #include "src/ast-literal-reindexer.h"
10 #include "src/bailout-reason.h" 10 #include "src/bailout-reason.h"
(...skipping 4698 matching lines...) Expand 10 before | Expand all | Expand 10 after
4709 result->Add(init_block, zone()); 4709 result->Add(init_block, zone());
4710 result->Add(inner_block, zone()); 4710 result->Add(inner_block, zone());
4711 } 4711 }
4712 4712
4713 if (function_type == FunctionLiteral::NAMED_EXPRESSION) { 4713 if (function_type == FunctionLiteral::NAMED_EXPRESSION) {
4714 // Now that we know the language mode, we can create the const assignment 4714 // Now that we know the language mode, we can create the const assignment
4715 // in the previously reserved spot. 4715 // in the previously reserved spot.
4716 // NOTE: We create a proxy and resolve it here so that in the 4716 // NOTE: We create a proxy and resolve it here so that in the
4717 // future we can change the AST to only refer to VariableProxies 4717 // future we can change the AST to only refer to VariableProxies
4718 // instead of Variables and Proxies as is the case now. 4718 // instead of Variables and Proxies as is the case now.
4719 Token::Value fvar_init_op = Token::INIT_CONST_LEGACY; 4719 const bool use_strict_const = is_strict(scope_->language_mode());
4720 bool use_strict_const = is_strict(scope_->language_mode()) || 4720 Token::Value fvar_init_op =
4721 (!allow_legacy_const() && allow_harmony_sloppy()); 4721 use_strict_const ? Token::INIT_CONST : Token::INIT_CONST_LEGACY;
4722 if (use_strict_const) {
4723 fvar_init_op = Token::INIT_CONST;
4724 }
4725 VariableMode fvar_mode = use_strict_const ? CONST : CONST_LEGACY; 4722 VariableMode fvar_mode = use_strict_const ? CONST : CONST_LEGACY;
4726 Variable* fvar = new (zone()) 4723 Variable* fvar = new (zone())
4727 Variable(scope_, function_name, fvar_mode, Variable::NORMAL, 4724 Variable(scope_, function_name, fvar_mode, Variable::NORMAL,
4728 kCreatedInitialized, kNotAssigned); 4725 kCreatedInitialized, kNotAssigned);
4729 VariableProxy* proxy = factory()->NewVariableProxy(fvar); 4726 VariableProxy* proxy = factory()->NewVariableProxy(fvar);
4730 VariableDeclaration* fvar_declaration = factory()->NewVariableDeclaration( 4727 VariableDeclaration* fvar_declaration = factory()->NewVariableDeclaration(
4731 proxy, fvar_mode, scope_, RelocInfo::kNoPosition); 4728 proxy, fvar_mode, scope_, RelocInfo::kNoPosition);
4732 scope_->DeclareFunctionVar(fvar_declaration); 4729 scope_->DeclareFunctionVar(fvar_declaration);
4733 4730
4734 VariableProxy* fproxy = scope_->NewUnresolved(factory(), function_name); 4731 VariableProxy* fproxy = scope_->NewUnresolved(factory(), function_name);
(...skipping 1605 matching lines...) Expand 10 before | Expand all | Expand 10 after
6340 6337
6341 Expression* Parser::SpreadCallNew(Expression* function, 6338 Expression* Parser::SpreadCallNew(Expression* function,
6342 ZoneList<v8::internal::Expression*>* args, 6339 ZoneList<v8::internal::Expression*>* args,
6343 int pos) { 6340 int pos) {
6344 args->InsertAt(0, function, zone()); 6341 args->InsertAt(0, function, zone());
6345 6342
6346 return factory()->NewCallRuntime(Context::REFLECT_CONSTRUCT_INDEX, args, pos); 6343 return factory()->NewCallRuntime(Context::REFLECT_CONSTRUCT_INDEX, args, pos);
6347 } 6344 }
6348 } // namespace internal 6345 } // namespace internal
6349 } // namespace v8 6346 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/harmony/regress/regress-4482.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698