| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 if (current_scope == scope) { | 51 if (current_scope == scope) { |
| 52 return true; | 52 return true; |
| 53 } | 53 } |
| 54 current_scope = current_scope->parent(); | 54 current_scope = current_scope->parent(); |
| 55 } | 55 } |
| 56 return false; | 56 return false; |
| 57 } | 57 } |
| 58 | 58 |
| 59 | 59 |
| 60 bool LocalScope::AddVariable(LocalVariable* variable) { | 60 bool LocalScope::AddVariable(LocalVariable* variable) { |
| 61 ASSERT(variable != NULL); |
| 61 if (LocalLookupVariable(variable->name()) != NULL) { | 62 if (LocalLookupVariable(variable->name()) != NULL) { |
| 62 return false; | 63 return false; |
| 63 } | 64 } |
| 64 variables_.Add(variable); | 65 variables_.Add(variable); |
| 65 if (variable->owner() == NULL) { | 66 if (variable->owner() == NULL) { |
| 66 // Variables must be added to their owner scope first. Subsequent calls | 67 // Variables must be added to their owner scope first. Subsequent calls |
| 67 // to 'add' treat the variable as an alias. | 68 // to 'add' treat the variable as an alias. |
| 68 variable->set_owner(this); | 69 variable->set_owner(this); |
| 69 } | 70 } |
| 70 return true; | 71 return true; |
| (...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after 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). | 554 // non-positive). |
| 554 return fixed_parameter_count - | 555 return fixed_parameter_count - |
| 555 (index() - ParsedFunction::kFirstLocalSlotIndex); | 556 (index() - ParsedFunction::kFirstLocalSlotIndex); |
| 556 } | 557 } |
| 557 } | 558 } |
| 558 | 559 |
| 559 | 560 |
| 560 } // namespace dart | 561 } // namespace dart |
| OLD | NEW |