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

Side by Side Diff: runtime/vm/ast_printer.cc

Issue 1003253005: Fix flow graph and AST printing. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 9 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
« no previous file with comments | « no previous file | runtime/vm/intrinsifier.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 #include "vm/ast_printer.h" 5 #include "vm/ast_printer.h"
6 6
7 #include "vm/handles.h" 7 #include "vm/handles.h"
8 #include "vm/log.h"
8 #include "vm/object.h" 9 #include "vm/object.h"
9 #include "vm/os.h" 10 #include "vm/os.h"
10 #include "vm/parser.h" 11 #include "vm/parser.h"
11 12
12 namespace dart { 13 namespace dart {
13 14
14 AstPrinter::AstPrinter() { } 15 AstPrinter::AstPrinter() { }
15 16
16 17
17 AstPrinter::~AstPrinter() { } 18 AstPrinter::~AstPrinter() { }
18 19
19 20
20 void AstPrinter::VisitGenericAstNode(AstNode* node) { 21 void AstPrinter::VisitGenericAstNode(AstNode* node) {
21 OS::Print("(%s ", node->PrettyName()); 22 ISL_Print("(%s ", node->PrettyName());
22 node->VisitChildren(this); 23 node->VisitChildren(this);
23 OS::Print(")"); 24 ISL_Print(")");
24 } 25 }
25 26
26 27
27 void AstPrinter::VisitSequenceNode(SequenceNode* node) { 28 void AstPrinter::VisitSequenceNode(SequenceNode* node) {
28 OS::Print("(%s (scope \"%p\")", node->PrettyName(), node->scope()); 29 ISL_Print("(%s (scope \"%p\")", node->PrettyName(), node->scope());
29 for (int i = 0; i < node->length(); ++i) { 30 for (int i = 0; i < node->length(); ++i) {
30 OS::Print("\n"); 31 ISL_Print("\n");
31 node->NodeAt(i)->Visit(this); 32 node->NodeAt(i)->Visit(this);
32 } 33 }
33 OS::Print(")"); 34 ISL_Print(")");
34 } 35 }
35 36
36 37
37 void AstPrinter::VisitCloneContextNode(CloneContextNode* node) { 38 void AstPrinter::VisitCloneContextNode(CloneContextNode* node) {
38 VisitGenericAstNode(node); 39 VisitGenericAstNode(node);
39 } 40 }
40 41
41 42
42 void AstPrinter::VisitArgumentListNode(ArgumentListNode* arguments) { 43 void AstPrinter::VisitArgumentListNode(ArgumentListNode* arguments) {
43 VisitGenericAstNode(arguments); 44 VisitGenericAstNode(arguments);
44 } 45 }
45 46
46 47
47 void AstPrinter::VisitReturnNode(ReturnNode* node) { 48 void AstPrinter::VisitReturnNode(ReturnNode* node) {
48 const char* kind; 49 const char* kind;
49 switch (node->return_type()) { 50 switch (node->return_type()) {
50 case ReturnNode::kContinuation: 51 case ReturnNode::kContinuation:
51 kind = "continuation "; 52 kind = "continuation ";
52 break; 53 break;
53 case ReturnNode::kContinuationTarget: 54 case ReturnNode::kContinuationTarget:
54 kind = "continuation-target "; 55 kind = "continuation-target ";
55 break; 56 break;
56 case ReturnNode::kRegular: 57 case ReturnNode::kRegular:
57 kind = ""; 58 kind = "";
58 break; 59 break;
59 default: 60 default:
60 kind = ""; 61 kind = "";
61 UNREACHABLE(); 62 UNREACHABLE();
62 } 63 }
63 OS::Print("(%s %s", node->PrettyName(), kind); 64 ISL_Print("(%s %s", node->PrettyName(), kind);
64 node->VisitChildren(this); 65 node->VisitChildren(this);
65 OS::Print(")"); 66 ISL_Print(")");
66 } 67 }
67 68
68 69
69 void AstPrinter::VisitGenericLocalNode(AstNode* node, 70 void AstPrinter::VisitGenericLocalNode(AstNode* node,
70 const LocalVariable& var) { 71 const LocalVariable& var) {
71 OS::Print("(%s %s%s \"%s\"", 72 ISL_Print("(%s %s%s \"%s\"",
72 node->PrettyName(), 73 node->PrettyName(),
73 var.is_final() ? "final " : "", 74 var.is_final() ? "final " : "",
74 String::Handle(var.type().Name()).ToCString(), 75 String::Handle(var.type().Name()).ToCString(),
75 var.name().ToCString()); 76 var.name().ToCString());
76 if (var.HasIndex()) { 77 if (var.HasIndex()) {
77 if (var.is_captured()) { 78 if (var.is_captured()) {
78 OS::Print(" (context %d %d)", var.owner()->context_level(), var.index()); 79 ISL_Print(" (context %d %d)", var.owner()->context_level(), var.index());
79 } else { 80 } else {
80 OS::Print(" (stack %d)", var.index()); 81 ISL_Print(" (stack %d)", var.index());
81 } 82 }
82 } 83 }
83 OS::Print(" "); 84 ISL_Print(" ");
84 node->VisitChildren(this); 85 node->VisitChildren(this);
85 OS::Print(")"); 86 ISL_Print(")");
86 } 87 }
87 88
88 89
89 void AstPrinter::VisitLoadLocalNode(LoadLocalNode* node) { 90 void AstPrinter::VisitLoadLocalNode(LoadLocalNode* node) {
90 VisitGenericLocalNode(node, node->local()); 91 VisitGenericLocalNode(node, node->local());
91 } 92 }
92 93
93 94
94 void AstPrinter::VisitStoreLocalNode(StoreLocalNode* node) { 95 void AstPrinter::VisitStoreLocalNode(StoreLocalNode* node) {
95 VisitGenericLocalNode(node, node->local()); 96 VisitGenericLocalNode(node, node->local());
96 } 97 }
97 98
98 99
99 void AstPrinter::VisitGenericFieldNode(AstNode* node, const Field& field) { 100 void AstPrinter::VisitGenericFieldNode(AstNode* node, const Field& field) {
100 OS::Print("(%s %s%s \"%s\" ", 101 ISL_Print("(%s %s%s \"%s\" ",
101 node->PrettyName(), 102 node->PrettyName(),
102 field.is_final() ? "final " : "", 103 field.is_final() ? "final " : "",
103 String::Handle(AbstractType::Handle(field.type()).Name()). 104 String::Handle(AbstractType::Handle(field.type()).Name()).
104 ToCString(), 105 ToCString(),
105 String::Handle(field.name()).ToCString()); 106 String::Handle(field.name()).ToCString());
106 node->VisitChildren(this); 107 node->VisitChildren(this);
107 OS::Print(")"); 108 ISL_Print(")");
108 } 109 }
109 110
110 111
111 void AstPrinter::VisitLoadInstanceFieldNode(LoadInstanceFieldNode* node) { 112 void AstPrinter::VisitLoadInstanceFieldNode(LoadInstanceFieldNode* node) {
112 VisitGenericFieldNode(node, node->field()); 113 VisitGenericFieldNode(node, node->field());
113 } 114 }
114 115
115 116
116 void AstPrinter::VisitStoreInstanceFieldNode(StoreInstanceFieldNode* node) { 117 void AstPrinter::VisitStoreInstanceFieldNode(StoreInstanceFieldNode* node) {
117 VisitGenericFieldNode(node, node->field()); 118 VisitGenericFieldNode(node, node->field());
(...skipping 20 matching lines...) Expand all
138 } 139 }
139 140
140 141
141 void AstPrinter::VisitStringInterpolateNode(StringInterpolateNode* node) { 142 void AstPrinter::VisitStringInterpolateNode(StringInterpolateNode* node) {
142 VisitGenericAstNode(node); 143 VisitGenericAstNode(node);
143 } 144 }
144 145
145 146
146 void AstPrinter::VisitLiteralNode(LiteralNode* node) { 147 void AstPrinter::VisitLiteralNode(LiteralNode* node) {
147 const Instance& literal = node->literal(); 148 const Instance& literal = node->literal();
148 OS::Print("(%s \"%s\")", node->PrettyName(), literal.ToCString()); 149 ISL_Print("(%s \"%s\")", node->PrettyName(), literal.ToCString());
149 } 150 }
150 151
151 152
152 void AstPrinter::VisitTypeNode(TypeNode* node) { 153 void AstPrinter::VisitTypeNode(TypeNode* node) {
153 const AbstractType& type = node->type(); 154 const AbstractType& type = node->type();
154 OS::Print("(%s \"%s\")", 155 ISL_Print("(%s \"%s\")",
155 node->PrettyName(), 156 node->PrettyName(),
156 String::Handle(type.Name()).ToCString()); 157 String::Handle(type.Name()).ToCString());
157 } 158 }
158 159
159 160
160 void AstPrinter::VisitAssignableNode(AssignableNode* node) { 161 void AstPrinter::VisitAssignableNode(AssignableNode* node) {
161 const AbstractType& type = node->type(); 162 const AbstractType& type = node->type();
162 const String& dst_name = node->dst_name(); 163 const String& dst_name = node->dst_name();
163 OS::Print("(%s (type \"%s\") (of \"%s\") ", 164 ISL_Print("(%s (type \"%s\") (of \"%s\") ",
164 node->PrettyName(), 165 node->PrettyName(),
165 String::Handle(type.Name()).ToCString(), 166 String::Handle(type.Name()).ToCString(),
166 dst_name.ToCString()); 167 dst_name.ToCString());
167 node->VisitChildren(this); 168 node->VisitChildren(this);
168 OS::Print(")"); 169 ISL_Print(")");
169 } 170 }
170 171
171 172
172 void AstPrinter::VisitAwaitNode(AwaitNode* node) { 173 void AstPrinter::VisitAwaitNode(AwaitNode* node) {
173 VisitGenericAstNode(node); 174 VisitGenericAstNode(node);
174 } 175 }
175 176
176 177
177 void AstPrinter::VisitAwaitMarkerNode(AwaitMarkerNode* node) { 178 void AstPrinter::VisitAwaitMarkerNode(AwaitMarkerNode* node) {
178 VisitGenericAstNode(node); 179 VisitGenericAstNode(node);
179 } 180 }
180 181
181 182
182 void AstPrinter::VisitPrimaryNode(PrimaryNode* node) { 183 void AstPrinter::VisitPrimaryNode(PrimaryNode* node) {
183 OS::Print("*****%s***** \"%s\")", 184 ISL_Print("*****%s***** \"%s\")",
184 node->PrettyName(), 185 node->PrettyName(),
185 node->primary().ToCString()); 186 node->primary().ToCString());
186 } 187 }
187 188
188 189
189 void AstPrinter::VisitComparisonNode(ComparisonNode* node) { 190 void AstPrinter::VisitComparisonNode(ComparisonNode* node) {
190 OS::Print("(%s %s ", node->PrettyName(), node->TokenName()); 191 ISL_Print("(%s %s ", node->PrettyName(), node->TokenName());
191 node->VisitChildren(this); 192 node->VisitChildren(this);
192 OS::Print(")"); 193 ISL_Print(")");
193 } 194 }
194 195
195 196
196 void AstPrinter::VisitBinaryOpNode(BinaryOpNode* node) { 197 void AstPrinter::VisitBinaryOpNode(BinaryOpNode* node) {
197 OS::Print("(%s %s ", node->PrettyName(), node->TokenName()); 198 ISL_Print("(%s %s ", node->PrettyName(), node->TokenName());
198 node->VisitChildren(this); 199 node->VisitChildren(this);
199 OS::Print(")"); 200 ISL_Print(")");
200 } 201 }
201 202
202 203
203 void AstPrinter::VisitBinaryOpWithMask32Node(BinaryOpWithMask32Node* node) { 204 void AstPrinter::VisitBinaryOpWithMask32Node(BinaryOpWithMask32Node* node) {
204 OS::Print("(%s %s ", node->PrettyName(), node->TokenName()); 205 ISL_Print("(%s %s ", node->PrettyName(), node->TokenName());
205 node->VisitChildren(this); 206 node->VisitChildren(this);
206 OS::Print(" & \"0x%" Px64 "", node->mask32()); 207 ISL_Print(" & \"0x%" Px64 "", node->mask32());
207 OS::Print("\")"); 208 ISL_Print("\")");
208 } 209 }
209 210
210 211
211 void AstPrinter::VisitUnaryOpNode(UnaryOpNode* node) { 212 void AstPrinter::VisitUnaryOpNode(UnaryOpNode* node) {
212 OS::Print("(%s %s ", node->PrettyName(), node->TokenName()); 213 ISL_Print("(%s %s ", node->PrettyName(), node->TokenName());
213 node->VisitChildren(this); 214 node->VisitChildren(this);
214 OS::Print(")"); 215 ISL_Print(")");
215 } 216 }
216 217
217 218
218 void AstPrinter::VisitConditionalExprNode(ConditionalExprNode* node) { 219 void AstPrinter::VisitConditionalExprNode(ConditionalExprNode* node) {
219 VisitGenericAstNode(node); 220 VisitGenericAstNode(node);
220 } 221 }
221 222
222 223
223 void AstPrinter::VisitIfNode(IfNode* node) { 224 void AstPrinter::VisitIfNode(IfNode* node) {
224 VisitGenericAstNode(node); 225 VisitGenericAstNode(node);
225 } 226 }
226 227
227 228
228 void AstPrinter::VisitCaseNode(CaseNode* node) { 229 void AstPrinter::VisitCaseNode(CaseNode* node) {
229 OS::Print("(%s (", node->PrettyName()); 230 ISL_Print("(%s (", node->PrettyName());
230 for (int i = 0; i < node->case_expressions()->length(); i++) { 231 for (int i = 0; i < node->case_expressions()->length(); i++) {
231 node->case_expressions()->NodeAt(i)->Visit(this); 232 node->case_expressions()->NodeAt(i)->Visit(this);
232 } 233 }
233 if (node->contains_default()) { 234 if (node->contains_default()) {
234 OS::Print(" default"); 235 ISL_Print(" default");
235 } 236 }
236 OS::Print(")"); 237 ISL_Print(")");
237 node->statements()->Visit(this); 238 node->statements()->Visit(this);
238 OS::Print(")"); 239 ISL_Print(")");
239 } 240 }
240 241
241 242
242 void AstPrinter::VisitSwitchNode(SwitchNode* node) { 243 void AstPrinter::VisitSwitchNode(SwitchNode* node) {
243 VisitGenericAstNode(node); 244 VisitGenericAstNode(node);
244 } 245 }
245 246
246 247
247 void AstPrinter::VisitWhileNode(WhileNode* node) { 248 void AstPrinter::VisitWhileNode(WhileNode* node) {
248 VisitGenericAstNode(node); 249 VisitGenericAstNode(node);
249 } 250 }
250 251
251 252
252 void AstPrinter::VisitForNode(ForNode* node) { 253 void AstPrinter::VisitForNode(ForNode* node) {
253 // Complicated because the condition is optional and so we clearly want to 254 // Complicated because the condition is optional and so we clearly want to
254 // indicate the subparts. 255 // indicate the subparts.
255 OS::Print("(%s (init ", node->PrettyName()); 256 ISL_Print("(%s (init ", node->PrettyName());
256 node->initializer()->Visit(this); 257 node->initializer()->Visit(this);
257 if (node->condition() != NULL) { 258 if (node->condition() != NULL) {
258 OS::Print(") (cond "); 259 ISL_Print(") (cond ");
259 node->condition()->Visit(this); 260 node->condition()->Visit(this);
260 } 261 }
261 OS::Print(") (update "); 262 ISL_Print(") (update ");
262 node->increment()->Visit(this); 263 node->increment()->Visit(this);
263 OS::Print(") "); 264 ISL_Print(") ");
264 node->body()->Visit(this); 265 node->body()->Visit(this);
265 OS::Print(")"); 266 ISL_Print(")");
266 } 267 }
267 268
268 269
269 void AstPrinter::VisitDoWhileNode(DoWhileNode* node) { 270 void AstPrinter::VisitDoWhileNode(DoWhileNode* node) {
270 VisitGenericAstNode(node); 271 VisitGenericAstNode(node);
271 } 272 }
272 273
273 274
274 void AstPrinter::VisitJumpNode(JumpNode* node) { 275 void AstPrinter::VisitJumpNode(JumpNode* node) {
275 OS::Print("(%s %s %s (scope \"%p\"))", 276 ISL_Print("(%s %s %s (scope \"%p\"))",
276 node->PrettyName(), 277 node->PrettyName(),
277 node->TokenName(), 278 node->TokenName(),
278 node->label()->name().ToCString(), 279 node->label()->name().ToCString(),
279 node->label()->owner()); 280 node->label()->owner());
280 } 281 }
281 282
282 283
283 void AstPrinter::VisitInstanceCallNode(InstanceCallNode* node) { 284 void AstPrinter::VisitInstanceCallNode(InstanceCallNode* node) {
284 OS::Print("(%s \"%s\" ", 285 ISL_Print("(%s \"%s\" ",
285 node->PrettyName(), 286 node->PrettyName(),
286 node->function_name().ToCString()); 287 node->function_name().ToCString());
287 node->VisitChildren(this); 288 node->VisitChildren(this);
288 OS::Print(")"); 289 ISL_Print(")");
289 } 290 }
290 291
291 292
292 void AstPrinter::VisitStaticCallNode(StaticCallNode* node) { 293 void AstPrinter::VisitStaticCallNode(StaticCallNode* node) {
293 const char* function_fullname = node->function().ToFullyQualifiedCString(); 294 const char* function_fullname = node->function().ToFullyQualifiedCString();
294 OS::Print("(%s \"%s\" ", node->PrettyName(), function_fullname); 295 ISL_Print("(%s \"%s\" ", node->PrettyName(), function_fullname);
295 node->VisitChildren(this); 296 node->VisitChildren(this);
296 OS::Print(")"); 297 ISL_Print(")");
297 } 298 }
298 299
299 300
300 void AstPrinter::VisitClosureNode(ClosureNode* node) { 301 void AstPrinter::VisitClosureNode(ClosureNode* node) {
301 const char* function_fullname = node->function().ToFullyQualifiedCString(); 302 const char* function_fullname = node->function().ToFullyQualifiedCString();
302 OS::Print("(%s \"%s\")", node->PrettyName(), function_fullname); 303 ISL_Print("(%s \"%s\")", node->PrettyName(), function_fullname);
303 } 304 }
304 305
305 306
306 void AstPrinter::VisitClosureCallNode(ClosureCallNode* node) { 307 void AstPrinter::VisitClosureCallNode(ClosureCallNode* node) {
307 VisitGenericAstNode(node); 308 VisitGenericAstNode(node);
308 } 309 }
309 310
310 311
311 void AstPrinter::VisitConstructorCallNode(ConstructorCallNode* node) { 312 void AstPrinter::VisitConstructorCallNode(ConstructorCallNode* node) {
312 const char* kind = node->constructor().IsFactory() ? "factory " : ""; 313 const char* kind = node->constructor().IsFactory() ? "factory " : "";
313 const char* constructor_name = node->constructor().ToFullyQualifiedCString(); 314 const char* constructor_name = node->constructor().ToFullyQualifiedCString();
314 OS::Print("(%s %s \"%s\" ", node->PrettyName(), kind, constructor_name); 315 ISL_Print("(%s %s \"%s\" ", node->PrettyName(), kind, constructor_name);
315 node->VisitChildren(this); 316 node->VisitChildren(this);
316 OS::Print(")"); 317 ISL_Print(")");
317 } 318 }
318 319
319 320
320 void AstPrinter::VisitInstanceGetterNode(InstanceGetterNode* node) { 321 void AstPrinter::VisitInstanceGetterNode(InstanceGetterNode* node) {
321 OS::Print("(%s \"%s\" ", 322 ISL_Print("(%s \"%s\" ",
322 node->PrettyName(), 323 node->PrettyName(),
323 node->field_name().ToCString()); 324 node->field_name().ToCString());
324 node->VisitChildren(this); 325 node->VisitChildren(this);
325 OS::Print(")"); 326 ISL_Print(")");
326 } 327 }
327 328
328 329
329 void AstPrinter::VisitInstanceSetterNode(InstanceSetterNode* node) { 330 void AstPrinter::VisitInstanceSetterNode(InstanceSetterNode* node) {
330 OS::Print("(%s \"%s\" ", 331 ISL_Print("(%s \"%s\" ",
331 node->PrettyName(), 332 node->PrettyName(),
332 node->field_name().ToCString()); 333 node->field_name().ToCString());
333 node->VisitChildren(this); 334 node->VisitChildren(this);
334 OS::Print(")"); 335 ISL_Print(")");
335 } 336 }
336 337
337 338
338 void AstPrinter::VisitInitStaticFieldNode(InitStaticFieldNode* node) { 339 void AstPrinter::VisitInitStaticFieldNode(InitStaticFieldNode* node) {
339 OS::Print("(%s \"%s\")", node->PrettyName(), 340 ISL_Print("(%s \"%s\")", node->PrettyName(),
340 String::Handle(node->field().name()).ToCString()); 341 String::Handle(node->field().name()).ToCString());
341 } 342 }
342 343
343 344
344 void AstPrinter::VisitStaticGetterNode(StaticGetterNode* node) { 345 void AstPrinter::VisitStaticGetterNode(StaticGetterNode* node) {
345 String& class_name = String::Handle(node->cls().Name()); 346 String& class_name = String::Handle(node->cls().Name());
346 OS::Print("(%s \"%s.%s\")", 347 ISL_Print("(%s \"%s.%s\")",
347 node->PrettyName(), 348 node->PrettyName(),
348 class_name.ToCString(), 349 class_name.ToCString(),
349 node->field_name().ToCString()); 350 node->field_name().ToCString());
350 } 351 }
351 352
352 353
353 void AstPrinter::VisitStaticSetterNode(StaticSetterNode* node) { 354 void AstPrinter::VisitStaticSetterNode(StaticSetterNode* node) {
354 String& class_name = String::Handle(node->cls().Name()); 355 String& class_name = String::Handle(node->cls().Name());
355 OS::Print("(%s \"%s.%s\" ", 356 ISL_Print("(%s \"%s.%s\" ",
356 node->PrettyName(), 357 node->PrettyName(),
357 class_name.ToCString(), 358 class_name.ToCString(),
358 node->field_name().ToCString()); 359 node->field_name().ToCString());
359 node->VisitChildren(this); 360 node->VisitChildren(this);
360 OS::Print(")"); 361 ISL_Print(")");
361 } 362 }
362 363
363 364
364 void AstPrinter::VisitLoadIndexedNode(LoadIndexedNode* node) { 365 void AstPrinter::VisitLoadIndexedNode(LoadIndexedNode* node) {
365 OS::Print("(%s%s ", node->PrettyName(), node->IsSuperLoad() ? " super" : ""); 366 ISL_Print("(%s%s ", node->PrettyName(), node->IsSuperLoad() ? " super" : "");
366 node->VisitChildren(this); 367 node->VisitChildren(this);
367 OS::Print(")"); 368 ISL_Print(")");
368 } 369 }
369 370
370 371
371 void AstPrinter::VisitStoreIndexedNode(StoreIndexedNode* node) { 372 void AstPrinter::VisitStoreIndexedNode(StoreIndexedNode* node) {
372 OS::Print("(%s%s ", node->PrettyName(), node->IsSuperStore() ? " super" : ""); 373 ISL_Print("(%s%s ", node->PrettyName(), node->IsSuperStore() ? " super" : "");
373 node->VisitChildren(this); 374 node->VisitChildren(this);
374 OS::Print(")"); 375 ISL_Print(")");
375 } 376 }
376 377
377 378
378 void AstPrinter::VisitNativeBodyNode(NativeBodyNode* node) { 379 void AstPrinter::VisitNativeBodyNode(NativeBodyNode* node) {
379 OS::Print("(%s \"%s\" (%" Pd " args))", 380 ISL_Print("(%s \"%s\" (%" Pd " args))",
380 node->PrettyName(), 381 node->PrettyName(),
381 node->native_c_function_name().ToCString(), 382 node->native_c_function_name().ToCString(),
382 NativeArguments::ParameterCountForResolution(node->function())); 383 NativeArguments::ParameterCountForResolution(node->function()));
383 } 384 }
384 385
385 386
386 void AstPrinter::VisitCatchClauseNode(CatchClauseNode* node) { 387 void AstPrinter::VisitCatchClauseNode(CatchClauseNode* node) {
387 VisitGenericAstNode(node); 388 VisitGenericAstNode(node);
388 } 389 }
389 390
390 391
391 void AstPrinter::VisitTryCatchNode(TryCatchNode* node) { 392 void AstPrinter::VisitTryCatchNode(TryCatchNode* node) {
392 OS::Print("(%s ", node->PrettyName()); 393 ISL_Print("(%s ", node->PrettyName());
393 node->try_block()->Visit(this); 394 node->try_block()->Visit(this);
394 if (node->catch_block() != NULL) { 395 if (node->catch_block() != NULL) {
395 node->catch_block()->Visit(this); 396 node->catch_block()->Visit(this);
396 } 397 }
397 if (node->finally_block() != NULL) { 398 if (node->finally_block() != NULL) {
398 OS::Print("(finally "); 399 ISL_Print("(finally ");
399 node->finally_block()->Visit(this); 400 node->finally_block()->Visit(this);
400 OS::Print(")"); 401 ISL_Print(")");
401 } 402 }
402 OS::Print(")"); 403 ISL_Print(")");
403 } 404 }
404 405
405 406
406 void AstPrinter::VisitThrowNode(ThrowNode* node) { 407 void AstPrinter::VisitThrowNode(ThrowNode* node) {
407 VisitGenericAstNode(node); 408 VisitGenericAstNode(node);
408 } 409 }
409 410
410 411
411 void AstPrinter::VisitInlinedFinallyNode(InlinedFinallyNode* node) { 412 void AstPrinter::VisitInlinedFinallyNode(InlinedFinallyNode* node) {
412 VisitGenericAstNode(node); 413 VisitGenericAstNode(node);
413 } 414 }
414 415
415 416
416 void AstPrinter::PrintNode(AstNode* node) { 417 void AstPrinter::PrintNode(AstNode* node) {
417 ASSERT(node != NULL); 418 ASSERT(node != NULL);
418 AstPrinter ast_printer; 419 AstPrinter ast_printer;
419 node->Visit(&ast_printer); 420 node->Visit(&ast_printer);
420 OS::Print("\n"); 421 ISL_Print("\n");
421 } 422 }
422 423
423 424
424 static void IndentN(int count) { 425 static void IndentN(int count) {
425 for (int i = 0; i < count; i++) { 426 for (int i = 0; i < count; i++) {
426 OS::Print(" "); 427 ISL_Print(" ");
427 } 428 }
428 } 429 }
429 430
430 431
431 void AstPrinter::PrintLocalScopeVariable(const LocalScope* scope, 432 void AstPrinter::PrintLocalScopeVariable(const LocalScope* scope,
432 LocalVariable* var, 433 LocalVariable* var,
433 int indent) { 434 int indent) {
434 ASSERT(scope != NULL); 435 ASSERT(scope != NULL);
435 ASSERT(var != NULL); 436 ASSERT(var != NULL);
436 IndentN(indent); 437 IndentN(indent);
437 OS::Print("(%s%s '%s'", 438 ISL_Print("(%s%s '%s'",
438 var->is_final() ? "final " : "", 439 var->is_final() ? "final " : "",
439 String::Handle(var->type().Name()).ToCString(), 440 String::Handle(var->type().Name()).ToCString(),
440 var->name().ToCString()); 441 var->name().ToCString());
441 if (var->owner() != scope) { 442 if (var->owner() != scope) {
442 OS::Print(" alias"); 443 ISL_Print(" alias");
443 } 444 }
444 if (var->HasIndex()) { 445 if (var->HasIndex()) {
445 OS::Print(" @%d", var->index()); 446 ISL_Print(" @%d", var->index());
446 if (var->is_captured()) { 447 if (var->is_captured()) {
447 OS::Print(" ctx %d", var->owner()->context_level()); 448 ISL_Print(" ctx %d", var->owner()->context_level());
448 } 449 }
449 } else if (var->owner()->function_level() != 0) { 450 } else if (var->owner()->function_level() != 0) {
450 OS::Print(" lev %d", var->owner()->function_level()); 451 ISL_Print(" lev %d", var->owner()->function_level());
451 } 452 }
452 OS::Print(" valid %" Pd "-%" Pd ")\n", 453 ISL_Print(" valid %" Pd "-%" Pd ")\n",
453 var->token_pos(), 454 var->token_pos(),
454 scope->end_token_pos()); 455 scope->end_token_pos());
455 } 456 }
456 457
457 458
458 void AstPrinter::PrintLocalScope(const LocalScope* scope, 459 void AstPrinter::PrintLocalScope(const LocalScope* scope,
459 int start_index, 460 int start_index,
460 int indent) { 461 int indent) {
461 ASSERT(scope != NULL); 462 ASSERT(scope != NULL);
462 for (int i = start_index; i < scope->num_variables(); i++) { 463 for (int i = start_index; i < scope->num_variables(); i++) {
463 LocalVariable* var = scope->VariableAt(i); 464 LocalVariable* var = scope->VariableAt(i);
464 PrintLocalScopeVariable(scope, var, indent); 465 PrintLocalScopeVariable(scope, var, indent);
465 } 466 }
466 const LocalScope* child = scope->child(); 467 const LocalScope* child = scope->child();
467 while (child != NULL) { 468 while (child != NULL) {
468 IndentN(indent); 469 IndentN(indent);
469 OS::Print("{scope %p ", child); 470 ISL_Print("{scope %p ", child);
470 if (child->HasContextLevel()) { 471 if (child->HasContextLevel()) {
471 OS::Print("ctx %d numctxvar %d ", 472 ISL_Print("ctx %d numctxvar %d ",
472 child->context_level(), 473 child->context_level(),
473 child->num_context_variables()); 474 child->num_context_variables());
474 } 475 }
475 OS::Print("llev %d\n", child->loop_level()); 476 ISL_Print("llev %d\n", child->loop_level());
476 PrintLocalScope(child, 0, indent + kScopeIndent); 477 PrintLocalScope(child, 0, indent + kScopeIndent);
477 IndentN(indent); 478 IndentN(indent);
478 OS::Print("}\n"); 479 ISL_Print("}\n");
479 child = child->sibling(); 480 child = child->sibling();
480 } 481 }
481 } 482 }
482 483
483 484
484 void AstPrinter::PrintFunctionScope(const ParsedFunction& parsed_function) { 485 void AstPrinter::PrintFunctionScope(const ParsedFunction& parsed_function) {
485 HANDLESCOPE(Isolate::Current()); 486 HANDLESCOPE(Isolate::Current());
486 const Function& function = parsed_function.function(); 487 const Function& function = parsed_function.function();
487 const Array& default_parameter_values = 488 const Array& default_parameter_values =
488 parsed_function.default_parameter_values(); 489 parsed_function.default_parameter_values();
489 SequenceNode* node_sequence = parsed_function.node_sequence(); 490 SequenceNode* node_sequence = parsed_function.node_sequence();
490 ASSERT(node_sequence != NULL); 491 ASSERT(node_sequence != NULL);
491 const LocalScope* scope = node_sequence->scope(); 492 const LocalScope* scope = node_sequence->scope();
492 ASSERT(scope != NULL); 493 ASSERT(scope != NULL);
493 const char* function_name = function.ToFullyQualifiedCString(); 494 const char* function_name = function.ToFullyQualifiedCString();
494 OS::Print("Scope for function '%s'\n{scope %p ", function_name, scope); 495 ISL_Print("Scope for function '%s'\n{scope %p ", function_name, scope);
495 if (scope->HasContextLevel()) { 496 if (scope->HasContextLevel()) {
496 OS::Print("ctx %d numctxvar %d ", 497 ISL_Print("ctx %d numctxvar %d ",
497 scope->context_level(), 498 scope->context_level(),
498 scope->num_context_variables()); 499 scope->num_context_variables());
499 } 500 }
500 OS::Print("llev %d\n", scope->loop_level()); 501 ISL_Print("llev %d\n", scope->loop_level());
501 const int num_fixed_params = function.num_fixed_parameters(); 502 const int num_fixed_params = function.num_fixed_parameters();
502 const int num_params = num_fixed_params + function.NumOptionalParameters(); 503 const int num_params = num_fixed_params + function.NumOptionalParameters();
503 // Parameters must be listed first and must all appear in the top scope. 504 // Parameters must be listed first and must all appear in the top scope.
504 ASSERT(num_params <= scope->num_variables()); 505 ASSERT(num_params <= scope->num_variables());
505 int pos = 0; // Current position of variable in scope. 506 int pos = 0; // Current position of variable in scope.
506 int indent = kScopeIndent; 507 int indent = kScopeIndent;
507 while (pos < num_params) { 508 while (pos < num_params) {
508 LocalVariable* param = scope->VariableAt(pos); 509 LocalVariable* param = scope->VariableAt(pos);
509 ASSERT(param->owner() == scope); // No aliases should precede parameters. 510 ASSERT(param->owner() == scope); // No aliases should precede parameters.
510 IndentN(indent); 511 IndentN(indent);
511 OS::Print("(param %s%s '%s'", 512 ISL_Print("(param %s%s '%s'",
512 param->is_final() ? "final " : "", 513 param->is_final() ? "final " : "",
513 String::Handle(param->type().Name()).ToCString(), 514 String::Handle(param->type().Name()).ToCString(),
514 param->name().ToCString()); 515 param->name().ToCString());
515 // Print the default value if the parameter is optional. 516 // Print the default value if the parameter is optional.
516 if (pos >= num_fixed_params && pos < num_params) { 517 if (pos >= num_fixed_params && pos < num_params) {
517 const Object& default_parameter_value = Object::Handle( 518 const Object& default_parameter_value = Object::Handle(
518 default_parameter_values.At(pos - num_fixed_params)); 519 default_parameter_values.At(pos - num_fixed_params));
519 OS::Print(" =%s", default_parameter_value.ToCString()); 520 ISL_Print(" =%s", default_parameter_value.ToCString());
520 } 521 }
521 if (param->HasIndex()) { 522 if (param->HasIndex()) {
522 OS::Print(" @%d", param->index()); 523 ISL_Print(" @%d", param->index());
523 if (param->is_captured()) { 524 if (param->is_captured()) {
524 OS::Print(" ctx %d", param->owner()->context_level()); 525 ISL_Print(" ctx %d", param->owner()->context_level());
525 } 526 }
526 } 527 }
527 OS::Print(" valid %" Pd "-%" Pd ")\n", 528 ISL_Print(" valid %" Pd "-%" Pd ")\n",
528 param->token_pos(), 529 param->token_pos(),
529 scope->end_token_pos()); 530 scope->end_token_pos());
530 pos++; 531 pos++;
531 } 532 }
532 // Visit remaining non-parameter variables and children scopes. 533 // Visit remaining non-parameter variables and children scopes.
533 PrintLocalScope(scope, pos, indent); 534 PrintLocalScope(scope, pos, indent);
534 OS::Print("}\n"); 535 ISL_Print("}\n");
535 } 536 }
536 537
537 538
538 void AstPrinter::PrintFunctionNodes(const ParsedFunction& parsed_function) { 539 void AstPrinter::PrintFunctionNodes(const ParsedFunction& parsed_function) {
539 HANDLESCOPE(Isolate::Current()); 540 HANDLESCOPE(Isolate::Current());
540 SequenceNode* node_sequence = parsed_function.node_sequence(); 541 SequenceNode* node_sequence = parsed_function.node_sequence();
541 ASSERT(node_sequence != NULL); 542 ASSERT(node_sequence != NULL);
542 AstPrinter ast_printer; 543 AstPrinter ast_printer;
543 const char* function_name = 544 const char* function_name =
544 parsed_function.function().ToFullyQualifiedCString(); 545 parsed_function.function().ToFullyQualifiedCString();
545 OS::Print("Ast for function '%s' {\n", function_name); 546 ISL_Print("Ast for function '%s' {\n", function_name);
546 node_sequence->Visit(&ast_printer); 547 node_sequence->Visit(&ast_printer);
547 OS::Print("}\n"); 548 ISL_Print("}\n");
548 } 549 }
549 550
550 } // namespace dart 551 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/intrinsifier.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698