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

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: Created 5 years, 11 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
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 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 PrintF("global : "); 294 PrintF("global : ");
295 top->interface()->Print(); 295 top->interface()->Print();
296 } 296 }
297 #endif 297 #endif
298 298
299 info->PrepareForCompilation(scope); 299 info->PrepareForCompilation(scope);
300 return true; 300 return true;
301 } 301 }
302 302
303 303
304 void Scope::Initialize() { 304 void Scope::Initialize(bool uninitialized_this) {
305 DCHECK(!already_resolved()); 305 DCHECK(!already_resolved());
306 306
307 // Add this scope as a new inner scope of the outer scope. 307 // Add this scope as a new inner scope of the outer scope.
308 if (outer_scope_ != NULL) { 308 if (outer_scope_ != NULL) {
309 outer_scope_->inner_scopes_.Add(this, zone()); 309 outer_scope_->inner_scopes_.Add(this, zone());
310 scope_inside_with_ = outer_scope_->scope_inside_with_ || is_with_scope(); 310 scope_inside_with_ = outer_scope_->scope_inside_with_ || is_with_scope();
311 } else { 311 } else {
312 scope_inside_with_ = is_with_scope(); 312 scope_inside_with_ = is_with_scope();
313 } 313 }
314 314
315 // Declare convenience variables. 315 // Declare convenience variables.
316 // Declare and allocate receiver (even for the script scope, and even 316 // Declare and allocate receiver (even for the script scope, and even
317 // if naccesses_ == 0). 317 // if naccesses_ == 0).
318 // NOTE: When loading parameters in the script scope, we must take 318 // NOTE: When loading parameters in the script scope, we must take
319 // care not to access them as properties of the global object, but 319 // care not to access them as properties of the global object, but
320 // instead load them directly from the stack. Currently, the only 320 // instead load them directly from the stack. Currently, the only
321 // such parameter is 'this' which is passed on the stack when 321 // such parameter is 'this' which is passed on the stack when
322 // invoking scripts 322 // invoking scripts
323 if (is_declaration_scope()) { 323 if (is_declaration_scope()) {
324 Variable* var = 324 DCHECK(!uninitialized_this || is_function_scope());
325 variables_.Declare(this, 325 DCHECK(FLAG_experimental_classes || !uninitialized_this);
326 ast_value_factory_->this_string(), 326 Variable* var = variables_.Declare(
327 VAR, 327 this, ast_value_factory_->this_string(),
328 false, 328 uninitialized_this ? CONST : VAR, false, Variable::THIS,
329 Variable::THIS, 329 uninitialized_this ? kNeedsInitialization : kCreatedInitialized);
330 kCreatedInitialized);
331 var->AllocateTo(Variable::PARAMETER, -1); 330 var->AllocateTo(Variable::PARAMETER, -1);
332 receiver_ = var; 331 receiver_ = var;
333 } else { 332 } else {
334 DCHECK(outer_scope() != NULL); 333 DCHECK(outer_scope() != NULL);
335 receiver_ = outer_scope()->receiver(); 334 receiver_ = outer_scope()->receiver();
336 } 335 }
337 336
338 if (is_function_scope()) { 337 if (is_function_scope()) {
339 // Declare 'arguments' variable which exists in all functions. 338 // Declare 'arguments' variable which exists in all functions.
340 // Note that it might never be accessed, in which case it won't be 339 // Note that it might never be accessed, in which case it won't be
(...skipping 1092 matching lines...) Expand 10 before | Expand all | Expand 10 after
1433 } 1432 }
1434 1433
1435 1434
1436 int Scope::ContextLocalCount() const { 1435 int Scope::ContextLocalCount() const {
1437 if (num_heap_slots() == 0) return 0; 1436 if (num_heap_slots() == 0) return 0;
1438 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - 1437 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS -
1439 (function_ != NULL && function_->proxy()->var()->IsContextSlot() ? 1 : 0); 1438 (function_ != NULL && function_->proxy()->var()->IsContextSlot() ? 1 : 0);
1440 } 1439 }
1441 1440
1442 } } // namespace v8::internal 1441 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698