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

Side by Side Diff: src/parser.cc

Issue 1303033003: Fix function scoping issue (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix tests Created 5 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 | « no previous file | test/mjsunit/regress/regress-520029.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 4003 matching lines...) Expand 10 before | Expand all | Expand 10 after
4014 // under which we compile is _not_ a declaration scope. This holds because 4014 // under which we compile is _not_ a declaration scope. This holds because
4015 // in all normal cases, function declarations are fully hoisted to a 4015 // in all normal cases, function declarations are fully hoisted to a
4016 // declaration scope and compiled relative to that. 4016 // declaration scope and compiled relative to that.
4017 // - (2) is the case iff the current declaration scope is still the original 4017 // - (2) is the case iff the current declaration scope is still the original
4018 // one relative to the deserialized scope chain. Otherwise we must be 4018 // one relative to the deserialized scope chain. Otherwise we must be
4019 // compiling a function in an inner declaration scope in the eval, e.g. a 4019 // compiling a function in an inner declaration scope in the eval, e.g. a
4020 // nested function, and hoisting works normally relative to that. 4020 // nested function, and hoisting works normally relative to that.
4021 Scope* declaration_scope = scope_->DeclarationScope(); 4021 Scope* declaration_scope = scope_->DeclarationScope();
4022 Scope* original_declaration_scope = original_scope_->DeclarationScope(); 4022 Scope* original_declaration_scope = original_scope_->DeclarationScope();
4023 Scope* scope = function_type == FunctionLiteral::DECLARATION && 4023 Scope* scope = function_type == FunctionLiteral::DECLARATION &&
4024 is_sloppy(language_mode) && !allow_harmony_sloppy() && 4024 is_sloppy(language_mode) &&
4025 !allow_harmony_sloppy_function() &&
4025 (original_scope_ == original_declaration_scope || 4026 (original_scope_ == original_declaration_scope ||
4026 declaration_scope != original_declaration_scope) 4027 declaration_scope != original_declaration_scope)
4027 ? NewScope(declaration_scope, FUNCTION_SCOPE, kind) 4028 ? NewScope(declaration_scope, FUNCTION_SCOPE, kind)
4028 : NewScope(scope_, FUNCTION_SCOPE, kind); 4029 : NewScope(scope_, FUNCTION_SCOPE, kind);
4029 scope->SetLanguageMode(language_mode); 4030 scope->SetLanguageMode(language_mode);
4030 ZoneList<Statement*>* body = NULL; 4031 ZoneList<Statement*>* body = NULL;
4031 int arity = -1; 4032 int arity = -1;
4032 int materialized_literal_count = -1; 4033 int materialized_literal_count = -1;
4033 int expected_property_count = -1; 4034 int expected_property_count = -1;
4034 DuplicateFinder duplicate_finder(scanner()->unicode_cache()); 4035 DuplicateFinder duplicate_finder(scanner()->unicode_cache());
(...skipping 2007 matching lines...) Expand 10 before | Expand all | Expand 10 after
6042 Expression* Parser::SpreadCallNew(Expression* function, 6043 Expression* Parser::SpreadCallNew(Expression* function,
6043 ZoneList<v8::internal::Expression*>* args, 6044 ZoneList<v8::internal::Expression*>* args,
6044 int pos) { 6045 int pos) {
6045 args->InsertAt(0, function, zone()); 6046 args->InsertAt(0, function, zone());
6046 6047
6047 return factory()->NewCallRuntime( 6048 return factory()->NewCallRuntime(
6048 ast_value_factory()->reflect_construct_string(), NULL, args, pos); 6049 ast_value_factory()->reflect_construct_string(), NULL, args, pos);
6049 } 6050 }
6050 } // namespace internal 6051 } // namespace internal
6051 } // namespace v8 6052 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-520029.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698