summaryrefslogtreecommitdiff
path: root/src/partest-extras/scala/tools/partest/ASMConverters.scala
diff options
context:
space:
mode:
Diffstat (limited to 'src/partest-extras/scala/tools/partest/ASMConverters.scala')
-rw-r--r--src/partest-extras/scala/tools/partest/ASMConverters.scala27
1 files changed, 23 insertions, 4 deletions
diff --git a/src/partest-extras/scala/tools/partest/ASMConverters.scala b/src/partest-extras/scala/tools/partest/ASMConverters.scala
index b4c686473b..a3d849a9c1 100644
--- a/src/partest-extras/scala/tools/partest/ASMConverters.scala
+++ b/src/partest-extras/scala/tools/partest/ASMConverters.scala
@@ -38,6 +38,28 @@ object ASMConverters {
}
def dropNonOp = dropLinesFrames.dropStaleLabels
+
+ def summary: List[Any] = dropNonOp map {
+ case i: Invoke => i.name
+ case i => i.opcode
+ }
+
+ def summaryText: String = {
+ def comment(i: Instruction) = i match {
+ case j: Jump => s" /*${j.label.offset}*/"
+ case l: Label => s" /*${l.offset}*/"
+ case _ => ""
+ }
+ dropNonOp.map({
+ case i: Invoke => s""""${i.name}""""
+ case ins => opcodeToString(ins.opcode, ins.opcode) + comment(ins)
+ }).mkString("List(", ", ", ")")
+ }
+ }
+
+ def opcodeToString(op: Int, default: Any = "?"): String = {
+ import scala.tools.asm.util.Printer.OPCODES
+ if (OPCODES.isDefinedAt(op)) OPCODES(op) else default.toString
}
sealed abstract class Instruction extends Product {
@@ -45,12 +67,9 @@ object ASMConverters {
// toString such that the first field, "opcode: Int", is printed textually.
final override def toString() = {
- import scala.tools.asm.util.Printer.OPCODES
- def opString(op: Int) = if (OPCODES.isDefinedAt(op)) OPCODES(op) else "?"
val printOpcode = opcode != -1
-
productPrefix + (
- if (printOpcode) Iterator(opString(opcode)) ++ productIterator.drop(1)
+ if (printOpcode) Iterator(opcodeToString(opcode)) ++ productIterator.drop(1)
else productIterator
).mkString("(", ", ", ")")
}