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

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

Issue 9959127: New compiler: implement switch/case in graph builder. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 8 months 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 "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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 }; 110 };
111 111
112 SourceLabel(intptr_t token_index, const String& name, Kind kind) 112 SourceLabel(intptr_t token_index, const String& name, Kind kind)
113 : token_index_(token_index), 113 : token_index_(token_index),
114 name_(name), 114 name_(name),
115 owner_(NULL), 115 owner_(NULL),
116 kind_(kind), 116 kind_(kind),
117 continue_label_(), 117 continue_label_(),
118 break_label_(), 118 break_label_(),
119 join_for_break_(NULL), 119 join_for_break_(NULL),
120 join_for_continue_(NULL) { 120 join_for_continue_(NULL),
121 is_continue_target_(false) {
121 } 122 }
122 123
123 static SourceLabel* New(intptr_t token_index, String* name, Kind kind) { 124 static SourceLabel* New(intptr_t token_index, String* name, Kind kind) {
124 if (name != NULL) { 125 if (name != NULL) {
125 return new SourceLabel(token_index, *name, kind); 126 return new SourceLabel(token_index, *name, kind);
126 } else { 127 } else {
127 return new SourceLabel(token_index, 128 return new SourceLabel(token_index,
128 String::ZoneHandle(String::New(kDefaultLabelName)), 129 String::ZoneHandle(String::New(kDefaultLabelName)),
129 kind); 130 kind);
130 } 131 }
(...skipping 13 matching lines...) Expand all
144 145
145 void set_join_for_continue(JoinEntryInstr* join) { 146 void set_join_for_continue(JoinEntryInstr* join) {
146 ASSERT(join_for_continue_ == NULL); 147 ASSERT(join_for_continue_ == NULL);
147 join_for_continue_ = join; 148 join_for_continue_ = join;
148 } 149 }
149 150
150 JoinEntryInstr* join_for_continue() const { 151 JoinEntryInstr* join_for_continue() const {
151 return join_for_continue_; 152 return join_for_continue_;
152 } 153 }
153 154
155 bool is_continue_target() const { return is_continue_target_; }
156 void set_is_continue_target(bool value) { is_continue_target_ = value; }
157
154 void set_join_for_break(JoinEntryInstr* join) { 158 void set_join_for_break(JoinEntryInstr* join) {
155 ASSERT(join_for_break_ == NULL); 159 ASSERT(join_for_break_ == NULL);
156 join_for_break_ = join; 160 join_for_break_ = join;
157 } 161 }
158 162
159 JoinEntryInstr* join_for_break() const { 163 JoinEntryInstr* join_for_break() const {
160 return join_for_break_; 164 return join_for_break_;
161 } 165 }
162 166
163 // Returns the function level of the scope in which the label is defined. 167 // Returns the function level of the scope in which the label is defined.
164 int FunctionLevel() const; 168 int FunctionLevel() const;
165 169
166 void ResolveForwardReference() { kind_ = kCase; } 170 void ResolveForwardReference() { kind_ = kCase; }
167 171
168 private: 172 private:
169 const intptr_t token_index_; 173 const intptr_t token_index_;
170 const String& name_; 174 const String& name_;
171 LocalScope* owner_; // Local scope declaring this label. 175 LocalScope* owner_; // Local scope declaring this label.
172 176
173 Kind kind_; 177 Kind kind_;
174 Label continue_label_; 178 Label continue_label_;
175 Label break_label_; 179 Label break_label_;
176 JoinEntryInstr* join_for_break_; 180 JoinEntryInstr* join_for_break_;
177 JoinEntryInstr* join_for_continue_; 181 JoinEntryInstr* join_for_continue_;
182 bool is_continue_target_; // Needed for CaseNode.
178 static const char* kDefaultLabelName; 183 static const char* kDefaultLabelName;
179 184
180 DISALLOW_COPY_AND_ASSIGN(SourceLabel); 185 DISALLOW_COPY_AND_ASSIGN(SourceLabel);
181 }; 186 };
182 187
183 188
184 class LocalScope : public ZoneAllocated { 189 class LocalScope : public ZoneAllocated {
185 public: 190 public:
186 LocalScope(LocalScope* parent, int function_level, int loop_level); 191 LocalScope(LocalScope* parent, int function_level, int loop_level);
187 192
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 intptr_t end_token_index_; // Token index of end of scope. 327 intptr_t end_token_index_; // Token index of end of scope.
323 GrowableArray<LocalVariable*> variables_; 328 GrowableArray<LocalVariable*> variables_;
324 GrowableArray<SourceLabel*> labels_; 329 GrowableArray<SourceLabel*> labels_;
325 330
326 DISALLOW_COPY_AND_ASSIGN(LocalScope); 331 DISALLOW_COPY_AND_ASSIGN(LocalScope);
327 }; 332 };
328 333
329 } // namespace dart 334 } // namespace dart
330 335
331 #endif // VM_SCOPES_H_ 336 #endif // VM_SCOPES_H_
OLDNEW
« runtime/vm/flow_graph_builder.cc ('K') | « runtime/vm/flow_graph_builder.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698