| 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 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 } | 213 } |
| 214 | 214 |
| 215 | 215 |
| 216 // The parser creates internal variables that start with ":" | 216 // The parser creates internal variables that start with ":" |
| 217 static bool IsInternalIdentifier(const String& str) { | 217 static bool IsInternalIdentifier(const String& str) { |
| 218 ASSERT(str.Length() > 0); | 218 ASSERT(str.Length() > 0); |
| 219 return str.CharAt(0) == ':'; | 219 return str.CharAt(0) == ':'; |
| 220 } | 220 } |
| 221 | 221 |
| 222 | 222 |
| 223 // Add variables that are declared in this scope to vars, then collect | 223 // Add visible variables that are declared in this scope to vars, then |
| 224 // variables of children, followed by siblings. | 224 // collect visible variables of children, followed by siblings. |
| 225 void LocalScope::CollectLocalVariables(GrowableArray<VarDesc>* vars, | 225 void LocalScope::CollectLocalVariables(GrowableArray<VarDesc>* vars, |
| 226 int16_t* scope_id) { | 226 int16_t* scope_id) { |
| 227 (*scope_id)++; | 227 (*scope_id)++; |
| 228 if (HasContextLevel() && | 228 if (HasContextLevel() && |
| 229 ((parent() == NULL) || | 229 ((parent() == NULL) || |
| 230 (!parent()->HasContextLevel()) || | 230 (!parent()->HasContextLevel()) || |
| 231 (parent()->context_level() != context_level()))) { | 231 (parent()->context_level() != context_level()))) { |
| 232 // This is the outermost scope with a context level or this scope's | 232 // This is the outermost scope with a context level or this scope's |
| 233 // context level differs from its parent's level. | 233 // context level differs from its parent's level. |
| 234 VarDesc desc; | 234 VarDesc desc; |
| 235 desc.name = &String::Handle(); // No name. | 235 desc.name = &String::Handle(); // No name. |
| 236 desc.info.kind = RawLocalVarDescriptors::kContextLevel; | 236 desc.info.kind = RawLocalVarDescriptors::kContextLevel; |
| 237 desc.info.scope_id = *scope_id; | 237 desc.info.scope_id = *scope_id; |
| 238 desc.info.begin_pos = begin_token_pos(); | 238 desc.info.begin_pos = begin_token_pos(); |
| 239 desc.info.end_pos = end_token_pos(); | 239 desc.info.end_pos = end_token_pos(); |
| 240 desc.info.index = context_level(); | 240 desc.info.index = context_level(); |
| 241 vars->Add(desc); | 241 vars->Add(desc); |
| 242 } | 242 } |
| 243 for (int i = 0; i < this->variables_.length(); i++) { | 243 for (int i = 0; i < this->variables_.length(); i++) { |
| 244 LocalVariable* var = variables_[i]; | 244 LocalVariable* var = variables_[i]; |
| 245 if (var->owner() == this) { | 245 if ((var->owner() == this) && !var->is_invisible()) { |
| 246 if (!IsInternalIdentifier(var->name())) { | 246 if (!IsInternalIdentifier(var->name())) { |
| 247 // This is a regular Dart variable, either stack-based or captured. | 247 // This is a regular Dart variable, either stack-based or captured. |
| 248 VarDesc desc; | 248 VarDesc desc; |
| 249 desc.name = &var->name(); | 249 desc.name = &var->name(); |
| 250 if (var->is_captured()) { | 250 if (var->is_captured()) { |
| 251 desc.info.kind = RawLocalVarDescriptors::kContextVar; | 251 desc.info.kind = RawLocalVarDescriptors::kContextVar; |
| 252 ASSERT(var->owner() != NULL); | 252 ASSERT(var->owner() != NULL); |
| 253 ASSERT(var->owner()->context_level() >= 0); | 253 ASSERT(var->owner()->context_level() >= 0); |
| 254 desc.info.scope_id = var->owner()->context_level(); | 254 desc.info.scope_id = var->owner()->context_level(); |
| 255 } else { | 255 } else { |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 600 return fixed_parameter_count - (index() - kParamEndSlotFromFp); | 600 return fixed_parameter_count - (index() - kParamEndSlotFromFp); |
| 601 } else { | 601 } else { |
| 602 // Shift negative indexes so that the lowest one is 0 (they are still | 602 // Shift negative indexes so that the lowest one is 0 (they are still |
| 603 // non-positive). | 603 // non-positive). |
| 604 return fixed_parameter_count - (index() - kFirstLocalSlotFromFp); | 604 return fixed_parameter_count - (index() - kFirstLocalSlotFromFp); |
| 605 } | 605 } |
| 606 } | 606 } |
| 607 | 607 |
| 608 | 608 |
| 609 } // namespace dart | 609 } // namespace dart |
| OLD | NEW |