toString() methods + one old typo

This commit is contained in:
upnotes
2018-08-10 15:02:21 +02:00
committed by Roman Shevchenko
parent 7e98f686c0
commit 1af631be9d
4 changed files with 256 additions and 2 deletions

View File

@@ -1,6 +1,8 @@
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package org.jetbrains.java.decompiler.code;
import org.jetbrains.java.decompiler.util.TextUtil;
public class Instruction implements CodeConstants {
public static Instruction create(int opcode, boolean wide, int group, int bytecodeVersion, int[] operands) {
if (opcode >= opc_ifeq && opcode <= opc_if_acmpne ||
@@ -57,6 +59,25 @@ public class Instruction implements CodeConstants {
opcode != opc_jsr && opcode != opc_tableswitch && opcode != opc_lookupswitch;
}
public String toString() {
String res = wide ? "@wide " : "";
res += "@" + TextUtil.getInstructionName(opcode);
int len = operandsCount();
for (int i = 0; i < len; i++) {
int op = operands[i];
if (op < 0) {
res += " -" + Integer.toHexString(-op);
}
else {
res += " " + Integer.toHexString(op);
}
}
return res;
}
@Override
@SuppressWarnings("MethodDoesntCallSuperMethod")
public Instruction clone() {