| 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/object.h" | 7 #include "vm/object.h" |
| 8 #include "vm/stack_frame.h" | 8 #include "vm/stack_frame.h" |
| 9 #include "vm/symbols.h" | 9 #include "vm/symbols.h" |
| 10 | 10 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 while (current_scope != NULL) { | 44 while (current_scope != NULL) { |
| 45 if (current_scope == scope) { | 45 if (current_scope == scope) { |
| 46 return true; | 46 return true; |
| 47 } | 47 } |
| 48 current_scope = current_scope->parent(); | 48 current_scope = current_scope->parent(); |
| 49 } | 49 } |
| 50 return false; | 50 return false; |
| 51 } | 51 } |
| 52 | 52 |
| 53 | 53 |
| 54 void LocalScope::Clear() { | |
| 55 variables_.Clear(); | |
| 56 } | |
| 57 | |
| 58 | |
| 59 bool LocalScope::AddVariable(LocalVariable* variable) { | 54 bool LocalScope::AddVariable(LocalVariable* variable) { |
| 60 ASSERT(variable != NULL); | 55 ASSERT(variable != NULL); |
| 61 if (LocalLookupVariable(variable->name()) != NULL) { | 56 if (LocalLookupVariable(variable->name()) != NULL) { |
| 62 return false; | 57 return false; |
| 63 } | 58 } |
| 64 variables_.Add(variable); | 59 variables_.Add(variable); |
| 65 if (variable->owner() == NULL) { | 60 if (variable->owner() == NULL) { |
| 66 // Variables must be added to their owner scope first. Subsequent calls | 61 // Variables must be added to their owner scope first. Subsequent calls |
| 67 // to 'add' treat the variable as an alias. | 62 // to 'add' treat the variable as an alias. |
| 68 variable->set_owner(this); | 63 variable->set_owner(this); |
| (...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 636 return fixed_parameter_count - (index() - kParamEndSlotFromFp); | 631 return fixed_parameter_count - (index() - kParamEndSlotFromFp); |
| 637 } else { | 632 } else { |
| 638 // Shift negative indexes so that the lowest one is 0 (they are still | 633 // Shift negative indexes so that the lowest one is 0 (they are still |
| 639 // non-positive). | 634 // non-positive). |
| 640 return fixed_parameter_count - (index() - kFirstLocalSlotFromFp); | 635 return fixed_parameter_count - (index() - kFirstLocalSlotFromFp); |
| 641 } | 636 } |
| 642 } | 637 } |
| 643 | 638 |
| 644 | 639 |
| 645 } // namespace dart | 640 } // namespace dart |
| OLD | NEW |