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 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 // Map the frame index into an index in the range 0..(var_count-1). | 543 int LocalVariable::BitIndexIn(intptr_t fixed_parameter_count) const { |
544 int LocalVariable::BitIndexIn(intptr_t var_count) const { | |
545 ASSERT(!is_captured()); | 544 ASSERT(!is_captured()); |
546 // Parameters have positive indexes with the lowest index being 2. Locals | 545 // Parameters have positive indexes with the lowest index being 2. Locals |
547 // and copied parameters have negative indexes with the lowest (closest to | 546 // and copied parameters have negative indexes with the lowest (closest to |
548 // zero) index being ParsedFunction::kFirstLocalSlotIndex. | 547 // zero) index being ParsedFunction::kFirstLocalSlotIndex. |
549 if (index() > 0) { | 548 if (index() > 0) { |
550 // Shift non-negative indexes so that the lowest one is 0. | 549 // Shift non-negative indexes so that the lowest one is 0. |
551 return index() - 2; | 550 return (fixed_parameter_count - 1) - (index() - 2); |
552 } else { | 551 } else { |
553 // 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 |
554 // non-positive) and index them backward from the end of the vector. | 553 // non-positive). |
555 return (var_count - 1) + | 554 return fixed_parameter_count - |
556 (index() - ParsedFunction::kFirstLocalSlotIndex); | 555 (index() - ParsedFunction::kFirstLocalSlotIndex); |
557 } | 556 } |
558 } | 557 } |
559 | 558 |
560 | 559 |
561 } // namespace dart | 560 } // namespace dart |
OLD | NEW |