OLD | NEW |
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 Loading... |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |