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 RUNTIME_VM_SCOPES_H_ | 5 #ifndef RUNTIME_VM_SCOPES_H_ |
6 #define RUNTIME_VM_SCOPES_H_ | 6 #define RUNTIME_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" |
11 #include "vm/growable_array.h" | 11 #include "vm/growable_array.h" |
12 #include "vm/object.h" | 12 #include "vm/object.h" |
13 #include "vm/raw_object.h" | 13 #include "vm/raw_object.h" |
14 #include "vm/symbols.h" | 14 #include "vm/symbols.h" |
15 #include "vm/token.h" | 15 #include "vm/token.h" |
16 | 16 |
17 namespace dart { | 17 namespace dart { |
18 | 18 |
19 class LocalScope; | 19 class LocalScope; |
20 | 20 |
21 | |
22 class LocalVariable : public ZoneAllocated { | 21 class LocalVariable : public ZoneAllocated { |
23 public: | 22 public: |
24 LocalVariable(TokenPosition declaration_pos, | 23 LocalVariable(TokenPosition declaration_pos, |
25 TokenPosition token_pos, | 24 TokenPosition token_pos, |
26 const String& name, | 25 const String& name, |
27 const AbstractType& type) | 26 const AbstractType& type) |
28 : declaration_pos_(declaration_pos), | 27 : declaration_pos_(declaration_pos), |
29 token_pos_(token_pos), | 28 token_pos_(token_pos), |
30 name_(name), | 29 name_(name), |
31 owner_(NULL), | 30 owner_(NULL), |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 bool is_invisible_; | 124 bool is_invisible_; |
126 bool is_captured_parameter_; | 125 bool is_captured_parameter_; |
127 bool is_forced_stack_; | 126 bool is_forced_stack_; |
128 int index_; // Allocation index in words relative to frame pointer (if not | 127 int index_; // Allocation index in words relative to frame pointer (if not |
129 // captured), or relative to the context pointer (if captured). | 128 // captured), or relative to the context pointer (if captured). |
130 | 129 |
131 friend class LocalScope; | 130 friend class LocalScope; |
132 DISALLOW_COPY_AND_ASSIGN(LocalVariable); | 131 DISALLOW_COPY_AND_ASSIGN(LocalVariable); |
133 }; | 132 }; |
134 | 133 |
135 | |
136 class NameReference : public ZoneAllocated { | 134 class NameReference : public ZoneAllocated { |
137 public: | 135 public: |
138 NameReference(TokenPosition token_pos, const String& name) | 136 NameReference(TokenPosition token_pos, const String& name) |
139 : token_pos_(token_pos), name_(name) { | 137 : token_pos_(token_pos), name_(name) { |
140 ASSERT(name.IsSymbol()); | 138 ASSERT(name.IsSymbol()); |
141 } | 139 } |
142 const String& name() const { return name_; } | 140 const String& name() const { return name_; } |
143 TokenPosition token_pos() const { return token_pos_; } | 141 TokenPosition token_pos() const { return token_pos_; } |
144 void set_token_pos(TokenPosition value) { token_pos_ = value; } | 142 void set_token_pos(TokenPosition value) { token_pos_ = value; } |
145 | 143 |
146 private: | 144 private: |
147 TokenPosition token_pos_; | 145 TokenPosition token_pos_; |
148 const String& name_; | 146 const String& name_; |
149 }; | 147 }; |
150 | 148 |
151 | |
152 class SourceLabel : public ZoneAllocated { | 149 class SourceLabel : public ZoneAllocated { |
153 public: | 150 public: |
154 enum Kind { | 151 enum Kind { |
155 kFor, | 152 kFor, |
156 kWhile, | 153 kWhile, |
157 kDoWhile, | 154 kDoWhile, |
158 kSwitch, | 155 kSwitch, |
159 kCase, | 156 kCase, |
160 kTry, | 157 kTry, |
161 kCatch, | 158 kCatch, |
(...skipping 30 matching lines...) Expand all Loading... |
192 private: | 189 private: |
193 const TokenPosition token_pos_; | 190 const TokenPosition token_pos_; |
194 const String& name_; | 191 const String& name_; |
195 LocalScope* owner_; // Local scope declaring this label. | 192 LocalScope* owner_; // Local scope declaring this label. |
196 | 193 |
197 Kind kind_; | 194 Kind kind_; |
198 | 195 |
199 DISALLOW_COPY_AND_ASSIGN(SourceLabel); | 196 DISALLOW_COPY_AND_ASSIGN(SourceLabel); |
200 }; | 197 }; |
201 | 198 |
202 | |
203 class LocalScope : public ZoneAllocated { | 199 class LocalScope : public ZoneAllocated { |
204 public: | 200 public: |
205 LocalScope(LocalScope* parent, int function_level, int loop_level); | 201 LocalScope(LocalScope* parent, int function_level, int loop_level); |
206 | 202 |
207 LocalScope* parent() const { return parent_; } | 203 LocalScope* parent() const { return parent_; } |
208 LocalScope* child() const { return child_; } | 204 LocalScope* child() const { return child_; } |
209 LocalScope* sibling() const { return sibling_; } | 205 LocalScope* sibling() const { return sibling_; } |
210 int function_level() const { return function_level_; } | 206 int function_level() const { return function_level_; } |
211 int loop_level() const { return loop_level_; } | 207 int loop_level() const { return loop_level_; } |
212 | 208 |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 // List of names referenced in this scope and its children that | 372 // List of names referenced in this scope and its children that |
377 // are not resolved to local variables. | 373 // are not resolved to local variables. |
378 GrowableArray<NameReference*> referenced_; | 374 GrowableArray<NameReference*> referenced_; |
379 | 375 |
380 DISALLOW_COPY_AND_ASSIGN(LocalScope); | 376 DISALLOW_COPY_AND_ASSIGN(LocalScope); |
381 }; | 377 }; |
382 | 378 |
383 } // namespace dart | 379 } // namespace dart |
384 | 380 |
385 #endif // RUNTIME_VM_SCOPES_H_ | 381 #endif // RUNTIME_VM_SCOPES_H_ |
OLD | NEW |