| 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 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 518 context_scope.SetIsFinalAt(0, true); | 518 context_scope.SetIsFinalAt(0, true); |
| 519 const AbstractType& type = AbstractType::Handle(func.ParameterTypeAt(0)); | 519 const AbstractType& type = AbstractType::Handle(func.ParameterTypeAt(0)); |
| 520 context_scope.SetTypeAt(0, type); | 520 context_scope.SetTypeAt(0, type); |
| 521 context_scope.SetContextIndexAt(0, 0); | 521 context_scope.SetContextIndexAt(0, 0); |
| 522 context_scope.SetContextLevelAt(0, 0); | 522 context_scope.SetContextLevelAt(0, 0); |
| 523 ASSERT(context_scope.num_variables() == kNumCapturedVars); // Verify count. | 523 ASSERT(context_scope.num_variables() == kNumCapturedVars); // Verify count. |
| 524 return context_scope.raw(); | 524 return context_scope.raw(); |
| 525 } | 525 } |
| 526 | 526 |
| 527 | 527 |
| 528 bool LocalVariable::Equals(const LocalVariable& other) const { | 528 bool LocalVariable::Equals(const LocalVariable* other) const { |
| 529 if (HasIndex() && other.HasIndex() && (index() == other.index())) { | 529 if (HasIndex() && other->HasIndex() && (index() == other->index())) { |
| 530 if (is_captured() == other.is_captured()) { | 530 if (is_captured() == other->is_captured()) { |
| 531 if (!is_captured()) { | 531 if (!is_captured()) { |
| 532 return true; | 532 return true; |
| 533 } | 533 } |
| 534 if (owner()->context_level() == other.owner()->context_level()) { | 534 if (owner()->context_level() == other->owner()->context_level()) { |
| 535 return true; | 535 return true; |
| 536 } | 536 } |
| 537 } | 537 } |
| 538 } | 538 } |
| 539 return false; | 539 return false; |
| 540 } | 540 } |
| 541 | 541 |
| 542 | 542 |
| 543 int LocalVariable::BitIndexIn(intptr_t fixed_parameter_count) const { | 543 int LocalVariable::BitIndexIn(intptr_t fixed_parameter_count) const { |
| 544 ASSERT(!is_captured()); | 544 ASSERT(!is_captured()); |
| 545 // Parameters have positive indexes with the lowest index being 2. Locals | 545 // Parameters have positive indexes with the lowest index being 2. Locals |
| 546 // and copied parameters have negative indexes with the lowest (closest to | 546 // and copied parameters have negative indexes with the lowest (closest to |
| 547 // zero) index being ParsedFunction::kFirstLocalSlotIndex. | 547 // zero) index being ParsedFunction::kFirstLocalSlotIndex. |
| 548 if (index() > 0) { | 548 if (index() > 0) { |
| 549 // Shift non-negative indexes so that the lowest one is 0. | 549 // Shift non-negative indexes so that the lowest one is 0. |
| 550 return (fixed_parameter_count - 1) - (index() - 2); | 550 return (fixed_parameter_count - 1) - (index() - 2); |
| 551 } else { | 551 } else { |
| 552 // Shift negative indexes so that the lowest one is 0 (they are still | 552 // Shift negative indexes so that the lowest one is 0 (they are still |
| 553 // non-positive). | 553 // non-positive). |
| 554 return fixed_parameter_count - | 554 return fixed_parameter_count - |
| 555 (index() - ParsedFunction::kFirstLocalSlotIndex); | 555 (index() - ParsedFunction::kFirstLocalSlotIndex); |
| 556 } | 556 } |
| 557 } | 557 } |
| 558 | 558 |
| 559 | 559 |
| 560 } // namespace dart | 560 } // namespace dart |
| OLD | NEW |