| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 #ifndef VM_SCOPES_H_ | 5 #ifndef VM_SCOPES_H_ |
| 6 #define VM_SCOPES_H_ | 6 #define VM_SCOPES_H_ |
| 7 | 7 |
| 8 #include "vm/allocation.h" | 8 #include "vm/allocation.h" |
| 9 #include "vm/assembler.h" | 9 #include "vm/assembler.h" |
| 10 #include "vm/growable_array.h" | 10 #include "vm/growable_array.h" |
| 11 | 11 |
| 12 namespace dart { | 12 namespace dart { |
| 13 | 13 |
| 14 class LocalScope; | 14 class LocalScope; |
| 15 class LocalVariable; | 15 class LocalVariable; |
| 16 class SourceLabel; | 16 class SourceLabel; |
| 17 | 17 |
| 18 | 18 |
| 19 class LocalVariable : public ZoneAllocated { | 19 class LocalVariable : public ZoneAllocated { |
| 20 public: | 20 public: |
| 21 LocalVariable(intptr_t token_index, const String& name, const Type& type) | 21 LocalVariable(intptr_t token_index, |
| 22 const String& name, |
| 23 const AbstractType& type) |
| 22 : token_index_(token_index), | 24 : token_index_(token_index), |
| 23 name_(name), | 25 name_(name), |
| 24 owner_(NULL), | 26 owner_(NULL), |
| 25 type_(type), | 27 type_(type), |
| 26 is_final_(false), | 28 is_final_(false), |
| 27 is_captured_(false), | 29 is_captured_(false), |
| 28 is_invisible_(false), | 30 is_invisible_(false), |
| 29 index_(LocalVariable::kUnitializedIndex_) { | 31 index_(LocalVariable::kUnitializedIndex_) { |
| 30 ASSERT(type.IsZoneHandle()); | 32 ASSERT(type.IsZoneHandle()); |
| 31 ASSERT(type.IsFinalized()); | 33 ASSERT(type.IsFinalized()); |
| 32 } | 34 } |
| 33 | 35 |
| 34 intptr_t token_index() const { return token_index_; } | 36 intptr_t token_index() const { return token_index_; } |
| 35 const String& name() const { return name_; } | 37 const String& name() const { return name_; } |
| 36 LocalScope* owner() const { return owner_; } | 38 LocalScope* owner() const { return owner_; } |
| 37 void set_owner(LocalScope* owner) { | 39 void set_owner(LocalScope* owner) { |
| 38 ASSERT(owner_ == NULL); | 40 ASSERT(owner_ == NULL); |
| 39 owner_ = owner; | 41 owner_ = owner; |
| 40 } | 42 } |
| 41 | 43 |
| 42 const Type& type() const { return type_; } | 44 const AbstractType& type() const { return type_; } |
| 43 | 45 |
| 44 bool is_final() const { return is_final_; } | 46 bool is_final() const { return is_final_; } |
| 45 void set_is_final() { is_final_ = true; } | 47 void set_is_final() { is_final_ = true; } |
| 46 | 48 |
| 47 bool is_captured() const { return is_captured_; } | 49 bool is_captured() const { return is_captured_; } |
| 48 void set_is_captured() { is_captured_ = true; } | 50 void set_is_captured() { is_captured_ = true; } |
| 49 | 51 |
| 50 bool HasIndex() const { | 52 bool HasIndex() const { |
| 51 return index_ != kUnitializedIndex_; | 53 return index_ != kUnitializedIndex_; |
| 52 } | 54 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 64 is_invisible_ = value; | 66 is_invisible_ = value; |
| 65 } | 67 } |
| 66 | 68 |
| 67 private: | 69 private: |
| 68 static const int kUnitializedIndex_ = INT_MIN; | 70 static const int kUnitializedIndex_ = INT_MIN; |
| 69 | 71 |
| 70 const intptr_t token_index_; | 72 const intptr_t token_index_; |
| 71 const String& name_; | 73 const String& name_; |
| 72 LocalScope* owner_; // Local scope declaring this variable. | 74 LocalScope* owner_; // Local scope declaring this variable. |
| 73 | 75 |
| 74 const Type& type_; // Declaration type of local variable. | 76 const AbstractType& type_; // Declaration type of local variable. |
| 75 | 77 |
| 76 bool is_final_; // If true, this variable is readonly. | 78 bool is_final_; // If true, this variable is readonly. |
| 77 bool is_captured_; // If true, this variable lives in the context, otherwise | 79 bool is_captured_; // If true, this variable lives in the context, otherwise |
| 78 // in the stack frame. | 80 // in the stack frame. |
| 79 bool is_invisible_; | 81 bool is_invisible_; |
| 80 int index_; // Allocation index in words relative to frame pointer (if not | 82 int index_; // Allocation index in words relative to frame pointer (if not |
| 81 // captured), or relative to the context pointer (if captured). | 83 // captured), or relative to the context pointer (if captured). |
| 82 | 84 |
| 83 friend class LocalScope; | 85 friend class LocalScope; |
| 84 DISALLOW_COPY_AND_ASSIGN(LocalVariable); | 86 DISALLOW_COPY_AND_ASSIGN(LocalVariable); |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 int num_context_variables_; // Only set if this scope is a context owner. | 280 int num_context_variables_; // Only set if this scope is a context owner. |
| 279 GrowableArray<LocalVariable*> variables_; | 281 GrowableArray<LocalVariable*> variables_; |
| 280 GrowableArray<SourceLabel*> labels_; | 282 GrowableArray<SourceLabel*> labels_; |
| 281 | 283 |
| 282 DISALLOW_COPY_AND_ASSIGN(LocalScope); | 284 DISALLOW_COPY_AND_ASSIGN(LocalScope); |
| 283 }; | 285 }; |
| 284 | 286 |
| 285 } // namespace dart | 287 } // namespace dart |
| 286 | 288 |
| 287 #endif // VM_SCOPES_H_ | 289 #endif // VM_SCOPES_H_ |
| OLD | NEW |