| 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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 | 165 |
| 166 String temporaryId(HInstruction instruction) { | 166 String temporaryId(HInstruction instruction) { |
| 167 String prefix; | 167 String prefix; |
| 168 HType type = instruction.propagatedType; | 168 HType type = instruction.propagatedType; |
| 169 if (type.isNonPrimitive()) { | 169 if (type.isNonPrimitive()) { |
| 170 prefix = 'U'; | 170 prefix = 'U'; |
| 171 } else { | 171 } else { |
| 172 switch (type) { | 172 switch (type) { |
| 173 case HType.MUTABLE_ARRAY: prefix = 'm'; break; | 173 case HType.MUTABLE_ARRAY: prefix = 'm'; break; |
| 174 case HType.READABLE_ARRAY: prefix = 'a'; break; | 174 case HType.READABLE_ARRAY: prefix = 'a'; break; |
| 175 case HType.EXTENDABLE_ARRAY: prefix = 'e'; break; |
| 175 case HType.BOOLEAN: prefix = 'b'; break; | 176 case HType.BOOLEAN: prefix = 'b'; break; |
| 176 case HType.INTEGER: prefix = 'i'; break; | 177 case HType.INTEGER: prefix = 'i'; break; |
| 177 case HType.DOUBLE: prefix = 'd'; break; | 178 case HType.DOUBLE: prefix = 'd'; break; |
| 178 case HType.NUMBER: prefix = 'n'; break; | 179 case HType.NUMBER: prefix = 'n'; break; |
| 179 case HType.STRING: prefix = 's'; break; | 180 case HType.STRING: prefix = 's'; break; |
| 180 case HType.UNKNOWN: prefix = 'v'; break; | 181 case HType.UNKNOWN: prefix = 'v'; break; |
| 181 case HType.CONFLICTING: prefix = 'c'; break; | 182 case HType.CONFLICTING: prefix = 'c'; break; |
| 182 case HType.STRING_OR_ARRAY: prefix = 'r'; break; | 183 case HType.INDEXABLE: prefix = 'r'; break; |
| 183 default: unreachable(); | 184 default: unreachable(); |
| 184 } | 185 } |
| 185 } | 186 } |
| 186 return "$prefix${instruction.id}"; | 187 return "$prefix${instruction.id}"; |
| 187 } | 188 } |
| 188 | 189 |
| 189 String visitBoolify(HBoolify node) { | 190 String visitBoolify(HBoolify node) { |
| 190 return "Boolify: ${temporaryId(node.inputs[0])}"; | 191 return "Boolify: ${temporaryId(node.inputs[0])}"; |
| 191 } | 192 } |
| 192 | 193 |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 finallyBlock = 'none'; | 404 finallyBlock = 'none'; |
| 404 } | 405 } |
| 405 return "Try: $tryBlock, Catch: $catchBlocks, Finally: $finallyBlock"; | 406 return "Try: $tryBlock, Catch: $catchBlocks, Finally: $finallyBlock"; |
| 406 } | 407 } |
| 407 | 408 |
| 408 String visitTypeGuard(HTypeGuard node) { | 409 String visitTypeGuard(HTypeGuard node) { |
| 409 String type; | 410 String type; |
| 410 switch (node.guardedType) { | 411 switch (node.guardedType) { |
| 411 case HType.MUTABLE_ARRAY: type = "mutable_array"; break; | 412 case HType.MUTABLE_ARRAY: type = "mutable_array"; break; |
| 412 case HType.READABLE_ARRAY: type = "readable_array"; break; | 413 case HType.READABLE_ARRAY: type = "readable_array"; break; |
| 414 case HType.EXTENDABLE_ARRAY: type = "extendable_array"; break; |
| 413 case HType.BOOLEAN: type = "bool"; break; | 415 case HType.BOOLEAN: type = "bool"; break; |
| 414 case HType.INTEGER: type = "integer"; break; | 416 case HType.INTEGER: type = "integer"; break; |
| 415 case HType.DOUBLE: type = "double"; break; | 417 case HType.DOUBLE: type = "double"; break; |
| 416 case HType.NUMBER: type = "number"; break; | 418 case HType.NUMBER: type = "number"; break; |
| 417 case HType.STRING: type = "string"; break; | 419 case HType.STRING: type = "string"; break; |
| 418 case HType.STRING_OR_ARRAY: type = "string_or_array"; break; | 420 case HType.INDEXABLE: type = "string_or_array"; break; |
| 419 case HType.UNKNOWN: type = 'unknown'; break; | 421 case HType.UNKNOWN: type = 'unknown'; break; |
| 420 default: unreachable(); | 422 default: unreachable(); |
| 421 } | 423 } |
| 422 StringBuffer envBuffer = new StringBuffer(); | 424 StringBuffer envBuffer = new StringBuffer(); |
| 423 List<HInstruction> inputs = node.inputs; | 425 List<HInstruction> inputs = node.inputs; |
| 424 // The last input is the guarded expression. | 426 // The last input is the guarded expression. |
| 425 for (int i = 0; i < inputs.length - 1; i++) { | 427 for (int i = 0; i < inputs.length - 1; i++) { |
| 426 envBuffer.add(" ${temporaryId(inputs[i])}"); | 428 envBuffer.add(" ${temporaryId(inputs[i])}"); |
| 427 } | 429 } |
| 428 String on = node.isOn ? "on" : "off"; | 430 String on = node.isOn ? "on" : "off"; |
| 429 String id = temporaryId(node.guarded); | 431 String id = temporaryId(node.guarded); |
| 430 return "TypeGuard($on): $id is $type env: $envBuffer"; | 432 return "TypeGuard($on): $id is $type env: $envBuffer"; |
| 431 } | 433 } |
| 432 | 434 |
| 433 String visitIs(HIs node) { | 435 String visitIs(HIs node) { |
| 434 String type = node.typeName.toString(); | 436 String type = node.typeName.toString(); |
| 435 return "TypeTest: ${temporaryId(node.expression)} is $type"; | 437 return "TypeTest: ${temporaryId(node.expression)} is $type"; |
| 436 } | 438 } |
| 437 } | 439 } |
| OLD | NEW |