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

Side by Side Diff: lib/compiler/implementation/ssa/tracer.dart

Issue 10557003: Fix most warnings and other minor cleanups. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 6 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) 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 #library('tracer'); 5 #library('tracer');
6 6
7 #import('dart:io'); 7 #import('dart:io');
8 #import('ssa.dart'); 8 #import('ssa.dart');
9 #import('../leg.dart'); 9 #import('../leg.dart');
10 10
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 } 152 }
153 } 153 }
154 154
155 class HInstructionStringifier implements HVisitor<String> { 155 class HInstructionStringifier implements HVisitor<String> {
156 HBasicBlock currentBlock; 156 HBasicBlock currentBlock;
157 157
158 HInstructionStringifier(this.currentBlock); 158 HInstructionStringifier(this.currentBlock);
159 159
160 visit(HInstruction node) => node.accept(this); 160 visit(HInstruction node) => node.accept(this);
161 161
162 visitBasicBlock(HBasicBlock node) {
163 // TODO(floitsch): Need a compiler object.
164 compiler.internalError('conditionExpression should not be called',
165 instruction: node);
166 }
167
168 String temporaryId(HInstruction instruction) { 162 String temporaryId(HInstruction instruction) {
169 String prefix; 163 String prefix;
170 HType type = instruction.propagatedType; 164 HType type = instruction.propagatedType;
171 if (!type.isPrimitive()) { 165 if (!type.isPrimitive()) {
172 prefix = 'U'; 166 prefix = 'U';
173 } else { 167 } else {
174 switch (type) { 168 if (type == HType.MUTABLE_ARRAY) {
karlklose 2012/06/15 12:43:46 How about a map?
floitsch 2012/06/15 13:05:17 literal maps must contain strings as keys.
175 case HType.MUTABLE_ARRAY: prefix = 'm'; break; 169 prefix = 'm';
176 case HType.READABLE_ARRAY: prefix = 'a'; break; 170 } else if (type == HType.READABLE_ARRAY) {
177 case HType.EXTENDABLE_ARRAY: prefix = 'e'; break; 171 prefix = 'a';
178 case HType.BOOLEAN: prefix = 'b'; break; 172 } else if (type == HType.EXTENDABLE_ARRAY) {
179 case HType.INTEGER: prefix = 'i'; break; 173 prefix = 'e';
180 case HType.DOUBLE: prefix = 'd'; break; 174 } else if (type == HType.BOOLEAN) {
181 case HType.NUMBER: prefix = 'n'; break; 175 prefix = 'b';
182 case HType.STRING: prefix = 's'; break; 176 } else if (type == HType.INTEGER) {
183 case HType.UNKNOWN: prefix = 'v'; break; 177 prefix = 'i';
184 case HType.CONFLICTING: prefix = 'c'; break; 178 } else if (type == HType.DOUBLE) {
185 case HType.INDEXABLE_PRIMITIVE: prefix = 'r'; break; 179 prefix = 'd';
186 case HType.NULL: prefix = 'u'; break; 180 } else if (type == HType.NUMBER) {
187 default: prefix = 'x'; 181 prefix = 'n';
182 } else if (type == HType.STRING) {
183 prefix = 's';
184 } else if (type == HType.UNKNOWN) {
185 prefix = 'v';
186 } else if (type == HType.CONFLICTING) {
187 prefix = 'c';
188 } else if (type == HType.INDEXABLE_PRIMITIVE) {
189 prefix = 'r';
190 } else if (type == HType.NULL) {
191 prefix = 'u';
192 } else {
193 prefix = 'x';
188 } 194 }
189 } 195 }
190 return "$prefix${instruction.id}"; 196 return "$prefix${instruction.id}";
191 } 197 }
192 198
193 String visitBoolify(HBoolify node) { 199 String visitBoolify(HBoolify node) {
194 return "Boolify: ${temporaryId(node.inputs[0])}"; 200 return "Boolify: ${temporaryId(node.inputs[0])}";
195 } 201 }
196 202
197 String visitAdd(HAdd node) => visitInvokeStatic(node); 203 String visitAdd(HAdd node) => visitInvokeStatic(node);
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 if (node.finallyBlock != null) { 431 if (node.finallyBlock != null) {
426 finallyBlock = 'B${node.finallyBlock.id}'; 432 finallyBlock = 'B${node.finallyBlock.id}';
427 } 433 }
428 434
429 return "Try: $tryBlock, Catch: $catchBlock, Finally: $finallyBlock, " 435 return "Try: $tryBlock, Catch: $catchBlock, Finally: $finallyBlock, "
430 "Join: B${successors.last().id}"; 436 "Join: B${successors.last().id}";
431 } 437 }
432 438
433 String visitTypeGuard(HTypeGuard node) { 439 String visitTypeGuard(HTypeGuard node) {
434 String type; 440 String type;
435 switch (node.guardedType) { 441 HType guardedType = node.guardedType;
karlklose 2012/06/15 12:43:46 Ditto.
436 case HType.MUTABLE_ARRAY: type = "mutable_array"; break; 442 if (guardedType == HType.MUTABLE_ARRAY) {
437 case HType.READABLE_ARRAY: type = "readable_array"; break; 443 type = "mutable_array";
438 case HType.EXTENDABLE_ARRAY: type = "extendable_array"; break; 444 } else if (guardedType == HType.READABLE_ARRAY) {
439 case HType.BOOLEAN: type = "bool"; break; 445 type = "readable_array";
440 case HType.INTEGER: type = "integer"; break; 446 } else if (guardedType == HType.EXTENDABLE_ARRAY) {
441 case HType.DOUBLE: type = "double"; break; 447 type = "extendable_array";
442 case HType.NUMBER: type = "number"; break; 448 } else if (guardedType == HType.BOOLEAN) {
443 case HType.STRING: type = "string"; break; 449 type = "bool";
444 case HType.INDEXABLE_PRIMITIVE: type = "string_or_array"; break; 450 } else if (guardedType == HType.INTEGER) {
445 case HType.UNKNOWN: type = 'unknown'; break; 451 type = "integer";
446 default: 452 } else if (guardedType == HType.DOUBLE) {
447 // TODO(floitsch): Need a compiler object. 453 type = "double";
448 compiler.internalError('Unexpected type guard.', 454 } else if (guardedType == HType.NUMBER) {
449 instruction: node.guardedType); 455 type = "number";
450 break; 456 } else if (guardedType == HType.STRING) {
457 type = "string";
458 } else if (guardedType == HType.INDEXABLE_PRIMITIVE) {
459 type = "string_or_array";
460 } else if (guardedType == HType.UNKNOWN) {
461 type = 'unknown';
462 } else {
463 throw new CompilerCancelledException('Unexpected type guard: $type');
451 } 464 }
452 StringBuffer envBuffer = new StringBuffer(); 465 StringBuffer envBuffer = new StringBuffer();
453 List<HInstruction> inputs = node.inputs; 466 List<HInstruction> inputs = node.inputs;
454 // The last input is the guarded expression. 467 // The last input is the guarded expression.
455 for (int i = 0; i < inputs.length - 1; i++) { 468 for (int i = 0; i < inputs.length - 1; i++) {
456 envBuffer.add(" ${temporaryId(inputs[i])}"); 469 envBuffer.add(" ${temporaryId(inputs[i])}");
457 } 470 }
458 String on = node.isOn ? "on" : "off"; 471 String on = node.isOn ? "on" : "off";
459 String id = temporaryId(node.guarded); 472 String id = temporaryId(node.guarded);
460 return "TypeGuard($on): $id is $type env: $envBuffer"; 473 return "TypeGuard($on): $id is $type env: $envBuffer";
461 } 474 }
462 475
463 String visitIs(HIs node) { 476 String visitIs(HIs node) {
464 String type = node.typeExpression.toString(); 477 String type = node.typeExpression.toString();
465 return "TypeTest: ${temporaryId(node.expression)} is $type"; 478 return "TypeTest: ${temporaryId(node.expression)} is $type";
466 } 479 }
467 480
468 String visitTypeConversion(HTypeConversion node) { 481 String visitTypeConversion(HTypeConversion node) {
469 String type = node.propagatedType.toString(); 482 String type = node.propagatedType.toString();
470 return "TypeConversion: ${temporaryId(node.inputs[0])} to $type"; 483 return "TypeConversion: ${temporaryId(node.inputs[0])} to $type";
471 } 484 }
472 } 485 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698