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

Side by Side Diff: vm/scopes.cc

Issue 11667012: Convert all symbols accessor to return read only handles so that it is not necessary to create a ne… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 7 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 | Annotate | Revision Log
« no previous file with comments | « vm/scopes.h ('k') | vm/stub_code_ia32.cc » ('j') | vm/symbols.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/ast.h" 7 #include "vm/ast.h"
8 #include "vm/bit_vector.h" 8 #include "vm/bit_vector.h"
9 #include "vm/object.h" 9 #include "vm/object.h"
10 #include "vm/parser.h" 10 #include "vm/parser.h"
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 desc.info.scope_id = var->owner()->context_level(); 252 desc.info.scope_id = var->owner()->context_level();
253 } else { 253 } else {
254 desc.info.kind = RawLocalVarDescriptors::kStackVar; 254 desc.info.kind = RawLocalVarDescriptors::kStackVar;
255 desc.info.scope_id = *scope_id; 255 desc.info.scope_id = *scope_id;
256 } 256 }
257 desc.info.begin_pos = var->token_pos(); 257 desc.info.begin_pos = var->token_pos();
258 desc.info.end_pos = var->owner()->end_token_pos(); 258 desc.info.end_pos = var->owner()->end_token_pos();
259 desc.info.index = var->index(); 259 desc.info.index = var->index();
260 vars->Add(desc); 260 vars->Add(desc);
261 } else if (var->name().Equals( 261 } else if (var->name().Equals(
262 Symbols::Name(Symbols::kSavedEntryContextVar))) { 262 Symbols::Name(Symbols::kSavedEntryContextVarId))) {
263 // This is the local variable in which the function saves the 263 // This is the local variable in which the function saves the
264 // caller's chain of closure contexts (caller's CTX register). 264 // caller's chain of closure contexts (caller's CTX register).
265 VarDesc desc; 265 VarDesc desc;
266 desc.name = &var->name(); 266 desc.name = &var->name();
267 desc.info.kind = RawLocalVarDescriptors::kContextChain; 267 desc.info.kind = RawLocalVarDescriptors::kContextChain;
268 desc.info.scope_id = 0; 268 desc.info.scope_id = 0;
269 desc.info.begin_pos = 0; 269 desc.info.begin_pos = 0;
270 desc.info.end_pos = 0; 270 desc.info.end_pos = 0;
271 desc.info.index = var->index(); 271 desc.info.index = var->index();
272 vars->Add(desc); 272 vars->Add(desc);
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 519
520 RawContextScope* LocalScope::CreateImplicitClosureScope(const Function& func) { 520 RawContextScope* LocalScope::CreateImplicitClosureScope(const Function& func) {
521 static const intptr_t kNumCapturedVars = 1; 521 static const intptr_t kNumCapturedVars = 1;
522 522
523 // Create a ContextScope with space for kNumCapturedVars descriptors. 523 // Create a ContextScope with space for kNumCapturedVars descriptors.
524 const ContextScope& context_scope = 524 const ContextScope& context_scope =
525 ContextScope::Handle(ContextScope::New(kNumCapturedVars)); 525 ContextScope::Handle(ContextScope::New(kNumCapturedVars));
526 526
527 // Create a descriptor for 'this' variable. 527 // Create a descriptor for 'this' variable.
528 context_scope.SetTokenIndexAt(0, func.token_pos()); 528 context_scope.SetTokenIndexAt(0, func.token_pos());
529 context_scope.SetNameAt(0, Symbols::ThisHandle()); 529 context_scope.SetNameAt(0, Symbols::This());
530 context_scope.SetIsFinalAt(0, true); 530 context_scope.SetIsFinalAt(0, true);
531 context_scope.SetIsConstAt(0, false); 531 context_scope.SetIsConstAt(0, false);
532 const AbstractType& type = AbstractType::Handle(func.ParameterTypeAt(0)); 532 const AbstractType& type = AbstractType::Handle(func.ParameterTypeAt(0));
533 context_scope.SetTypeAt(0, type); 533 context_scope.SetTypeAt(0, type);
534 context_scope.SetContextIndexAt(0, 0); 534 context_scope.SetContextIndexAt(0, 0);
535 context_scope.SetContextLevelAt(0, 0); 535 context_scope.SetContextLevelAt(0, 0);
536 ASSERT(context_scope.num_variables() == kNumCapturedVars); // Verify count. 536 ASSERT(context_scope.num_variables() == kNumCapturedVars); // Verify count.
537 return context_scope.raw(); 537 return context_scope.raw();
538 } 538 }
539 539
(...skipping 24 matching lines...) Expand all
564 } else { 564 } else {
565 // Shift negative indexes so that the lowest one is 0 (they are still 565 // Shift negative indexes so that the lowest one is 0 (they are still
566 // non-positive). 566 // non-positive).
567 return fixed_parameter_count - 567 return fixed_parameter_count -
568 (index() - ParsedFunction::kFirstLocalSlotIndex); 568 (index() - ParsedFunction::kFirstLocalSlotIndex);
569 } 569 }
570 } 570 }
571 571
572 572
573 } // namespace dart 573 } // namespace dart
OLDNEW
« no previous file with comments | « vm/scopes.h ('k') | vm/stub_code_ia32.cc » ('j') | vm/symbols.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698