| OLD | NEW |
| 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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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) { | 162 visitBasicBlock(HBasicBlock node) { |
| 163 unreachable(); | 163 // TODO(floitsch): Need a compiler object. |
| 164 compiler.internalError('conditionExpression should not be called', |
| 165 instruction: node); |
| 164 } | 166 } |
| 165 | 167 |
| 166 String temporaryId(HInstruction instruction) { | 168 String temporaryId(HInstruction instruction) { |
| 167 String prefix; | 169 String prefix; |
| 168 HType type = instruction.propagatedType; | 170 HType type = instruction.propagatedType; |
| 169 if (!type.isPrimitive()) { | 171 if (!type.isPrimitive()) { |
| 170 prefix = 'U'; | 172 prefix = 'U'; |
| 171 } else { | 173 } else { |
| 172 switch (type) { | 174 switch (type) { |
| 173 case HType.MUTABLE_ARRAY: prefix = 'm'; break; | 175 case HType.MUTABLE_ARRAY: prefix = 'm'; break; |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 case HType.MUTABLE_ARRAY: type = "mutable_array"; break; | 415 case HType.MUTABLE_ARRAY: type = "mutable_array"; break; |
| 414 case HType.READABLE_ARRAY: type = "readable_array"; break; | 416 case HType.READABLE_ARRAY: type = "readable_array"; break; |
| 415 case HType.EXTENDABLE_ARRAY: type = "extendable_array"; break; | 417 case HType.EXTENDABLE_ARRAY: type = "extendable_array"; break; |
| 416 case HType.BOOLEAN: type = "bool"; break; | 418 case HType.BOOLEAN: type = "bool"; break; |
| 417 case HType.INTEGER: type = "integer"; break; | 419 case HType.INTEGER: type = "integer"; break; |
| 418 case HType.DOUBLE: type = "double"; break; | 420 case HType.DOUBLE: type = "double"; break; |
| 419 case HType.NUMBER: type = "number"; break; | 421 case HType.NUMBER: type = "number"; break; |
| 420 case HType.STRING: type = "string"; break; | 422 case HType.STRING: type = "string"; break; |
| 421 case HType.INDEXABLE_PRIMITIVE: type = "string_or_array"; break; | 423 case HType.INDEXABLE_PRIMITIVE: type = "string_or_array"; break; |
| 422 case HType.UNKNOWN: type = 'unknown'; break; | 424 case HType.UNKNOWN: type = 'unknown'; break; |
| 423 default: unreachable(); | 425 default: |
| 426 // TODO(floitsch): Need a compiler object. |
| 427 compiler.internalError('Unexpected type guard.', |
| 428 instruction: node.guardedType); |
| 429 break; |
| 424 } | 430 } |
| 425 StringBuffer envBuffer = new StringBuffer(); | 431 StringBuffer envBuffer = new StringBuffer(); |
| 426 List<HInstruction> inputs = node.inputs; | 432 List<HInstruction> inputs = node.inputs; |
| 427 // The last input is the guarded expression. | 433 // The last input is the guarded expression. |
| 428 for (int i = 0; i < inputs.length - 1; i++) { | 434 for (int i = 0; i < inputs.length - 1; i++) { |
| 429 envBuffer.add(" ${temporaryId(inputs[i])}"); | 435 envBuffer.add(" ${temporaryId(inputs[i])}"); |
| 430 } | 436 } |
| 431 String on = node.isOn ? "on" : "off"; | 437 String on = node.isOn ? "on" : "off"; |
| 432 String id = temporaryId(node.guarded); | 438 String id = temporaryId(node.guarded); |
| 433 return "TypeGuard($on): $id is $type env: $envBuffer"; | 439 return "TypeGuard($on): $id is $type env: $envBuffer"; |
| 434 } | 440 } |
| 435 | 441 |
| 436 String visitIs(HIs node) { | 442 String visitIs(HIs node) { |
| 437 String type = node.typeExpression.toString(); | 443 String type = node.typeExpression.toString(); |
| 438 return "TypeTest: ${temporaryId(node.expression)} is $type"; | 444 return "TypeTest: ${temporaryId(node.expression)} is $type"; |
| 439 } | 445 } |
| 440 | 446 |
| 441 String visitTypeConversion(HTypeConversion node) { | 447 String visitTypeConversion(HTypeConversion node) { |
| 442 String type = node.propagatedType.toString(); | 448 String type = node.propagatedType.toString(); |
| 443 return "TypeConversion: ${temporaryId(node.inputs[0])} to $type"; | 449 return "TypeConversion: ${temporaryId(node.inputs[0])} to $type"; |
| 444 } | 450 } |
| 445 } | 451 } |
| OLD | NEW |