| 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" |
| 11 #include "vm/symbols.h" |
| 11 | 12 |
| 12 namespace dart { | 13 namespace dart { |
| 13 | 14 |
| 14 const char* SourceLabel::kDefaultLabelName = ":L"; | 15 const char* SourceLabel::kDefaultLabelName = ":L"; |
| 15 | 16 |
| 16 const char* LocalVariable::kSavedContextVarName = ":saved_entry_context_var"; | 17 const char* LocalVariable::kSavedContextVarName = ":saved_entry_context_var"; |
| 17 | 18 |
| 18 | 19 |
| 19 int SourceLabel::FunctionLevel() const { | 20 int SourceLabel::FunctionLevel() const { |
| 20 ASSERT(owner() != NULL); | 21 ASSERT(owner() != NULL); |
| (...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 504 | 505 |
| 505 | 506 |
| 506 RawContextScope* LocalScope::CreateImplicitClosureScope(const Function& func) { | 507 RawContextScope* LocalScope::CreateImplicitClosureScope(const Function& func) { |
| 507 static const intptr_t kNumCapturedVars = 1; | 508 static const intptr_t kNumCapturedVars = 1; |
| 508 | 509 |
| 509 // Create a ContextScope with space for kNumCapturedVars descriptors. | 510 // Create a ContextScope with space for kNumCapturedVars descriptors. |
| 510 const ContextScope& context_scope = | 511 const ContextScope& context_scope = |
| 511 ContextScope::Handle(ContextScope::New(kNumCapturedVars)); | 512 ContextScope::Handle(ContextScope::New(kNumCapturedVars)); |
| 512 | 513 |
| 513 // Create a descriptor for 'this' variable. | 514 // Create a descriptor for 'this' variable. |
| 514 const String& name = String::Handle(String::NewSymbol("this")); | 515 const String& name = String::Handle(Symbols::New("this")); |
| 515 context_scope.SetTokenIndexAt(0, func.token_pos()); | 516 context_scope.SetTokenIndexAt(0, func.token_pos()); |
| 516 context_scope.SetNameAt(0, name); | 517 context_scope.SetNameAt(0, name); |
| 517 context_scope.SetIsFinalAt(0, true); | 518 context_scope.SetIsFinalAt(0, true); |
| 518 const AbstractType& type = AbstractType::Handle(func.ParameterTypeAt(0)); | 519 const AbstractType& type = AbstractType::Handle(func.ParameterTypeAt(0)); |
| 519 context_scope.SetTypeAt(0, type); | 520 context_scope.SetTypeAt(0, type); |
| 520 context_scope.SetContextIndexAt(0, 0); | 521 context_scope.SetContextIndexAt(0, 0); |
| 521 context_scope.SetContextLevelAt(0, 0); | 522 context_scope.SetContextLevelAt(0, 0); |
| 522 ASSERT(context_scope.num_variables() == kNumCapturedVars); // Verify count. | 523 ASSERT(context_scope.num_variables() == kNumCapturedVars); // Verify count. |
| 523 return context_scope.raw(); | 524 return context_scope.raw(); |
| 524 } | 525 } |
| (...skipping 26 matching lines...) Expand all Loading... |
| 551 } else { | 552 } else { |
| 552 // Shift negative indexes so that the lowest one is 0 (they are still | 553 // Shift negative indexes so that the lowest one is 0 (they are still |
| 553 // non-positive) and index them backward from the end of the vector. | 554 // non-positive) and index them backward from the end of the vector. |
| 554 return (var_count - 1) + | 555 return (var_count - 1) + |
| 555 (index() - ParsedFunction::kFirstLocalSlotIndex); | 556 (index() - ParsedFunction::kFirstLocalSlotIndex); |
| 556 } | 557 } |
| 557 } | 558 } |
| 558 | 559 |
| 559 | 560 |
| 560 } // namespace dart | 561 } // namespace dart |
| OLD | NEW |