| 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 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 ASSERT(str.Length() > 0); | 289 ASSERT(str.Length() > 0); |
| 290 return str.CharAt(0) == ':'; | 290 return str.CharAt(0) == ':'; |
| 291 } | 291 } |
| 292 | 292 |
| 293 | 293 |
| 294 // Add visible variables that are declared in this scope to vars, then | 294 // Add visible variables that are declared in this scope to vars, then |
| 295 // collect visible variables of children, followed by siblings. | 295 // collect visible variables of children, followed by siblings. |
| 296 void LocalScope::CollectLocalVariables(GrowableArray<VarDesc>* vars, | 296 void LocalScope::CollectLocalVariables(GrowableArray<VarDesc>* vars, |
| 297 int16_t* scope_id) { | 297 int16_t* scope_id) { |
| 298 (*scope_id)++; | 298 (*scope_id)++; |
| 299 if (HasContextLevel() && | 299 if (num_context_variables() > 0) { |
| 300 ((parent() == NULL) || | |
| 301 (!parent()->HasContextLevel()) || | |
| 302 (parent()->context_level() != context_level()))) { | |
| 303 // This is the outermost scope with a context level or this scope's | |
| 304 // context level differs from its parent's level. | |
| 305 VarDesc desc; | 300 VarDesc desc; |
| 306 desc.name = &Symbols::Empty(); // No name. | 301 desc.name = &Symbols::Empty(); // No name. |
| 307 desc.info.set_kind(RawLocalVarDescriptors::kContextLevel); | 302 desc.info.set_kind(RawLocalVarDescriptors::kContextLevel); |
| 308 desc.info.scope_id = *scope_id; | 303 desc.info.scope_id = *scope_id; |
| 309 desc.info.begin_pos = begin_token_pos(); | 304 desc.info.begin_pos = begin_token_pos(); |
| 310 desc.info.end_pos = end_token_pos(); | 305 desc.info.end_pos = end_token_pos(); |
| 311 desc.info.set_index(context_level()); | 306 desc.info.set_index(context_level()); |
| 312 vars->Add(desc); | 307 vars->Add(desc); |
| 313 } | 308 } |
| 314 for (int i = 0; i < this->variables_.length(); i++) { | 309 for (int i = 0; i < this->variables_.length(); i++) { |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 667 return fixed_parameter_count - (index() - kParamEndSlotFromFp); | 662 return fixed_parameter_count - (index() - kParamEndSlotFromFp); |
| 668 } else { | 663 } else { |
| 669 // Shift negative indexes so that the lowest one is 0 (they are still | 664 // Shift negative indexes so that the lowest one is 0 (they are still |
| 670 // non-positive). | 665 // non-positive). |
| 671 return fixed_parameter_count - (index() - kFirstLocalSlotFromFp); | 666 return fixed_parameter_count - (index() - kFirstLocalSlotFromFp); |
| 672 } | 667 } |
| 673 } | 668 } |
| 674 | 669 |
| 675 | 670 |
| 676 } // namespace dart | 671 } // namespace dart |
| OLD | NEW |