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" | 8 #include "platform/assert.h" |
9 #include "platform/globals.h" | 9 #include "platform/globals.h" |
10 #include "vm/allocation.h" | 10 #include "vm/allocation.h" |
(...skipping 17 matching lines...) Expand all Loading... |
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 index_(LocalVariable::kUninitializedIndex) { | 35 index_(LocalVariable::kUninitializedIndex) { |
36 ASSERT(type.IsZoneHandle()); | 36 ASSERT(type.IsZoneHandle()); |
37 ASSERT(type.IsFinalized()); | 37 ASSERT(type.IsFinalized()); |
| 38 ASSERT(name.IsSymbol()); |
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); |
45 owner_ = owner; | 46 owner_ = owner; |
46 } | 47 } |
47 | 48 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 friend class LocalScope; | 116 friend class LocalScope; |
116 DISALLOW_COPY_AND_ASSIGN(LocalVariable); | 117 DISALLOW_COPY_AND_ASSIGN(LocalVariable); |
117 }; | 118 }; |
118 | 119 |
119 | 120 |
120 class NameReference : public ZoneAllocated { | 121 class NameReference : public ZoneAllocated { |
121 public: | 122 public: |
122 NameReference(intptr_t token_pos, const String& name) | 123 NameReference(intptr_t token_pos, const String& name) |
123 : token_pos_(token_pos), | 124 : token_pos_(token_pos), |
124 name_(name) { | 125 name_(name) { |
| 126 ASSERT(name.IsSymbol()); |
125 } | 127 } |
126 const String& name() const { return name_; } | 128 const String& name() const { return name_; } |
127 intptr_t token_pos() const { return token_pos_; } | 129 intptr_t token_pos() const { return token_pos_; } |
128 void set_token_pos(intptr_t value) { token_pos_ = value; } | 130 void set_token_pos(intptr_t value) { token_pos_ = value; } |
129 private: | 131 private: |
130 intptr_t token_pos_; | 132 intptr_t token_pos_; |
131 const String& name_; | 133 const String& name_; |
132 }; | 134 }; |
133 | 135 |
134 | 136 |
135 class SourceLabel : public ZoneAllocated { | 137 class SourceLabel : public ZoneAllocated { |
136 public: | 138 public: |
137 enum Kind { | 139 enum Kind { |
138 kFor, | 140 kFor, |
139 kWhile, | 141 kWhile, |
140 kDoWhile, | 142 kDoWhile, |
141 kSwitch, | 143 kSwitch, |
142 kCase, | 144 kCase, |
143 kTry, | 145 kTry, |
144 kCatch, | 146 kCatch, |
145 kForward, | 147 kForward, |
146 kStatement // Any statement other than the above | 148 kStatement // Any statement other than the above |
147 }; | 149 }; |
148 | 150 |
149 SourceLabel(intptr_t token_pos, const String& name, Kind kind) | 151 SourceLabel(intptr_t token_pos, const String& name, Kind kind) |
150 : token_pos_(token_pos), | 152 : token_pos_(token_pos), |
151 name_(name), | 153 name_(name), |
152 owner_(NULL), | 154 owner_(NULL), |
153 kind_(kind) { | 155 kind_(kind) { |
| 156 ASSERT(name.IsSymbol()); |
154 } | 157 } |
155 | 158 |
156 static SourceLabel* New(intptr_t token_pos, String* name, Kind kind) { | 159 static SourceLabel* New(intptr_t token_pos, String* name, Kind kind) { |
157 if (name != NULL) { | 160 if (name != NULL) { |
158 return new SourceLabel(token_pos, *name, kind); | 161 return new SourceLabel(token_pos, *name, kind); |
159 } else { | 162 } else { |
160 return new SourceLabel(token_pos, | 163 return new SourceLabel(token_pos, |
161 Symbols::DefaultLabel(), | 164 Symbols::DefaultLabel(), |
162 kind); | 165 kind); |
163 } | 166 } |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 // List of names referenced in this scope and its children that | 356 // List of names referenced in this scope and its children that |
354 // are not resolved to local variables. | 357 // are not resolved to local variables. |
355 GrowableArray<NameReference*> referenced_; | 358 GrowableArray<NameReference*> referenced_; |
356 | 359 |
357 DISALLOW_COPY_AND_ASSIGN(LocalScope); | 360 DISALLOW_COPY_AND_ASSIGN(LocalScope); |
358 }; | 361 }; |
359 | 362 |
360 } // namespace dart | 363 } // namespace dart |
361 | 364 |
362 #endif // VM_SCOPES_H_ | 365 #endif // VM_SCOPES_H_ |
OLD | NEW |