Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(133)

Side by Side Diff: runtime/vm/scopes.h

Issue 71703002: Introduce a nesting stack to the flow graph builder. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
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 JoinEntryInstr;
20 class LocalScope; 19 class LocalScope;
21 20
22 21
23 class LocalVariable : public ZoneAllocated { 22 class LocalVariable : public ZoneAllocated {
24 public: 23 public:
25 LocalVariable(intptr_t token_pos, 24 LocalVariable(intptr_t token_pos,
26 const String& name, 25 const String& name,
27 const AbstractType& type) 26 const AbstractType& type)
28 : token_pos_(token_pos), 27 : token_pos_(token_pos),
29 name_(name), 28 name_(name),
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 kTry, 143 kTry,
145 kCatch, 144 kCatch,
146 kForward, 145 kForward,
147 kStatement // Any statement other than the above 146 kStatement // Any statement other than the above
148 }; 147 };
149 148
150 SourceLabel(intptr_t token_pos, const String& name, Kind kind) 149 SourceLabel(intptr_t token_pos, const String& name, Kind kind)
151 : token_pos_(token_pos), 150 : token_pos_(token_pos),
152 name_(name), 151 name_(name),
153 owner_(NULL), 152 owner_(NULL),
154 kind_(kind), 153 kind_(kind) {
155 join_for_break_(NULL),
156 join_for_continue_(NULL),
157 is_continue_target_(false) {
158 } 154 }
159 155
160 static SourceLabel* New(intptr_t token_pos, String* name, Kind kind) { 156 static SourceLabel* New(intptr_t token_pos, String* name, Kind kind) {
161 if (name != NULL) { 157 if (name != NULL) {
162 return new SourceLabel(token_pos, *name, kind); 158 return new SourceLabel(token_pos, *name, kind);
163 } else { 159 } else {
164 return new SourceLabel(token_pos, 160 return new SourceLabel(token_pos,
165 Symbols::DefaultLabel(), 161 Symbols::DefaultLabel(),
166 kind); 162 kind);
167 } 163 }
168 } 164 }
169 165
170 intptr_t token_pos() const { return token_pos_; } 166 intptr_t token_pos() const { return token_pos_; }
171 const String& name() const { return name_; } 167 const String& name() const { return name_; }
172 LocalScope* owner() const { return owner_; } 168 LocalScope* owner() const { return owner_; }
173 void set_owner(LocalScope* owner) { 169 void set_owner(LocalScope* owner) {
174 ASSERT(owner_ == NULL); 170 ASSERT(owner_ == NULL);
175 owner_ = owner; 171 owner_ = owner;
176 } 172 }
177 173
178 Kind kind() const { return kind_; } 174 Kind kind() const { return kind_; }
179 175
180 void set_join_for_continue(JoinEntryInstr* join) {
181 ASSERT(join_for_continue_ == NULL);
182 join_for_continue_ = join;
183 }
184
185 JoinEntryInstr* join_for_continue() const {
186 return join_for_continue_;
187 }
188
189 bool is_continue_target() const { return is_continue_target_; }
190 void set_is_continue_target(bool value) { is_continue_target_ = value; }
191
192 void set_join_for_break(JoinEntryInstr* join) {
193 ASSERT(join_for_break_ == NULL);
194 join_for_break_ = join;
195 }
196
197 JoinEntryInstr* join_for_break() const {
198 return join_for_break_;
199 }
200
201 // Returns the function level of the scope in which the label is defined. 176 // Returns the function level of the scope in which the label is defined.
202 int FunctionLevel() const; 177 int FunctionLevel() const;
203 178
204 void ResolveForwardReference() { kind_ = kCase; } 179 void ResolveForwardReference() { kind_ = kCase; }
205 180
206 private: 181 private:
207 // TODO(zerny): Remove this hack when the builder no longer stores state in
208 // the ast/scopes.
209 friend class SourceLabelResetter;
210
211 const intptr_t token_pos_; 182 const intptr_t token_pos_;
212 const String& name_; 183 const String& name_;
213 LocalScope* owner_; // Local scope declaring this label. 184 LocalScope* owner_; // Local scope declaring this label.
214 185
215 Kind kind_; 186 Kind kind_;
216 JoinEntryInstr* join_for_break_;
217 JoinEntryInstr* join_for_continue_;
218 bool is_continue_target_; // Needed for CaseNode.
219 187
220 DISALLOW_COPY_AND_ASSIGN(SourceLabel); 188 DISALLOW_COPY_AND_ASSIGN(SourceLabel);
221 }; 189 };
222 190
223 191
224 class LocalScope : public ZoneAllocated { 192 class LocalScope : public ZoneAllocated {
225 public: 193 public:
226 LocalScope(LocalScope* parent, int function_level, int loop_level); 194 LocalScope(LocalScope* parent, int function_level, int loop_level);
227 195
228 LocalScope* parent() const { return parent_; } 196 LocalScope* parent() const { return parent_; }
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 // List of names referenced in this scope and its children that 353 // List of names referenced in this scope and its children that
386 // are not resolved to local variables. 354 // are not resolved to local variables.
387 GrowableArray<NameReference*> referenced_; 355 GrowableArray<NameReference*> referenced_;
388 356
389 DISALLOW_COPY_AND_ASSIGN(LocalScope); 357 DISALLOW_COPY_AND_ASSIGN(LocalScope);
390 }; 358 };
391 359
392 } // namespace dart 360 } // namespace dart
393 361
394 #endif // VM_SCOPES_H_ 362 #endif // VM_SCOPES_H_
OLDNEW
« runtime/vm/flow_graph_builder.cc ('K') | « runtime/vm/flow_graph_inliner.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698