| OLD | NEW |
| 1 // Copyright (c) 2011, 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/object.h" | 8 #include "vm/object.h" |
| 9 | 9 |
| 10 namespace dart { | 10 namespace dart { |
| 11 | 11 |
| 12 const char* SourceLabel::kDefaultLabelName = ":L"; | 12 const char* SourceLabel::kDefaultLabelName = ":L"; |
| 13 | 13 |
| 14 | 14 |
| 15 int SourceLabel::FunctionLevel() const { | 15 int SourceLabel::FunctionLevel() const { |
| 16 ASSERT(owner() != NULL); | 16 ASSERT(owner() != NULL); |
| 17 return owner()->function_level(); | 17 return owner()->function_level(); |
| 18 } | 18 } |
| 19 | 19 |
| 20 | 20 |
| 21 LocalScope::LocalScope(LocalScope* parent, int function_level, int loop_level) | 21 LocalScope::LocalScope(LocalScope* parent, int function_level, int loop_level) |
| 22 : parent_(parent), | 22 : parent_(parent), |
| 23 child_(NULL), | 23 child_(NULL), |
| 24 sibling_(NULL), | 24 sibling_(NULL), |
| 25 function_level_(function_level), | 25 function_level_(function_level), |
| 26 loop_level_(loop_level), | 26 loop_level_(loop_level), |
| 27 context_level_(LocalScope::kUnitializedContextLevel_), | 27 context_level_(LocalScope::kUnitializedContextLevel), |
| 28 num_context_variables_(0), | 28 num_context_variables_(0), |
| 29 end_token_index_(0), | 29 end_token_index_(0), |
| 30 variables_(), | 30 variables_(), |
| 31 labels_() { | 31 labels_() { |
| 32 // Hook this node into the children of the parent, unless the parent has a | 32 // Hook this node into the children of the parent, unless the parent has a |
| 33 // different function_level, since the local scope of a nested function can | 33 // different function_level, since the local scope of a nested function can |
| 34 // be discarded after it has been parsed. | 34 // be discarded after it has been parsed. |
| 35 if ((parent != NULL) && (parent->function_level() == function_level)) { | 35 if ((parent != NULL) && (parent->function_level() == function_level)) { |
| 36 sibling_ = parent->child_; | 36 sibling_ = parent->child_; |
| 37 parent->child_ = this; | 37 parent->child_ = this; |
| (...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 } | 468 } |
| 469 if (owner()->context_level() == other.owner()->context_level()) { | 469 if (owner()->context_level() == other.owner()->context_level()) { |
| 470 return true; | 470 return true; |
| 471 } | 471 } |
| 472 } | 472 } |
| 473 } | 473 } |
| 474 return false; | 474 return false; |
| 475 } | 475 } |
| 476 | 476 |
| 477 } // namespace dart | 477 } // namespace dart |
| OLD | NEW |