| 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 #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" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 const String& name, | 25 const String& name, |
| 26 const AbstractType& type) | 26 const AbstractType& type) |
| 27 : token_pos_(token_pos), | 27 : token_pos_(token_pos), |
| 28 name_(name), | 28 name_(name), |
| 29 owner_(NULL), | 29 owner_(NULL), |
| 30 type_(type), | 30 type_(type), |
| 31 const_value_(NULL), | 31 const_value_(NULL), |
| 32 is_final_(false), | 32 is_final_(false), |
| 33 is_captured_(false), | 33 is_captured_(false), |
| 34 is_invisible_(false), | 34 is_invisible_(false), |
| 35 always_live_(false), |
| 35 index_(LocalVariable::kUnitializedIndex) { | 36 index_(LocalVariable::kUnitializedIndex) { |
| 36 ASSERT(type.IsZoneHandle()); | 37 ASSERT(type.IsZoneHandle()); |
| 37 ASSERT(type.IsFinalized()); | 38 ASSERT(type.IsFinalized()); |
| 38 } | 39 } |
| 39 | 40 |
| 40 intptr_t token_pos() const { return token_pos_; } | 41 intptr_t token_pos() const { return token_pos_; } |
| 41 const String& name() const { return name_; } | 42 const String& name() const { return name_; } |
| 42 LocalScope* owner() const { return owner_; } | 43 LocalScope* owner() const { return owner_; } |
| 43 void set_owner(LocalScope* owner) { | 44 void set_owner(LocalScope* owner) { |
| 44 ASSERT(owner_ == NULL); | 45 ASSERT(owner_ == NULL); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 65 void set_index(int index) { | 66 void set_index(int index) { |
| 66 ASSERT(!HasIndex()); | 67 ASSERT(!HasIndex()); |
| 67 ASSERT(index != kUnitializedIndex); | 68 ASSERT(index != kUnitializedIndex); |
| 68 index_ = index; | 69 index_ = index; |
| 69 } | 70 } |
| 70 | 71 |
| 71 void set_invisible(bool value) { | 72 void set_invisible(bool value) { |
| 72 is_invisible_ = value; | 73 is_invisible_ = value; |
| 73 } | 74 } |
| 74 | 75 |
| 76 bool always_live() const { return always_live_; } |
| 77 void mark_as_always_live() { always_live_ = true; } |
| 78 |
| 75 bool IsConst() const { | 79 bool IsConst() const { |
| 76 return const_value_ != NULL; | 80 return const_value_ != NULL; |
| 77 } | 81 } |
| 78 | 82 |
| 79 void SetConstValue(const Instance& value) { | 83 void SetConstValue(const Instance& value) { |
| 80 ASSERT(value.IsZoneHandle() || value.IsReadOnlyHandle()); | 84 ASSERT(value.IsZoneHandle() || value.IsReadOnlyHandle()); |
| 81 const_value_ = &value; | 85 const_value_ = &value; |
| 82 } | 86 } |
| 83 | 87 |
| 84 const Instance* ConstValue() const { | 88 const Instance* ConstValue() const { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 102 LocalScope* owner_; // Local scope declaring this variable. | 106 LocalScope* owner_; // Local scope declaring this variable. |
| 103 | 107 |
| 104 const AbstractType& type_; // Declaration type of local variable. | 108 const AbstractType& type_; // Declaration type of local variable. |
| 105 | 109 |
| 106 const Instance* const_value_; // NULL or compile-time const value. | 110 const Instance* const_value_; // NULL or compile-time const value. |
| 107 | 111 |
| 108 bool is_final_; // If true, this variable is readonly. | 112 bool is_final_; // If true, this variable is readonly. |
| 109 bool is_captured_; // If true, this variable lives in the context, otherwise | 113 bool is_captured_; // If true, this variable lives in the context, otherwise |
| 110 // in the stack frame. | 114 // in the stack frame. |
| 111 bool is_invisible_; | 115 bool is_invisible_; |
| 116 bool always_live_; |
| 112 int index_; // Allocation index in words relative to frame pointer (if not | 117 int index_; // Allocation index in words relative to frame pointer (if not |
| 113 // captured), or relative to the context pointer (if captured). | 118 // captured), or relative to the context pointer (if captured). |
| 114 | 119 |
| 115 friend class LocalScope; | 120 friend class LocalScope; |
| 116 DISALLOW_COPY_AND_ASSIGN(LocalVariable); | 121 DISALLOW_COPY_AND_ASSIGN(LocalVariable); |
| 117 }; | 122 }; |
| 118 | 123 |
| 119 | 124 |
| 120 class SourceLabel : public ZoneAllocated { | 125 class SourceLabel : public ZoneAllocated { |
| 121 public: | 126 public: |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 intptr_t end_token_pos_; // Token index of end of scope. | 366 intptr_t end_token_pos_; // Token index of end of scope. |
| 362 GrowableArray<LocalVariable*> variables_; | 367 GrowableArray<LocalVariable*> variables_; |
| 363 GrowableArray<SourceLabel*> labels_; | 368 GrowableArray<SourceLabel*> labels_; |
| 364 | 369 |
| 365 DISALLOW_COPY_AND_ASSIGN(LocalScope); | 370 DISALLOW_COPY_AND_ASSIGN(LocalScope); |
| 366 }; | 371 }; |
| 367 | 372 |
| 368 } // namespace dart | 373 } // namespace dart |
| 369 | 374 |
| 370 #endif // VM_SCOPES_H_ | 375 #endif // VM_SCOPES_H_ |
| OLD | NEW |