toString() methods + one old typo
This commit is contained in:
committed by
Roman Shevchenko
parent
7e98f686c0
commit
1af631be9d
@@ -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() {
|
||||
|
||||
@@ -5,6 +5,8 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.jetbrains.java.decompiler.main.DecompilerContext;
|
||||
|
||||
public class ExceptionRangeCFG {
|
||||
private final List<BasicBlock> protectedRange; // FIXME: replace with set
|
||||
private BasicBlock handler;
|
||||
@@ -23,6 +25,28 @@ public class ExceptionRangeCFG {
|
||||
return protectedRange.contains(handler);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
|
||||
String new_line_separator = DecompilerContext.getNewLineSeparator();
|
||||
|
||||
StringBuilder buf = new StringBuilder();
|
||||
|
||||
buf.append("exceptionType:");
|
||||
for (String exception_type : exceptionTypes) {
|
||||
buf.append(" ").append(exception_type);
|
||||
}
|
||||
buf.append(new_line_separator);
|
||||
|
||||
buf.append("handler: ").append(handler.id).append(new_line_separator);
|
||||
buf.append("range: ");
|
||||
for (int i = 0; i < protectedRange.size(); i++) {
|
||||
buf.append(protectedRange.get(i).id).append(" ");
|
||||
}
|
||||
buf.append(new_line_separator);
|
||||
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
public BasicBlock getHandler() {
|
||||
return handler;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user