| 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 "platform/assert.h" |
| 9 #include "platform/globals.h" |
| 8 #include "vm/allocation.h" | 10 #include "vm/allocation.h" |
| 9 #include "vm/assembler.h" | |
| 10 #include "vm/growable_array.h" | 11 #include "vm/growable_array.h" |
| 12 #include "vm/object.h" |
| 13 #include "vm/raw_object.h" |
| 11 #include "vm/symbols.h" | 14 #include "vm/symbols.h" |
| 15 #include "vm/token.h" |
| 12 | 16 |
| 13 namespace dart { | 17 namespace dart { |
| 14 | 18 |
| 15 class BitVector; | |
| 16 class JoinEntryInstr; | 19 class JoinEntryInstr; |
| 17 class LocalScope; | 20 class LocalScope; |
| 18 class LocalVariable; | |
| 19 class SourceLabel; | |
| 20 | 21 |
| 21 | 22 |
| 22 class LocalVariable : public ZoneAllocated { | 23 class LocalVariable : public ZoneAllocated { |
| 23 public: | 24 public: |
| 24 LocalVariable(intptr_t token_pos, | 25 LocalVariable(intptr_t token_pos, |
| 25 const String& name, | 26 const String& name, |
| 26 const AbstractType& type) | 27 const AbstractType& type) |
| 27 : token_pos_(token_pos), | 28 : token_pos_(token_pos), |
| 28 name_(name), | 29 name_(name), |
| 29 owner_(NULL), | 30 owner_(NULL), |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 kCatch, | 130 kCatch, |
| 130 kForward, | 131 kForward, |
| 131 kStatement // Any statement other than the above | 132 kStatement // Any statement other than the above |
| 132 }; | 133 }; |
| 133 | 134 |
| 134 SourceLabel(intptr_t token_pos, const String& name, Kind kind) | 135 SourceLabel(intptr_t token_pos, const String& name, Kind kind) |
| 135 : token_pos_(token_pos), | 136 : token_pos_(token_pos), |
| 136 name_(name), | 137 name_(name), |
| 137 owner_(NULL), | 138 owner_(NULL), |
| 138 kind_(kind), | 139 kind_(kind), |
| 139 continue_label_(), | |
| 140 break_label_(), | |
| 141 join_for_break_(NULL), | 140 join_for_break_(NULL), |
| 142 join_for_continue_(NULL), | 141 join_for_continue_(NULL), |
| 143 is_continue_target_(false) { | 142 is_continue_target_(false) { |
| 144 } | 143 } |
| 145 | 144 |
| 146 static SourceLabel* New(intptr_t token_pos, String* name, Kind kind) { | 145 static SourceLabel* New(intptr_t token_pos, String* name, Kind kind) { |
| 147 if (name != NULL) { | 146 if (name != NULL) { |
| 148 return new SourceLabel(token_pos, *name, kind); | 147 return new SourceLabel(token_pos, *name, kind); |
| 149 } else { | 148 } else { |
| 150 return new SourceLabel(token_pos, | 149 return new SourceLabel(token_pos, |
| 151 Symbols::DefaultLabel(), | 150 Symbols::DefaultLabel(), |
| 152 kind); | 151 kind); |
| 153 } | 152 } |
| 154 } | 153 } |
| 155 | 154 |
| 156 intptr_t token_pos() const { return token_pos_; } | 155 intptr_t token_pos() const { return token_pos_; } |
| 157 const String& name() const { return name_; } | 156 const String& name() const { return name_; } |
| 158 LocalScope* owner() const { return owner_; } | 157 LocalScope* owner() const { return owner_; } |
| 159 void set_owner(LocalScope* owner) { | 158 void set_owner(LocalScope* owner) { |
| 160 ASSERT(owner_ == NULL); | 159 ASSERT(owner_ == NULL); |
| 161 owner_ = owner; | 160 owner_ = owner; |
| 162 } | 161 } |
| 163 | 162 |
| 164 Kind kind() const { return kind_; } | 163 Kind kind() const { return kind_; } |
| 165 Label* break_label() { return &break_label_; } | |
| 166 Label* continue_label() { return &continue_label_; } | |
| 167 | 164 |
| 168 void set_join_for_continue(JoinEntryInstr* join) { | 165 void set_join_for_continue(JoinEntryInstr* join) { |
| 169 ASSERT(join_for_continue_ == NULL); | 166 ASSERT(join_for_continue_ == NULL); |
| 170 join_for_continue_ = join; | 167 join_for_continue_ = join; |
| 171 } | 168 } |
| 172 | 169 |
| 173 JoinEntryInstr* join_for_continue() const { | 170 JoinEntryInstr* join_for_continue() const { |
| 174 return join_for_continue_; | 171 return join_for_continue_; |
| 175 } | 172 } |
| 176 | 173 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 194 private: | 191 private: |
| 195 // TODO(zerny): Remove this hack when the builder no longer stores state in | 192 // TODO(zerny): Remove this hack when the builder no longer stores state in |
| 196 // the ast/scopes. | 193 // the ast/scopes. |
| 197 friend class SourceLabelResetter; | 194 friend class SourceLabelResetter; |
| 198 | 195 |
| 199 const intptr_t token_pos_; | 196 const intptr_t token_pos_; |
| 200 const String& name_; | 197 const String& name_; |
| 201 LocalScope* owner_; // Local scope declaring this label. | 198 LocalScope* owner_; // Local scope declaring this label. |
| 202 | 199 |
| 203 Kind kind_; | 200 Kind kind_; |
| 204 Label continue_label_; | |
| 205 Label break_label_; | |
| 206 JoinEntryInstr* join_for_break_; | 201 JoinEntryInstr* join_for_break_; |
| 207 JoinEntryInstr* join_for_continue_; | 202 JoinEntryInstr* join_for_continue_; |
| 208 bool is_continue_target_; // Needed for CaseNode. | 203 bool is_continue_target_; // Needed for CaseNode. |
| 209 | 204 |
| 210 DISALLOW_COPY_AND_ASSIGN(SourceLabel); | 205 DISALLOW_COPY_AND_ASSIGN(SourceLabel); |
| 211 }; | 206 }; |
| 212 | 207 |
| 213 | 208 |
| 214 class LocalScope : public ZoneAllocated { | 209 class LocalScope : public ZoneAllocated { |
| 215 public: | 210 public: |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 intptr_t end_token_pos_; // Token index of end of scope. | 361 intptr_t end_token_pos_; // Token index of end of scope. |
| 367 GrowableArray<LocalVariable*> variables_; | 362 GrowableArray<LocalVariable*> variables_; |
| 368 GrowableArray<SourceLabel*> labels_; | 363 GrowableArray<SourceLabel*> labels_; |
| 369 | 364 |
| 370 DISALLOW_COPY_AND_ASSIGN(LocalScope); | 365 DISALLOW_COPY_AND_ASSIGN(LocalScope); |
| 371 }; | 366 }; |
| 372 | 367 |
| 373 } // namespace dart | 368 } // namespace dart |
| 374 | 369 |
| 375 #endif // VM_SCOPES_H_ | 370 #endif // VM_SCOPES_H_ |
| OLD | NEW |