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

Side by Side Diff: src/scopes.cc

Issue 867153003: new classes: special construct stub for derived classs and TDZ for `this`. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: CHECK_OK fixed Created 5 years, 10 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/scopes.h ('k') | src/x64/builtins-x64.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/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/scopes.h" 7 #include "src/scopes.h"
8 8
9 #include "src/accessors.h" 9 #include "src/accessors.h"
10 #include "src/bootstrapper.h" 10 #include "src/bootstrapper.h"
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 PrintF("global : "); 284 PrintF("global : ");
285 top->interface()->Print(); 285 top->interface()->Print();
286 } 286 }
287 #endif 287 #endif
288 288
289 info->PrepareForCompilation(scope); 289 info->PrepareForCompilation(scope);
290 return true; 290 return true;
291 } 291 }
292 292
293 293
294 void Scope::Initialize() { 294 void Scope::Initialize(bool uninitialized_this) {
295 DCHECK(!already_resolved()); 295 DCHECK(!already_resolved());
296 296
297 // Add this scope as a new inner scope of the outer scope. 297 // Add this scope as a new inner scope of the outer scope.
298 if (outer_scope_ != NULL) { 298 if (outer_scope_ != NULL) {
299 outer_scope_->inner_scopes_.Add(this, zone()); 299 outer_scope_->inner_scopes_.Add(this, zone());
300 scope_inside_with_ = outer_scope_->scope_inside_with_ || is_with_scope(); 300 scope_inside_with_ = outer_scope_->scope_inside_with_ || is_with_scope();
301 } else { 301 } else {
302 scope_inside_with_ = is_with_scope(); 302 scope_inside_with_ = is_with_scope();
303 } 303 }
304 304
305 // Declare convenience variables. 305 // Declare convenience variables.
306 // Declare and allocate receiver (even for the script scope, and even 306 // Declare and allocate receiver (even for the script scope, and even
307 // if naccesses_ == 0). 307 // if naccesses_ == 0).
308 // NOTE: When loading parameters in the script scope, we must take 308 // NOTE: When loading parameters in the script scope, we must take
309 // care not to access them as properties of the global object, but 309 // care not to access them as properties of the global object, but
310 // instead load them directly from the stack. Currently, the only 310 // instead load them directly from the stack. Currently, the only
311 // such parameter is 'this' which is passed on the stack when 311 // such parameter is 'this' which is passed on the stack when
312 // invoking scripts 312 // invoking scripts
313 if (is_declaration_scope()) { 313 if (is_declaration_scope()) {
314 Variable* var = 314 DCHECK(!uninitialized_this || is_function_scope());
315 variables_.Declare(this, 315 DCHECK(FLAG_experimental_classes || !uninitialized_this);
316 ast_value_factory_->this_string(), 316 Variable* var = variables_.Declare(
317 VAR, 317 this, ast_value_factory_->this_string(),
318 false, 318 uninitialized_this ? CONST : VAR, false, Variable::THIS,
319 Variable::THIS, 319 uninitialized_this ? kNeedsInitialization : kCreatedInitialized);
320 kCreatedInitialized);
321 var->AllocateTo(Variable::PARAMETER, -1); 320 var->AllocateTo(Variable::PARAMETER, -1);
322 receiver_ = var; 321 receiver_ = var;
323 } else { 322 } else {
324 DCHECK(outer_scope() != NULL); 323 DCHECK(outer_scope() != NULL);
325 receiver_ = outer_scope()->receiver(); 324 receiver_ = outer_scope()->receiver();
326 } 325 }
327 326
328 if (is_function_scope()) { 327 if (is_function_scope()) {
329 // Declare 'arguments' variable which exists in all functions. 328 // Declare 'arguments' variable which exists in all functions.
330 // Note that it might never be accessed, in which case it won't be 329 // Note that it might never be accessed, in which case it won't be
(...skipping 1108 matching lines...) Expand 10 before | Expand all | Expand 10 after
1439 } 1438 }
1440 1439
1441 1440
1442 int Scope::ContextLocalCount() const { 1441 int Scope::ContextLocalCount() const {
1443 if (num_heap_slots() == 0) return 0; 1442 if (num_heap_slots() == 0) return 0;
1444 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - 1443 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS -
1445 (function_ != NULL && function_->proxy()->var()->IsContextSlot() ? 1 : 0); 1444 (function_ != NULL && function_->proxy()->var()->IsContextSlot() ? 1 : 0);
1446 } 1445 }
1447 1446
1448 } } // namespace v8::internal 1447 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/scopes.h ('k') | src/x64/builtins-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698