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

Side by Side Diff: runtime/vm/scopes.cc

Issue 1323813004: Changes to prepare for allowing script snapshots to be taken after running the main application (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: fix-long-line Created 5 years, 3 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 (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/scopes.h" 5 #include "vm/scopes.h"
6 6
7 #include "vm/object.h" 7 #include "vm/object.h"
8 #include "vm/stack_frame.h" 8 #include "vm/stack_frame.h"
9 #include "vm/symbols.h" 9 #include "vm/symbols.h"
10 10
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 const { 541 const {
542 // Since code generation for nested functions is postponed until first 542 // Since code generation for nested functions is postponed until first
543 // invocation, the function level of the closure scope can only be 1. 543 // invocation, the function level of the closure scope can only be 1.
544 ASSERT(function_level() == 1); 544 ASSERT(function_level() == 1);
545 545
546 // Count the number of referenced captured variables. 546 // Count the number of referenced captured variables.
547 intptr_t num_captured_vars = NumCapturedVariables(); 547 intptr_t num_captured_vars = NumCapturedVariables();
548 548
549 // Create a ContextScope with space for num_captured_vars descriptors. 549 // Create a ContextScope with space for num_captured_vars descriptors.
550 const ContextScope& context_scope = 550 const ContextScope& context_scope =
551 ContextScope::Handle(ContextScope::New(num_captured_vars)); 551 ContextScope::Handle(ContextScope::New(num_captured_vars, false));
552 552
553 // Create a descriptor for each referenced captured variable of enclosing 553 // Create a descriptor for each referenced captured variable of enclosing
554 // functions to preserve its name and its context allocation information. 554 // functions to preserve its name and its context allocation information.
555 int captured_idx = 0; 555 int captured_idx = 0;
556 for (int i = 0; i < num_variables(); i++) { 556 for (int i = 0; i < num_variables(); i++) {
557 LocalVariable* variable = VariableAt(i); 557 LocalVariable* variable = VariableAt(i);
558 // Preserve the aliases of captured variables belonging to outer scopes. 558 // Preserve the aliases of captured variables belonging to outer scopes.
559 if (variable->owner()->function_level() != 1) { 559 if (variable->owner()->function_level() != 1) {
560 context_scope.SetTokenIndexAt(captured_idx, variable->token_pos()); 560 context_scope.SetTokenIndexAt(captured_idx, variable->token_pos());
561 context_scope.SetNameAt(captured_idx, variable->name()); 561 context_scope.SetNameAt(captured_idx, variable->name());
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
631 if (sibling() != NULL) { sibling()->RecursivelyCaptureAllVariables(); } 631 if (sibling() != NULL) { sibling()->RecursivelyCaptureAllVariables(); }
632 if (child() != NULL) { child()->RecursivelyCaptureAllVariables(); } 632 if (child() != NULL) { child()->RecursivelyCaptureAllVariables(); }
633 } 633 }
634 634
635 635
636 RawContextScope* LocalScope::CreateImplicitClosureScope(const Function& func) { 636 RawContextScope* LocalScope::CreateImplicitClosureScope(const Function& func) {
637 static const intptr_t kNumCapturedVars = 1; 637 static const intptr_t kNumCapturedVars = 1;
638 638
639 // Create a ContextScope with space for kNumCapturedVars descriptors. 639 // Create a ContextScope with space for kNumCapturedVars descriptors.
640 const ContextScope& context_scope = 640 const ContextScope& context_scope =
641 ContextScope::Handle(ContextScope::New(kNumCapturedVars)); 641 ContextScope::Handle(ContextScope::New(kNumCapturedVars, true));
642 642
643 // Create a descriptor for 'this' variable. 643 // Create a descriptor for 'this' variable.
644 context_scope.SetTokenIndexAt(0, func.token_pos()); 644 context_scope.SetTokenIndexAt(0, func.token_pos());
645 context_scope.SetNameAt(0, Symbols::This()); 645 context_scope.SetNameAt(0, Symbols::This());
646 context_scope.SetIsFinalAt(0, true); 646 context_scope.SetIsFinalAt(0, true);
647 context_scope.SetIsConstAt(0, false); 647 context_scope.SetIsConstAt(0, false);
648 const AbstractType& type = AbstractType::Handle(func.ParameterTypeAt(0)); 648 const AbstractType& type = AbstractType::Handle(func.ParameterTypeAt(0));
649 context_scope.SetTypeAt(0, type); 649 context_scope.SetTypeAt(0, type);
650 context_scope.SetContextIndexAt(0, 0); 650 context_scope.SetContextIndexAt(0, 0);
651 context_scope.SetContextLevelAt(0, 0); 651 context_scope.SetContextLevelAt(0, 0);
(...skipping 27 matching lines...) Expand all
679 return fixed_parameter_count - (index() - kParamEndSlotFromFp); 679 return fixed_parameter_count - (index() - kParamEndSlotFromFp);
680 } else { 680 } else {
681 // Shift negative indexes so that the lowest one is 0 (they are still 681 // Shift negative indexes so that the lowest one is 0 (they are still
682 // non-positive). 682 // non-positive).
683 return fixed_parameter_count - (index() - kFirstLocalSlotFromFp); 683 return fixed_parameter_count - (index() - kFirstLocalSlotFromFp);
684 } 684 }
685 } 685 }
686 686
687 687
688 } // namespace dart 688 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698