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