[java decompiler] cleanup (dead code; optimizations; warnings)

This commit is contained in:
Roman Shevchenko
2017-12-01 18:23:42 +01:00
parent 71d8f4d689
commit 29de7ad72e
140 changed files with 761 additions and 5054 deletions

View File

@@ -1,8 +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;
@SuppressWarnings({"unused", "SpellCheckingInspection"})
public interface CodeConstants {
// ----------------------------------------------------------------------
// BYTECODE VERSIONS
// ----------------------------------------------------------------------
@@ -50,20 +50,6 @@ public interface CodeConstants {
int TYPE_FAMILY_DOUBLE = 5;
int TYPE_FAMILY_OBJECT = 6;
// ----------------------------------------------------------------------
// MODULE CONSTANTS
// ----------------------------------------------------------------------
int STACKSIZE_SIMPLE = 1;
int STACKSIZE_DOUBLE = 2;
int VAR_LOCAL = 0;
int VAR_STACK = 1;
int VAR_WRITE = 0;
int VAR_READ = 1;
// ----------------------------------------------------------------------
// ACCESS FLAGS
// ----------------------------------------------------------------------
@@ -92,17 +78,6 @@ public interface CodeConstants {
int ACC_SUPER = 0x0020;
int ACC_INTERFACE = 0x0200;
// ----------------------------------------------------------------------
// DEPENDENCY CONSTANTS
// ----------------------------------------------------------------------
int DEP_CONSTANT = 0;
int DEP_UNKNOWN = 1;
int DEP_GENERAL = 2;
int DEP_PARAMS = 4;
int DEP_STATIC = 8;
// ----------------------------------------------------------------------
// INSTRUCTION GROUPS
// ----------------------------------------------------------------------
@@ -338,7 +313,6 @@ public interface CodeConstants {
int opc_invokestatic = 184;
int opc_invokeinterface = 185;
int opc_invokedynamic = 186;
int opc_xxxunusedxxx = 186;
int opc_new = 187;
int opc_newarray = 188;
int opc_anewarray = 189;
@@ -355,7 +329,6 @@ public interface CodeConstants {
int opc_goto_w = 200;
int opc_jsr_w = 201;
@SuppressWarnings("SpellCheckingInspection")
String CLINIT_NAME = "<clinit>";
String INIT_NAME = "<init>";
}
}

View File

@@ -1,468 +0,0 @@
// 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.code.optinstructions.*;
public class ConstantsUtil {
public static String getName(int opcode) {
return opcodeNames[opcode];
}
public static Instruction getInstructionInstance(int opcode, boolean wide, int group, int bytecode_version, int[] operands) {
Instruction instr = getInstructionInstance(opcode, bytecode_version);
instr.wide = wide;
instr.group = group;
instr.bytecode_version = bytecode_version;
instr.setOperands(operands);
return instr;
}
private static Instruction getInstructionInstance(int opcode, int bytecode_version) {
try {
Instruction instr;
if ((opcode >= CodeConstants.opc_ifeq &&
opcode <= CodeConstants.opc_if_acmpne) ||
opcode == CodeConstants.opc_ifnull ||
opcode == CodeConstants.opc_ifnonnull) {
instr = new IfInstruction();
}
else {
Class cl = opcodeClasses[opcode];
if (opcode == CodeConstants.opc_invokedynamic && bytecode_version < CodeConstants.BYTECODE_JAVA_7) {
cl = null; // instruction unused in Java 6 and before
}
if (cl == null) {
instr = new Instruction();
}
else {
instr = (Instruction)cl.newInstance();
}
}
instr.opcode = opcode;
return instr;
}
catch (Exception ex) {
return null;
}
}
private static final String[] opcodeNames = {
"nop", // "nop",
"aconst_null", // "aconst_null",
"iconst_m1", // "iconst_m1",
"iconst_0", // "iconst_0",
"iconst_1", // "iconst_1",
"iconst_2", // "iconst_2",
"iconst_3", // "iconst_3",
"iconst_4", // "iconst_4",
"iconst_5", // "iconst_5",
"lconst_0", // "lconst_0",
"lconst_1", // "lconst_1",
"fconst_0", // "fconst_0",
"fconst_1", // "fconst_1",
"fconst_2", // "fconst_2",
"dconst_0", // "dconst_0",
"dconst_1", // "dconst_1",
"bipush", // "bipush",
"sipush", // "sipush",
"ldc", // "ldc",
"ldc_w", // "ldc_w",
"ldc2_w", // "ldc2_w",
"iload", // "iload",
"lload", // "lload",
"fload", // "fload",
"dload", // "dload",
"aload", // "aload",
"iload_0", // "iload_0",
"iload_1", // "iload_1",
"iload_2", // "iload_2",
"iload_3", // "iload_3",
"lload_0", // "lload_0",
"lload_1", // "lload_1",
"lload_2", // "lload_2",
"lload_3", // "lload_3",
"fload_0", // "fload_0",
"fload_1", // "fload_1",
"fload_2", // "fload_2",
"fload_3", // "fload_3",
"dload_0", // "dload_0",
"dload_1", // "dload_1",
"dload_2", // "dload_2",
"dload_3", // "dload_3",
"aload_0", // "aload_0",
"aload_1", // "aload_1",
"aload_2", // "aload_2",
"aload_3", // "aload_3",
"iaload", // "iaload",
"laload", // "laload",
"faload", // "faload",
"daload", // "daload",
"aaload", // "aaload",
"baload", // "baload",
"caload", // "caload",
"saload", // "saload",
"istore", // "istore",
"lstore", // "lstore",
"fstore", // "fstore",
"dstore", // "dstore",
"astore", // "astore",
"istore_0", // "istore_0",
"istore_1", // "istore_1",
"istore_2", // "istore_2",
"istore_3", // "istore_3",
"lstore_0", // "lstore_0",
"lstore_1", // "lstore_1",
"lstore_2", // "lstore_2",
"lstore_3", // "lstore_3",
"fstore_0", // "fstore_0",
"fstore_1", // "fstore_1",
"fstore_2", // "fstore_2",
"fstore_3", // "fstore_3",
"dstore_0", // "dstore_0",
"dstore_1", // "dstore_1",
"dstore_2", // "dstore_2",
"dstore_3", // "dstore_3",
"astore_0", // "astore_0",
"astore_1", // "astore_1",
"astore_2", // "astore_2",
"astore_3", // "astore_3",
"iastore", // "iastore",
"lastore", // "lastore",
"fastore", // "fastore",
"dastore", // "dastore",
"aastore", // "aastore",
"bastore", // "bastore",
"castore", // "castore",
"sastore", // "sastore",
"pop", // "pop",
"pop2", // "pop2",
"dup", // "dup",
"dup_x1", // "dup_x1",
"dup_x2", // "dup_x2",
"dup2", // "dup2",
"dup2_x1", // "dup2_x1",
"dup2_x2", // "dup2_x2",
"swap", // "swap",
"iadd", // "iadd",
"ladd", // "ladd",
"fadd", // "fadd",
"dadd", // "dadd",
"isub", // "isub",
"lsub", // "lsub",
"fsub", // "fsub",
"dsub", // "dsub",
"imul", // "imul",
"lmul", // "lmul",
"fmul", // "fmul",
"dmul", // "dmul",
"idiv", // "idiv",
"ldiv", // "ldiv",
"fdiv", // "fdiv",
"ddiv", // "ddiv",
"irem", // "irem",
"lrem", // "lrem",
"frem", // "frem",
"drem", // "drem",
"ineg", // "ineg",
"lneg", // "lneg",
"fneg", // "fneg",
"dneg", // "dneg",
"ishl", // "ishl",
"lshl", // "lshl",
"ishr", // "ishr",
"lshr", // "lshr",
"iushr", // "iushr",
"lushr", // "lushr",
"iand", // "iand",
"land", // "land",
"ior", // "ior",
"lor", // "lor",
"ixor", // "ixor",
"lxor", // "lxor",
"iinc", // "iinc",
"i2l", // "i2l",
"i2f", // "i2f",
"i2d", // "i2d",
"l2i", // "l2i",
"l2f", // "l2f",
"l2d", // "l2d",
"f2i", // "f2i",
"f2l", // "f2l",
"f2d", // "f2d",
"d2i", // "d2i",
"d2l", // "d2l",
"d2f", // "d2f",
"i2b", // "i2b",
"i2c", // "i2c",
"i2s", // "i2s",
"lcmp", // "lcmp",
"fcmpl", // "fcmpl",
"fcmpg", // "fcmpg",
"dcmpl", // "dcmpl",
"dcmpg", // "dcmpg",
"ifeq", // "ifeq",
"ifne", // "ifne",
"iflt", // "iflt",
"ifge", // "ifge",
"ifgt", // "ifgt",
"ifle", // "ifle",
"if_icmpeq", // "if_icmpeq",
"if_icmpne", // "if_icmpne",
"if_icmplt", // "if_icmplt",
"if_icmpge", // "if_icmpge",
"if_icmpgt", // "if_icmpgt",
"if_icmple", // "if_icmple",
"if_acmpeq", // "if_acmpeq",
"if_acmpne", // "if_acmpne",
"goto", // "goto",
"jsr", // "jsr",
"ret", // "ret",
"tableswitch", // "tableswitch",
"lookupswitch", // "lookupswitch",
"ireturn", // "ireturn",
"lreturn", // "lreturn",
"freturn", // "freturn",
"dreturn", // "dreturn",
"areturn", // "areturn",
"return", // "return",
"getstatic", // "getstatic",
"putstatic", // "putstatic",
"getfield", // "getfield",
"putfield", // "putfield",
"invokevirtual", // "invokevirtual",
"invokespecial", // "invokespecial",
"invokestatic", // "invokestatic",
"invokeinterface", // "invokeinterface",
//"xxxunusedxxx", // "xxxunusedxxx", Java 6 and before
"invokedynamic", // "invokedynamic", Java 7 and later
"new", // "new",
"newarray", // "newarray",
"anewarray", // "anewarray",
"arraylength", // "arraylength",
"athrow", // "athrow",
"checkcast", // "checkcast",
"instanceof", // "instanceof",
"monitorenter", // "monitorenter",
"monitorexit", // "monitorexit",
"wide", // "wide",
"multianewarray", // "multianewarray",
"ifnull", // "ifnull",
"ifnonnull", // "ifnonnull",
"goto_w", // "goto_w",
"jsr_w" // "jsr_w"
};
private static final Class[] opcodeClasses = {
null, // "nop",
null, // "aconst_null",
null, // "iconst_m1",
null, // "iconst_0",
null, // "iconst_1",
null, // "iconst_2",
null, // "iconst_3",
null, // "iconst_4",
null, // "iconst_5",
null, // "lconst_0",
null, // "lconst_1",
null, // "fconst_0",
null, // "fconst_1",
null, // "fconst_2",
null, // "dconst_0",
null, // "dconst_1",
BIPUSH.class, // "bipush",
SIPUSH.class, // "sipush",
LDC.class, // "ldc",
LDC_W.class, // "ldc_w",
LDC2_W.class, // "ldc2_w",
ILOAD.class, // "iload",
LLOAD.class, // "lload",
FLOAD.class, // "fload",
DLOAD.class, // "dload",
ALOAD.class, // "aload",
null, // "iload_0",
null, // "iload_1",
null, // "iload_2",
null, // "iload_3",
null, // "lload_0",
null, // "lload_1",
null, // "lload_2",
null, // "lload_3",
null, // "fload_0",
null, // "fload_1",
null, // "fload_2",
null, // "fload_3",
null, // "dload_0",
null, // "dload_1",
null, // "dload_2",
null, // "dload_3",
null, // "aload_0",
null, // "aload_1",
null, // "aload_2",
null, // "aload_3",
null, // "iaload",
null, // "laload",
null, // "faload",
null, // "daload",
null, // "aaload",
null, // "baload",
null, // "caload",
null, // "saload",
ISTORE.class, // "istore",
LSTORE.class, // "lstore",
FSTORE.class, // "fstore",
DSTORE.class, // "dstore",
ASTORE.class, // "astore",
null, // "istore_0",
null, // "istore_1",
null, // "istore_2",
null, // "istore_3",
null, // "lstore_0",
null, // "lstore_1",
null, // "lstore_2",
null, // "lstore_3",
null, // "fstore_0",
null, // "fstore_1",
null, // "fstore_2",
null, // "fstore_3",
null, // "dstore_0",
null, // "dstore_1",
null, // "dstore_2",
null, // "dstore_3",
null, // "astore_0",
null, // "astore_1",
null, // "astore_2",
null, // "astore_3",
null, // "iastore",
null, // "lastore",
null, // "fastore",
null, // "dastore",
null, // "aastore",
null, // "bastore",
null, // "castore",
null, // "sastore",
null, // "pop",
null, // "pop2",
null, // "dup",
null, // "dup_x1",
null, // "dup_x2",
null, // "dup2",
null, // "dup2_x1",
null, // "dup2_x2",
null, // "swap",
null, // "iadd",
null, // "ladd",
null, // "fadd",
null, // "dadd",
null, // "isub",
null, // "lsub",
null, // "fsub",
null, // "dsub",
null, // "imul",
null, // "lmul",
null, // "fmul",
null, // "dmul",
null, // "idiv",
null, // "ldiv",
null, // "fdiv",
null, // "ddiv",
null, // "irem",
null, // "lrem",
null, // "frem",
null, // "drem",
null, // "ineg",
null, // "lneg",
null, // "fneg",
null, // "dneg",
null, // "ishl",
null, // "lshl",
null, // "ishr",
null, // "lshr",
null, // "iushr",
null, // "lushr",
null, // "iand",
null, // "land",
null, // "ior",
null, // "lor",
null, // "ixor",
null, // "lxor",
IINC.class, // "iinc",
null, // "i2l",
null, // "i2f",
null, // "i2d",
null, // "l2i",
null, // "l2f",
null, // "l2d",
null, // "f2i",
null, // "f2l",
null, // "f2d",
null, // "d2i",
null, // "d2l",
null, // "d2f",
null, // "i2b",
null, // "i2c",
null, // "i2s",
null, // "lcmp",
null, // "fcmpl",
null, // "fcmpg",
null, // "dcmpl",
null, // "dcmpg",
null, // "ifeq",
null, // "ifne",
null, // "iflt",
null, // "ifge",
null, // "ifgt",
null, // "ifle",
null, // "if_icmpeq",
null, // "if_icmpne",
null, // "if_icmplt",
null, // "if_icmpge",
null, // "if_icmpgt",
null, // "if_icmple",
null, // "if_acmpeq",
null, // "if_acmpne",
GOTO.class, // "goto",
JSR.class, // "jsr",
RET.class, // "ret",
TABLESWITCH.class, // "tableswitch",
LOOKUPSWITCH.class, // "lookupswitch",
null, // "ireturn",
null, // "lreturn",
null, // "freturn",
null, // "dreturn",
null, // "areturn",
null, // "return",
GETSTATIC.class, // "getstatic",
PUTSTATIC.class, // "putstatic",
GETFIELD.class, // "getfield",
PUTFIELD.class, // "putfield",
INVOKEVIRTUAL.class, // "invokevirtual",
INVOKESPECIAL.class, // "invokespecial",
INVOKESTATIC.class, // "invokestatic",
INVOKEINTERFACE.class, // "invokeinterface",
INVOKEDYNAMIC.class, // "xxxunusedxxx" Java 6 and before, "invokedynamic" Java 7 and later
NEW.class, // "new",
NEWARRAY.class, // "newarray",
ANEWARRAY.class, // "anewarray",
null, // "arraylength",
null, // "athrow",
CHECKCAST.class, // "checkcast",
INSTANCEOF.class, // "instanceof",
null, // "monitorenter",
null, // "monitorexit",
null, // "wide",
MULTIANEWARRAY.class, // "multianewarray",
null, // "ifnull",
null, // "ifnonnull",
GOTO_W.class, // "goto_w",
JSR_W.class // "jsr_w"
};
}

View File

@@ -3,11 +3,7 @@ package org.jetbrains.java.decompiler.code;
import org.jetbrains.java.decompiler.main.DecompilerContext;
import java.io.DataOutputStream;
import java.io.IOException;
public class ExceptionHandler {
public int from = 0;
public int to = 0;
public int handler = 0;
@@ -16,32 +12,12 @@ public class ExceptionHandler {
public int to_instr = 0;
public int handler_instr = 0;
public int class_index = 0;
public String exceptionClass = null;
public ExceptionHandler() {
}
public ExceptionHandler(int from_raw, int to_raw, int handler_raw, String exceptionClass) {
this.from = from_raw;
this.to = to_raw;
this.handler = handler_raw;
this.exceptionClass = exceptionClass;
}
public void writeToStream(DataOutputStream out) throws IOException {
out.writeShort(from);
out.writeShort(to);
out.writeShort(handler);
out.writeShort(class_index);
}
public String toString() {
String new_line_separator = DecompilerContext.getNewLineSeparator();
return "from: " + from + " to: " + to + " handler: " + handler + new_line_separator +
"from_instr: " + from_instr + " to_instr: " + to_instr + " handler_instr: " + handler_instr + new_line_separator +
"exceptionClass: " + exceptionClass + new_line_separator;
}
}
}

View File

@@ -1,19 +1,11 @@
// 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.code.interpreter.Util;
import org.jetbrains.java.decompiler.struct.StructContext;
import java.util.Collections;
import java.util.List;
public class ExceptionTable {
public static final ExceptionTable EMPTY = new ExceptionTable(null) {
@Override
public List<ExceptionHandler> getHandlers() {
return Collections.emptyList();
}
};
public static final ExceptionTable EMPTY = new ExceptionTable(Collections.emptyList());
private final List<ExceptionHandler> handlers;
@@ -21,27 +13,7 @@ public class ExceptionTable {
this.handlers = handlers;
}
public ExceptionHandler getHandlerByClass(StructContext context, int line, String valclass, boolean withany) {
ExceptionHandler res = null; // no handler found
for (ExceptionHandler handler : handlers) {
if (handler.from <= line && handler.to > line) {
String name = handler.exceptionClass;
if ((withany && name == null) || // any -> finally or synchronized handler
(name != null && Util.instanceOf(context, valclass, name))) {
res = handler;
break;
}
}
}
return res;
}
public List<ExceptionHandler> getHandlers() {
return handlers;
}
}
}

View File

@@ -1,22 +0,0 @@
// 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 java.io.DataOutputStream;
import java.io.IOException;
/*
* opc_ifeq, opc_ifne, opc_iflt, opc_ifge, opc_ifgt, opc_ifle, opc_if_icmpeq, opc_if_icmpne, opc_if_icmplt,
* opc_if_icmpge, opc_if_icmpgt, opc_if_icmple, opc_if_acmpeq, opc_if_acmpne, opc_ifnull, opc_ifnonnull
*/
public class IfInstruction extends JumpInstruction {
public void writeToStream(DataOutputStream out, int offset) throws IOException {
out.writeByte(opcode);
out.writeShort(getOperand(0));
}
public int length() {
return 3;
}
}

View File

@@ -1,112 +1,65 @@
// 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 java.io.DataOutputStream;
import java.io.IOException;
public class Instruction implements CodeConstants {
// *****************************************************************************
// public fields
// *****************************************************************************
public int opcode;
public int group = CodeConstants.GROUP_GENERAL;
public boolean wide = false;
public int bytecode_version = BYTECODE_JAVA_LE_4;
// *****************************************************************************
// private fields
// *****************************************************************************
private int[] operands = null;
// *****************************************************************************
// public methods
// *****************************************************************************
public Instruction() {
public static Instruction create(int opcode, boolean wide, int group, int bytecodeVersion, int[] operands) {
if (opcode >= opc_ifeq && opcode <= opc_if_acmpne ||
opcode == opc_ifnull || opcode == opc_ifnonnull ||
opcode == opc_jsr || opcode == opc_jsr_w ||
opcode == opc_goto || opcode == opc_goto_w) {
return new JumpInstruction(opcode, group, wide, bytecodeVersion, operands);
}
else if (opcode == opc_tableswitch || opcode == opc_lookupswitch) {
return new SwitchInstruction(opcode, group, wide, bytecodeVersion, operands);
}
else {
return new Instruction(opcode, group, wide, bytecodeVersion, operands);
}
}
public int length() {
return 1;
public static boolean equals(Instruction i1, Instruction i2) {
return i1 != null && i2 != null &&
(i1 == i2 ||
i1.opcode == i2.opcode &&
i1.wide == i2.wide &&
i1.operandsCount() == i2.operandsCount());
}
public final int opcode;
public final int group;
public final boolean wide;
public final int bytecodeVersion;
protected final int[] operands;
public Instruction(int opcode, int group, boolean wide, int bytecodeVersion, int[] operands) {
this.opcode = opcode;
this.group = group;
this.wide = wide;
this.bytecodeVersion = bytecodeVersion;
this.operands = operands;
}
public void initInstruction(InstructionSequence seq) { }
public int operandsCount() {
return (operands == null) ? 0 : operands.length;
return operands == null ? 0 : operands.length;
}
public int getOperand(int index) {
public int operand(int index) {
return operands[index];
}
public Instruction clone() {
return ConstantsUtil.getInstructionInstance(opcode, wide, group, bytecode_version, operands == null ? null : operands.clone());
}
public String toString() {
String res = wide ? "@wide " : "";
res += "@" + ConstantsUtil.getName(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;
}
public boolean canFallthrough() {
public boolean canFallThrough() {
return opcode != opc_goto && opcode != opc_goto_w && opcode != opc_ret &&
!(opcode >= opc_ireturn && opcode <= opc_return) && opcode != opc_athrow
&& opcode != opc_jsr && opcode != opc_tableswitch && opcode != opc_lookupswitch;
!(opcode >= opc_ireturn && opcode <= opc_return) &&
opcode != opc_athrow &&
opcode != opc_jsr && opcode != opc_tableswitch && opcode != opc_lookupswitch;
}
public boolean equalsInstruction(Instruction instr) {
if (opcode != instr.opcode || wide != instr.wide
|| operandsCount() != instr.operandsCount()) {
return false;
}
if (operands != null) {
for (int i = 0; i < operands.length; i++) {
if (operands[i] != instr.getOperand(i)) {
return false;
}
}
}
return true;
@Override
@SuppressWarnings("MethodDoesntCallSuperMethod")
public Instruction clone() {
return create(opcode, wide, group, bytecodeVersion, operands == null ? null : operands.clone());
}
// should be overwritten by subclasses
public void initInstruction(InstructionSequence seq) {
}
// should be overwritten by subclasses
public void writeToStream(DataOutputStream out, int offset) throws IOException {
out.writeByte(opcode);
}
// *****************************************************************************
// getter and setter methods
// *****************************************************************************
public int[] getOperands() {
return operands;
}
public void setOperands(int[] operands) {
this.operands = operands;
}
}
}

View File

@@ -1,19 +1,10 @@
// 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.code.interpreter.Util;
import org.jetbrains.java.decompiler.main.DecompilerContext;
import org.jetbrains.java.decompiler.struct.StructContext;
import org.jetbrains.java.decompiler.util.TextUtil;
import org.jetbrains.java.decompiler.util.VBStyleCollection;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
public abstract class InstructionSequence {
// *****************************************************************************
@@ -73,10 +64,6 @@ public abstract class InstructionSequence {
}
}
public Instruction getCurrentInstr() {
return collinstr.get(pointer);
}
public Instruction getInstr(int index) {
return collinstr.get(index);
}
@@ -85,16 +72,12 @@ public abstract class InstructionSequence {
return collinstr.getLast();
}
public int getCurrentOffset() {
return collinstr.getKey(pointer).intValue();
}
public int getOffset(int index) {
return collinstr.getKey(index).intValue();
public int getOffset(int index) {
return collinstr.getKey(index);
}
public int getPointerByAbsOffset(int offset) {
Integer absoffset = new Integer(offset);
Integer absoffset = offset;
if (collinstr.containsKey(absoffset)) {
return collinstr.getIndexByKey(absoffset);
}
@@ -104,7 +87,7 @@ public int getOffset(int index) {
}
public int getPointerByRelOffset(int offset) {
Integer absoffset = new Integer(collinstr.getKey(pointer).intValue() + offset);
Integer absoffset = collinstr.getKey(pointer) + offset;
if (collinstr.containsKey(absoffset)) {
return collinstr.getIndexByKey(absoffset);
}
@@ -113,13 +96,6 @@ public int getOffset(int index) {
}
}
public void setPointerByAbsOffset(int offset) {
Integer absoffset = new Integer(collinstr.getKey(pointer).intValue() + offset);
if (collinstr.containsKey(absoffset)) {
pointer = collinstr.getIndexByKey(absoffset);
}
}
public int length() {
return collinstr.size();
}
@@ -153,55 +129,6 @@ public int getOffset(int index) {
return buf.toString();
}
public void writeCodeToStream(DataOutputStream out) throws IOException {
for (int i = 0; i < collinstr.size(); i++) {
collinstr.get(i).writeToStream(out, collinstr.getKey(i).intValue());
}
}
public void writeExceptionsToStream(DataOutputStream out) throws IOException {
List<ExceptionHandler> handlers = exceptionTable.getHandlers();
out.writeShort(handlers.size());
for (int i = 0; i < handlers.size(); i++) {
handlers.get(i).writeToStream(out);
}
}
public void sortHandlers(final StructContext context) {
Collections.sort(exceptionTable.getHandlers(), (handler0, handler1) -> {
if (handler0.to == handler1.to) {
if (handler0.exceptionClass == null) {
return 1;
}
else {
if (handler1.exceptionClass == null) {
return -1;
}
else if (handler0.exceptionClass.equals(handler1.exceptionClass)) {
return (handler0.from > handler1.from) ? -1 : 1; // invalid code
}
else {
if (Util.instanceOf(context, handler0.exceptionClass, handler1.exceptionClass)) {
return -1;
}
else {
return 1;
}
}
}
}
else {
return (handler0.to > handler1.to) ? 1 : -1;
}
});
}
// *****************************************************************************
// getter and setter methods
// *****************************************************************************
@@ -217,8 +144,4 @@ public int getOffset(int index) {
public ExceptionTable getExceptionTable() {
return exceptionTable;
}
public void setExceptionTable(ExceptionTable exceptionTable) {
this.exceptionTable = exceptionTable;
}
}
}

View File

@@ -1,28 +1,22 @@
// 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;
/*
* opc_ifeq, opc_ifne, opc_iflt, opc_ifge, opc_ifgt, opc_ifle, opc_if_icmpeq, opc_if_icmpne, opc_if_icmplt,
* opc_if_icmpge, opc_if_icmpgt, opc_if_icmple, opc_if_acmpeq, opc_if_acmpne, opc_ifnull, opc_ifnonnull
* opc_goto, opc_jsr, opc_goto_w, opc_jsr_w
*/
public class JumpInstruction extends Instruction {
public int destination;
public JumpInstruction() {
public JumpInstruction(int opcode, int group, boolean wide, int bytecodeVersion, int[] operands) {
super(opcode, group, wide, bytecodeVersion, operands);
}
@Override
public void initInstruction(InstructionSequence seq) {
destination = seq.getPointerByRelOffset(this.getOperand(0));
destination = seq.getPointerByRelOffset(this.operand(0));
}
@Override
public JumpInstruction clone() {
JumpInstruction newinstr = (JumpInstruction)super.clone();
newinstr.destination = destination;
return newinstr;
JumpInstruction copy = (JumpInstruction)super.clone();
copy.destination = destination;
return copy;
}
}
}

View File

@@ -1,83 +1,61 @@
// 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;
/*
* opc_tableswitch, lookupswitch
*/
public class SwitchInstruction extends Instruction {
private int[] destinations;
private int[] values;
private int defaultDestination;
private int defaultdest;
public SwitchInstruction() {
public SwitchInstruction(int opcode, int group, boolean wide, int bytecodeVersion, int[] operands) {
super(opcode, group, wide, bytecodeVersion, operands);
}
@Override
public void initInstruction(InstructionSequence seq) {
defaultDestination = seq.getPointerByRelOffset(operands[0]);
int pref = (opcode == CodeConstants.opc_tableswitch ? 3 : 2);
int len = this.getOperands().length - pref;
defaultdest = seq.getPointerByRelOffset(this.getOperand(0));
int prefix = opcode == CodeConstants.opc_tableswitch ? 3 : 2;
int len = operands.length - prefix;
int low = 0;
if (opcode == CodeConstants.opc_lookupswitch) {
len /= 2;
}
else {
low = this.getOperand(1);
low = operands[1];
}
destinations = new int[len];
values = new int[len];
for (int i = 0, k = 0; i < len; i++, k++) {
if (opcode == CodeConstants.opc_lookupswitch) {
values[i] = this.getOperand(pref + k);
values[i] = operands[prefix + k];
k++;
}
else {
values[i] = low + k;
}
destinations[i] = seq.getPointerByRelOffset(this.getOperand(pref + k));
destinations[i] = seq.getPointerByRelOffset(operands[prefix + k]);
}
}
public SwitchInstruction clone() {
SwitchInstruction newinstr = (SwitchInstruction)super.clone();
newinstr.defaultdest = defaultdest;
newinstr.destinations = destinations.clone();
newinstr.values = values.clone();
return newinstr;
}
public int[] getDestinations() {
return destinations;
}
public void setDestinations(int[] destinations) {
this.destinations = destinations;
}
public int getDefaultdest() {
return defaultdest;
}
public void setDefaultdest(int defaultdest) {
this.defaultdest = defaultdest;
}
public int[] getValues() {
return values;
}
public void setValues(int[] values) {
this.values = values;
public int getDefaultDestination() {
return defaultDestination;
}
}
@Override
public SwitchInstruction clone() {
SwitchInstruction copy = (SwitchInstruction)super.clone();
copy.defaultDestination = defaultDestination;
copy.destinations = destinations.clone();
copy.values = values.clone();
return copy;
}
}

View File

@@ -16,8 +16,7 @@ public class BasicBlock implements IGraphNode {
// public fields
// *****************************************************************************
public int id = 0;
public int id;
public int mark = 0;
// *****************************************************************************
@@ -26,15 +25,11 @@ public class BasicBlock implements IGraphNode {
private InstructionSequence seq = new SimpleInstructionSequence();
private List<BasicBlock> preds = new ArrayList<>();
private List<BasicBlock> succs = new ArrayList<>();
private final List<BasicBlock> preds = new ArrayList<>();
private final List<BasicBlock> succs = new ArrayList<>();
private final List<Integer> instrOldOffsets = new ArrayList<>();
private List<BasicBlock> predExceptions = new ArrayList<>();
private List<BasicBlock> succExceptions = new ArrayList<>();
private final List<BasicBlock> predExceptions = new ArrayList<>();
private final List<BasicBlock> succExceptions = new ArrayList<>();
public BasicBlock(int id) {
this.id = id;
@@ -44,7 +39,9 @@ public class BasicBlock implements IGraphNode {
// public methods
// *****************************************************************************
public Object clone() {
@Override
@SuppressWarnings("MethodDoesntCallSuperMethod")
public BasicBlock clone() {
BasicBlock block = new BasicBlock(id);
block.setSeq(seq.clone());
@@ -53,14 +50,6 @@ public class BasicBlock implements IGraphNode {
return block;
}
public void free() {
preds.clear();
succs.clear();
instrOldOffsets.clear();
succExceptions.clear();
seq = new SimpleInstructionSequence();
}
public Instruction getInstruction(int index) {
return seq.getInstr(index);
}
@@ -91,7 +80,7 @@ public class BasicBlock implements IGraphNode {
}
public void removePredecessor(BasicBlock block) {
while (preds.remove(block)) ;
while (preds.remove(block)) /**/;
}
public void addSuccessor(BasicBlock block) {
@@ -100,7 +89,7 @@ public class BasicBlock implements IGraphNode {
}
public void removeSuccessor(BasicBlock block) {
while (succs.remove(block)) ;
while (succs.remove(block)) /**/;
block.removePredecessor(this);
}
@@ -128,7 +117,7 @@ public class BasicBlock implements IGraphNode {
}
public void removePredecessorException(BasicBlock block) {
while (predExceptions.remove(block)) ;
while (predExceptions.remove(block)) /**/;
}
public void addSuccessorException(BasicBlock block) {
@@ -139,7 +128,7 @@ public class BasicBlock implements IGraphNode {
}
public void removeSuccessorException(BasicBlock block) {
while (succExceptions.remove(block)) ;
while (succExceptions.remove(block)) /**/;
block.removePredecessorException(this);
}
@@ -154,27 +143,6 @@ public class BasicBlock implements IGraphNode {
return id + ":" + new_line_separator + seq.toString(indent);
}
public String toStringOldIndices() {
String new_line_separator = DecompilerContext.getNewLineSeparator();
StringBuilder buf = new StringBuilder();
for (int i = 0; i < seq.length(); i++) {
if (i < instrOldOffsets.size()) {
buf.append(instrOldOffsets.get(i));
}
else {
buf.append("-1");
}
buf.append(": ");
buf.append(seq.getInstr(i).toString());
buf.append(new_line_separator);
}
return buf.toString();
}
public boolean isSuccessor(BasicBlock block) {
for (BasicBlock succ : succs) {
if (succ.id == block.id) {
@@ -184,15 +152,6 @@ public class BasicBlock implements IGraphNode {
return false;
}
public boolean isPredecessor(BasicBlock block) {
for (int i = 0; i < preds.size(); i++) {
if (preds.get(i).id == block.id) {
return true;
}
}
return false;
}
// *****************************************************************************
// getter and setter methods
// *****************************************************************************
@@ -211,10 +170,6 @@ public class BasicBlock implements IGraphNode {
return preds;
}
public void setPreds(List<BasicBlock> preds) {
this.preds = preds;
}
public InstructionSequence getSeq() {
return seq;
}
@@ -227,25 +182,11 @@ public class BasicBlock implements IGraphNode {
return succs;
}
public void setSuccs(List<BasicBlock> succs) {
this.succs = succs;
}
public List<BasicBlock> getSuccExceptions() {
return succExceptions;
}
public void setSuccExceptions(List<BasicBlock> succExceptions) {
this.succExceptions = succExceptions;
}
public List<BasicBlock> getPredExceptions() {
return predExceptions;
}
public void setPredExceptions(List<BasicBlock> predExceptions) {
this.predExceptions = predExceptions;
}
}
}

View File

@@ -33,7 +33,7 @@ public class ControlFlowGraph implements CodeConstants {
private Map<BasicBlock, BasicBlock> subroutines;
private Set<BasicBlock> finallyExits = new HashSet<>();
private final Set<BasicBlock> finallyExits = new HashSet<>();
// *****************************************************************************
// constructors
@@ -48,19 +48,6 @@ public class ControlFlowGraph implements CodeConstants {
// public methods
// *****************************************************************************
public void free() {
for (BasicBlock block : blocks) {
block.free();
}
blocks.clear();
first = null;
last = null;
exceptions.clear();
finallyExits.clear();
}
public void removeMarkers() {
for (BasicBlock block : blocks) {
block.mark = 0;
@@ -80,12 +67,11 @@ public class ControlFlowGraph implements CodeConstants {
buf.append("----- Edges -----").append(new_line_separator);
List<BasicBlock> suc = block.getSuccs();
for (int j = 0; j < suc.size(); j++) {
buf.append(">>>>>>>>(regular) Block ").append(suc.get(j).id).append(new_line_separator);
for (BasicBlock aSuc : suc) {
buf.append(">>>>>>>>(regular) Block ").append(aSuc.id).append(new_line_separator);
}
suc = block.getSuccExceptions();
for (int j = 0; j < suc.size(); j++) {
BasicBlock handler = suc.get(j);
for (BasicBlock handler : suc) {
ExceptionRangeCFG range = getExceptionRange(handler, block);
if (range == null) {
@@ -156,13 +142,7 @@ public class ControlFlowGraph implements CodeConstants {
}
}
Iterator<Entry<BasicBlock, BasicBlock>> it = subroutines.entrySet().iterator();
while (it.hasNext()) {
Entry<BasicBlock, BasicBlock> ent = it.next();
if (ent.getKey() == block || ent.getValue() == block) {
it.remove();
}
}
subroutines.entrySet().removeIf(ent -> ent.getKey() == block || ent.getValue() == block);
}
public ExceptionRangeCFG getExceptionRange(BasicBlock handler, BasicBlock block) {
@@ -261,7 +241,7 @@ public class ControlFlowGraph implements CodeConstants {
for (int j = dests.length - 1; j >= 0; j--) {
inststates[dests[j]] = 1;
}
inststates[swinstr.getDefaultdest()] = 1;
inststates[swinstr.getDefaultDestination()] = 1;
if (i + 1 < len) {
inststates[i + 1] = 1;
}
@@ -322,7 +302,7 @@ public class ControlFlowGraph implements CodeConstants {
BasicBlock block = lstbb.get(i);
Instruction instr = block.getLastInstruction();
boolean fallthrough = instr.canFallthrough();
boolean fallthrough = instr.canFallThrough();
BasicBlock bTemp;
switch (instr.group) {
@@ -336,10 +316,10 @@ public class ControlFlowGraph implements CodeConstants {
SwitchInstruction sinstr = (SwitchInstruction)instr;
int[] dests = sinstr.getDestinations();
bTemp = mapInstrBlocks.get(((SwitchInstruction)instr).getDefaultdest());
bTemp = mapInstrBlocks.get(((SwitchInstruction)instr).getDefaultDestination());
block.addSuccessor(bTemp);
for (int j = 0; j < dests.length; j++) {
bTemp = mapInstrBlocks.get(dests[j]);
for (int dest1 : dests) {
bTemp = mapInstrBlocks.get(dest1);
block.addSuccessor(bTemp);
}
}
@@ -617,9 +597,8 @@ public class ControlFlowGraph implements CodeConstants {
node.replaceSuccessor(child, mapNewNodes.get(childid));
}
else if (common_blocks.contains(child)) {
// make a copy of the current block
BasicBlock copy = (BasicBlock)child.clone();
BasicBlock copy = child.clone();
copy.id = ++last_id;
// copy all successors
if (copy.getLastInstruction().opcode == CodeConstants.opc_ret &&
@@ -816,10 +795,6 @@ public class ControlFlowGraph implements CodeConstants {
return blocks;
}
public void setBlocks(VBStyleCollection<BasicBlock, Integer> blocks) {
this.blocks = blocks;
}
public BasicBlock getFirst() {
return first;
}
@@ -828,39 +803,15 @@ public class ControlFlowGraph implements CodeConstants {
this.first = first;
}
public List<BasicBlock> getEndBlocks() {
return last.getPreds();
}
public List<ExceptionRangeCFG> getExceptions() {
return exceptions;
}
public void setExceptions(List<ExceptionRangeCFG> exceptions) {
this.exceptions = exceptions;
}
public BasicBlock getLast() {
return last;
}
public void setLast(BasicBlock last) {
this.last = last;
}
public Map<BasicBlock, BasicBlock> getSubroutines() {
return subroutines;
}
public void setSubroutines(Map<BasicBlock, BasicBlock> subroutines) {
this.subroutines = subroutines;
}
public Set<BasicBlock> getFinallyExits() {
return finallyExits;
}
public void setFinallyExits(HashSet<BasicBlock> finallyExits) {
this.finallyExits = finallyExits;
}
}
}

View File

@@ -1,18 +1,13 @@
// 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.cfg;
import org.jetbrains.java.decompiler.main.DecompilerContext;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
public class ExceptionRangeCFG {
private List<BasicBlock> protectedRange = new ArrayList<>(); // FIXME: replace with set
private final List<BasicBlock> protectedRange; // FIXME: replace with set
private BasicBlock handler;
private List<String> exceptionTypes;
public ExceptionRangeCFG(List<BasicBlock> protectedRange, BasicBlock handler, List<String> exceptionType) {
@@ -28,28 +23,6 @@ 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;
}
@@ -62,16 +35,11 @@ public class ExceptionRangeCFG {
return protectedRange;
}
public void setProtectedRange(List<BasicBlock> protectedRange) {
this.protectedRange = protectedRange;
}
public List<String> getExceptionTypes() {
return this.exceptionTypes;
}
public void addExceptionType(String exceptionType) {
if (this.exceptionTypes == null) {
return;
}
@@ -85,16 +53,6 @@ public class ExceptionRangeCFG {
}
public String getUniqueExceptionsString() {
if (exceptionTypes == null) {
return null;
}
return exceptionTypes.stream().distinct().collect(Collectors.joining(":"));
return exceptionTypes != null ? exceptionTypes.stream().distinct().collect(Collectors.joining(":")) : null;
}
// public void setExceptionType(String exceptionType) {
// this.exceptionType = exceptionType;
// }
}
}

View File

@@ -325,7 +325,6 @@ public class InstructionImpact {
public static void stepTypes(DataPoint data, Instruction instr, ConstantPool pool) {
ListStack<VarType> stack = data.getStack();
int[][] arr = stack_impact[instr.opcode];
@@ -337,8 +336,7 @@ public class InstructionImpact {
if (read != null) {
int depth = 0;
for (int i = 0; i < read.length; i++) {
int type = read[i];
for (int type : read) {
depth++;
if (type == CodeConstants.TYPE_LONG ||
type == CodeConstants.TYPE_DOUBLE) {
@@ -350,8 +348,7 @@ public class InstructionImpact {
}
if (write != null) {
for (int i = 0; i < write.length; i++) {
int type = write[i];
for (int type : write) {
stack.push(new VarType(type));
if (type == CodeConstants.TYPE_LONG ||
type == CodeConstants.TYPE_DOUBLE) {
@@ -381,7 +378,7 @@ public class InstructionImpact {
case CodeConstants.opc_ldc:
case CodeConstants.opc_ldc_w:
case CodeConstants.opc_ldc2_w:
PooledConstant constant = pool.getConstant(instr.getOperand(0));
PooledConstant constant = pool.getConstant(instr.operand(0));
switch (constant.type) {
case CodeConstants.CONSTANT_Integer:
stack.push(new VarType(CodeConstants.TYPE_INT));
@@ -409,7 +406,7 @@ public class InstructionImpact {
}
break;
case CodeConstants.opc_aload:
var1 = data.getVariable(instr.getOperand(0));
var1 = data.getVariable(instr.operand(0));
if (var1 != null) {
stack.push(var1);
}
@@ -422,7 +419,7 @@ public class InstructionImpact {
stack.push(new VarType(var1.type, var1.arrayDim - 1, var1.value));
break;
case CodeConstants.opc_astore:
data.setVariable(instr.getOperand(0), stack.pop());
data.setVariable(instr.operand(0), stack.pop());
break;
case CodeConstants.opc_dup:
case CodeConstants.opc_dup_x1:
@@ -444,7 +441,7 @@ public class InstructionImpact {
case CodeConstants.opc_getfield:
stack.pop();
case CodeConstants.opc_getstatic:
ck = pool.getLinkConstant(instr.getOperand(0));
ck = pool.getLinkConstant(instr.operand(0));
var1 = new VarType(ck.descriptor);
stack.push(var1);
if (var1.stackSize == 2) {
@@ -454,7 +451,7 @@ public class InstructionImpact {
case CodeConstants.opc_putfield:
stack.pop();
case CodeConstants.opc_putstatic:
ck = pool.getLinkConstant(instr.getOperand(0));
ck = pool.getLinkConstant(instr.operand(0));
var1 = new VarType(ck.descriptor);
stack.pop(var1.stackSize);
break;
@@ -464,8 +461,8 @@ public class InstructionImpact {
stack.pop();
case CodeConstants.opc_invokestatic:
case CodeConstants.opc_invokedynamic:
if (instr.opcode != CodeConstants.opc_invokedynamic || instr.bytecode_version >= CodeConstants.BYTECODE_JAVA_7) {
ck = pool.getLinkConstant(instr.getOperand(0));
if (instr.opcode != CodeConstants.opc_invokedynamic || instr.bytecodeVersion >= CodeConstants.BYTECODE_JAVA_7) {
ck = pool.getLinkConstant(instr.operand(0));
MethodDescriptor md = MethodDescriptor.parseDescriptor(ck.descriptor);
for (int i = 0; i < md.params.length; i++) {
stack.pop(md.params[i].stackSize);
@@ -479,12 +476,12 @@ public class InstructionImpact {
}
break;
case CodeConstants.opc_new:
cn = pool.getPrimitiveConstant(instr.getOperand(0));
cn = pool.getPrimitiveConstant(instr.operand(0));
stack.push(new VarType(CodeConstants.TYPE_OBJECT, 0, cn.getString()));
break;
case CodeConstants.opc_newarray:
stack.pop();
stack.push(new VarType(arr_type[instr.getOperand(0) - 4], 1).resizeArrayDim(1));
stack.push(new VarType(arr_type[instr.operand(0) - 4], 1).resizeArrayDim(1));
break;
case CodeConstants.opc_athrow:
var1 = stack.pop();
@@ -494,14 +491,14 @@ public class InstructionImpact {
case CodeConstants.opc_checkcast:
case CodeConstants.opc_instanceof:
stack.pop();
cn = pool.getPrimitiveConstant(instr.getOperand(0));
cn = pool.getPrimitiveConstant(instr.operand(0));
stack.push(new VarType(CodeConstants.TYPE_OBJECT, 0, cn.getString()));
break;
case CodeConstants.opc_anewarray:
case CodeConstants.opc_multianewarray:
int dimensions = (instr.opcode == CodeConstants.opc_anewarray) ? 1 : instr.getOperand(1);
int dimensions = (instr.opcode == CodeConstants.opc_anewarray) ? 1 : instr.operand(1);
stack.pop(dimensions);
cn = pool.getPrimitiveConstant(instr.getOperand(0));
cn = pool.getPrimitiveConstant(instr.operand(0));
if (cn.isArray) {
var1 = new VarType(CodeConstants.TYPE_OBJECT, 0, cn.getString());
var1 = var1.resizeArrayDim(var1.arrayDim + dimensions);

View File

@@ -1,272 +0,0 @@
// 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.interpreter;
import org.jetbrains.java.decompiler.code.Instruction;
import org.jetbrains.java.decompiler.struct.StructClass;
import org.jetbrains.java.decompiler.struct.StructContext;
// FIXME: move to StructContext
public class Util {
private static final String[][] runtime_exceptions = {
null, // public final static int opc_nop = 0;
null, // public final static int opc_aconst_null = 1;
null, // public final static int opc_iconst_m1 = 2;
null, // public final static int opc_iconst_0 = 3;
null, // public final static int opc_iconst_1 = 4;
null, // public final static int opc_iconst_2 = 5;
null, // public final static int opc_iconst_3 = 6;
null, // public final static int opc_iconst_4 = 7;
null, // public final static int opc_iconst_5 = 8;
null, // public final static int opc_lconst_0 = 9;
null, // public final static int opc_lconst_1 = 10;
null, // public final static int opc_fconst_0 = 11;
null, // public final static int opc_fconst_1 = 12;
null, // public final static int opc_fconst_2 = 13;
null, // public final static int opc_dconst_0 = 14;
null, // public final static int opc_dconst_1 = 15;
null, // public final static int opc_bipush = 16;
null, // public final static int opc_sipush = 17;
null, // public final static int opc_ldc = 18;
null, // public final static int opc_ldc_w = 19;
null, // public final static int opc_ldc2_w = 20;
null, // public final static int opc_iload = 21;
null, // public final static int opc_lload = 22;
null, // public final static int opc_fload = 23;
null, // public final static int opc_dload = 24;
null, // public final static int opc_aload = 25;
null, // public final static int opc_iload_0 = 26;
null, // public final static int opc_iload_1 = 27;
null, // public final static int opc_iload_2 = 28;
null, // public final static int opc_iload_3 = 29;
null, // public final static int opc_lload_0 = 30;
null, // public final static int opc_lload_1 = 31;
null, // public final static int opc_lload_2 = 32;
null, // public final static int opc_lload_3 = 33;
null, // public final static int opc_fload_0 = 34;
null, // public final static int opc_fload_1 = 35;
null, // public final static int opc_fload_2 = 36;
null, // public final static int opc_fload_3 = 37;
null, // public final static int opc_dload_0 = 38;
null, // public final static int opc_dload_1 = 39;
null, // public final static int opc_dload_2 = 40;
null, // public final static int opc_dload_3 = 41;
null, // public final static int opc_aload_0 = 42;
null, // public final static int opc_aload_1 = 43;
null, // public final static int opc_aload_2 = 44;
null, // public final static int opc_aload_3 = 45;
{"java/lang/NullPointerException", "java/lang/ArrayIndexOutOfBoundsException"},
// public final static int opc_iaload = 46;
{"java/lang/NullPointerException", "java/lang/ArrayIndexOutOfBoundsException"},
// public final static int opc_laload = 47;
{"java/lang/NullPointerException", "java/lang/ArrayIndexOutOfBoundsException"},
// public final static int opc_faload = 48;
{"java/lang/NullPointerException", "java/lang/ArrayIndexOutOfBoundsException"},
// public final static int opc_daload = 49;
{"java/lang/NullPointerException", "java/lang/ArrayIndexOutOfBoundsException"},
// public final static int opc_aaload = 50;
{"java/lang/NullPointerException", "java/lang/ArrayIndexOutOfBoundsException"},
// public final static int opc_baload = 51;
{"java/lang/NullPointerException", "java/lang/ArrayIndexOutOfBoundsException"},
// public final static int opc_caload = 52;
{"java/lang/NullPointerException", "java/lang/ArrayIndexOutOfBoundsException"},
// public final static int opc_saload = 53;
null, // public final static int opc_istore = 54;
null, // public final static int opc_lstore = 55;
null, // public final static int opc_fstore = 56;
null, // public final static int opc_dstore = 57;
null, // public final static int opc_astore = 58;
null, // public final static int opc_istore_0 = 59;
null, // public final static int opc_istore_1 = 60;
null, // public final static int opc_istore_2 = 61;
null, // public final static int opc_istore_3 = 62;
null, // public final static int opc_lstore_0 = 63;
null, // public final static int opc_lstore_1 = 64;
null, // public final static int opc_lstore_2 = 65;
null, // public final static int opc_lstore_3 = 66;
null, // public final static int opc_fstore_0 = 67;
null, // public final static int opc_fstore_1 = 68;
null, // public final static int opc_fstore_2 = 69;
null, // public final static int opc_fstore_3 = 70;
null, // public final static int opc_dstore_0 = 71;
null, // public final static int opc_dstore_1 = 72;
null, // public final static int opc_dstore_2 = 73;
null, // public final static int opc_dstore_3 = 74;
null, // public final static int opc_astore_0 = 75;
null, // public final static int opc_astore_1 = 76;
null, // public final static int opc_astore_2 = 77;
null, // public final static int opc_astore_3 = 78;
{"java/lang/NullPointerException", "java/lang/ArrayIndexOutOfBoundsException"},
// public final static int opc_iastore = 79;
{"java/lang/NullPointerException", "java/lang/ArrayIndexOutOfBoundsException"},
// public final static int opc_lastore = 80;
{"java/lang/NullPointerException", "java/lang/ArrayIndexOutOfBoundsException"},
// public final static int opc_fastore = 81;
{"java/lang/NullPointerException", "java/lang/ArrayIndexOutOfBoundsException"},
// public final static int opc_dastore = 82;
{"java/lang/NullPointerException", "java/lang/ArrayIndexOutOfBoundsException", "java/lang/ArrayStoreException"},
// public final static int opc_aastore = 83;
{"java/lang/NullPointerException", "java/lang/ArrayIndexOutOfBoundsException"},
// public final static int opc_bastore = 84;
{"java/lang/NullPointerException", "java/lang/ArrayIndexOutOfBoundsException"},
// public final static int opc_castore = 85;
{"java/lang/NullPointerException", "java/lang/ArrayIndexOutOfBoundsException"},
// public final static int opc_sastore = 86;
null, // public final static int opc_pop = 87;
null, // public final static int opc_pop2 = 88;
null, // public final static int opc_dup = 89;
null, // public final static int opc_dup_x1 = 90;
null, // public final static int opc_dup_x2 = 91;
null, // public final static int opc_dup2 = 92;
null, // public final static int opc_dup2_x1 = 93;
null, // public final static int opc_dup2_x2 = 94;
null, // public final static int opc_swap = 95;
null, // public final static int opc_iadd = 96;
null, // public final static int opc_ladd = 97;
null, // public final static int opc_fadd = 98;
null, // public final static int opc_dadd = 99;
null, // public final static int opc_isub = 100;
null, // public final static int opc_lsub = 101;
null, // public final static int opc_fsub = 102;
null, // public final static int opc_dsub = 103;
null, // public final static int opc_imul = 104;
null, // public final static int opc_lmul = 105;
null, // public final static int opc_fmul = 106;
null, // public final static int opc_dmul = 107;
{"java/lang/ArithmeticException"}, // public final static int opc_idiv = 108;
{"java/lang/ArithmeticException"}, // public final static int opc_ldiv = 109;
null, // public final static int opc_fdiv = 110;
null, // public final static int opc_ddiv = 111;
{"java/lang/ArithmeticException"}, // public final static int opc_irem = 112;
{"java/lang/ArithmeticException"}, // public final static int opc_lrem = 113;
null, // public final static int opc_frem = 114;
null, // public final static int opc_drem = 115;
null, // public final static int opc_ineg = 116;
null, // public final static int opc_lneg = 117;
null, // public final static int opc_fneg = 118;
null, // public final static int opc_dneg = 119;
null, // public final static int opc_ishl = 120;
null, // public final static int opc_lshl = 121;
null, // public final static int opc_ishr = 122;
null, // public final static int opc_lshr = 123;
null, // public final static int opc_iushr = 124;
null, // public final static int opc_lushr = 125;
null, // public final static int opc_iand = 126;
null, // public final static int opc_land = 127;
null, // public final static int opc_ior = 128;
null, // public final static int opc_lor = 129;
null, // public final static int opc_ixor = 130;
null, // public final static int opc_lxor = 131;
null, // public final static int opc_iinc = 132;
null, // public final static int opc_i2l = 133;
null, // public final static int opc_i2f = 134;
null, // public final static int opc_i2d = 135;
null, // public final static int opc_l2i = 136;
null, // public final static int opc_l2f = 137;
null, // public final static int opc_l2d = 138;
null, // public final static int opc_f2i = 139;
null, // public final static int opc_f2l = 140;
null, // public final static int opc_f2d = 141;
null, // public final static int opc_d2i = 142;
null, // public final static int opc_d2l = 143;
null, // public final static int opc_d2f = 144;
null, // public final static int opc_i2b = 145;
null, // public final static int opc_i2c = 146;
null, // public final static int opc_i2s = 147;
null, // public final static int opc_lcmp = 148;
null, // public final static int opc_fcmpl = 149;
null, // public final static int opc_fcmpg = 150;
null, // public final static int opc_dcmpl = 151;
null, // public final static int opc_dcmpg = 152;
null, // public final static int opc_ifeq = 153;
null, // public final static int opc_ifne = 154;
null, // public final static int opc_iflt = 155;
null, // public final static int opc_ifge = 156;
null, // public final static int opc_ifgt = 157;
null, // public final static int opc_ifle = 158;
null, // public final static int opc_if_icmpeq = 159;
null, // public final static int opc_if_icmpne = 160;
null, // public final static int opc_if_icmplt = 161;
null, // public final static int opc_if_icmpge = 162;
null, // public final static int opc_if_icmpgt = 163;
null, // public final static int opc_if_icmple = 164;
null, // public final static int opc_if_acmpeq = 165;
null, // public final static int opc_if_acmpne = 166;
null, // public final static int opc_goto = 167;
null, // public final static int opc_jsr = 168;
null, // public final static int opc_ret = 169;
null, // public final static int opc_tableswitch = 170;
null, // public final static int opc_lookupswitch = 171;
{"java/lang/IllegalMonitorStateException"}, // public final static int opc_ireturn = 172;
{"java/lang/IllegalMonitorStateException"}, // public final static int opc_lreturn = 173;
{"java/lang/IllegalMonitorStateException"}, // public final static int opc_freturn = 174;
{"java/lang/IllegalMonitorStateException"}, // public final static int opc_dreturn = 175;
{"java/lang/IllegalMonitorStateException"}, // public final static int opc_areturn = 176;
{"java/lang/IllegalMonitorStateException"}, // public final static int opc_return = 177;
null, // public final static int opc_getstatic = 178;
null, // public final static int opc_putstatic = 179;
{"java/lang/NullPointerException"}, // public final static int opc_getfield = 180;
{"java/lang/NullPointerException"}, // public final static int opc_putfield = 181;
{"java/lang/NullPointerException", "java/lang/AbstractMethodError", "java/lang/UnsatisfiedLinkError"},
// public final static int opc_invokevirtual = 182;
{"java/lang/NullPointerException", "java/lang/UnsatisfiedLinkError"},
// public final static int opc_invokespecial = 183;
{"java/lang/UnsatisfiedLinkError"}, // public final static int opc_invokestatic = 184;
{"java/lang/NullPointerException", "java/lang/IncompatibleClassChangeError", "java/lang/IllegalAccessError",
"java/lang/java/lang/AbstractMethodError", "java/lang/UnsatisfiedLinkError"},
// public final static int opc_invokeinterface = 185;
null, // public final static int opc_xxxunusedxxx = 186;
null, // public final static int opc_new = 187;
{"java/lang/NegativeArraySizeException"}, // public final static int opc_newarray = 188;
{"java/lang/NegativeArraySizeException"}, // public final static int opc_anewarray = 189;
{"java/lang/NullPointerException"}, // public final static int opc_arraylength = 190;
{"java/lang/NullPointerException", "java/lang/IllegalMonitorStateException"},
// public final static int opc_athrow = 191;
{"java/lang/ClassCastException"}, // public final static int opc_checkcast = 192;
null, // public final static int opc_instanceof = 193;
{"java/lang/NullPointerException"}, // public final static int opc_monitorenter = 194;
{"java/lang/NullPointerException", "java/lang/IllegalMonitorStateException"},
// public final static int opc_monitorexit = 195;
null, // public final static int opc_wide = 196;
{"java/lang/NegativeArraySizeException"}, // public final static int opc_multianewarray = 197;
null, // public final static int opc_ifnull = 198;
null, // public final static int opc_ifnonnull = 199;
null, // public final static int opc_goto_w = 200;
null, // public final static int opc_jsr_w = 201;
};
public static boolean instanceOf(StructContext context, String valclass, String refclass) {
if (valclass.equals(refclass)) {
return true;
}
StructClass cl = context.getClass(valclass);
if (cl == null) {
return false;
}
if (cl.superClass != null && instanceOf(context, cl.superClass.getString(), refclass)) {
return true;
}
int[] interfaces = cl.getInterfaces();
for (int i = 0; i < interfaces.length; i++) {
String intfc = cl.getPool().getPrimitiveConstant(interfaces[i]).getString();
if (instanceOf(context, intfc, refclass)) {
return true;
}
}
return false;
}
public static String[] getRuntimeExceptions(Instruction instr) {
return runtime_exceptions[instr.opcode];
}
}

View File

@@ -1,46 +0,0 @@
// 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.optinstructions;
import org.jetbrains.java.decompiler.code.Instruction;
import java.io.DataOutputStream;
import java.io.IOException;
public class ALOAD extends Instruction {
private static final int[] opcodes = new int[]{opc_aload_0, opc_aload_1, opc_aload_2, opc_aload_3};
public void writeToStream(DataOutputStream out, int offset) throws IOException {
int index = getOperand(0);
if (index > 3) {
if (wide) {
out.writeByte(opc_wide);
}
out.writeByte(opc_aload);
if (wide) {
out.writeShort(index);
}
else {
out.writeByte(index);
}
}
else {
out.writeByte(opcodes[index]);
}
}
public int length() {
int index = getOperand(0);
if (index > 3) {
if (wide) {
return 4;
}
else {
return 2;
}
}
else {
return 1;
}
}
}

View File

@@ -1,19 +0,0 @@
// 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.optinstructions;
import org.jetbrains.java.decompiler.code.Instruction;
import java.io.DataOutputStream;
import java.io.IOException;
public class ANEWARRAY extends Instruction {
public void writeToStream(DataOutputStream out, int offset) throws IOException {
out.writeByte(opc_anewarray);
out.writeShort(getOperand(0));
}
public int length() {
return 3;
}
}

View File

@@ -1,46 +0,0 @@
// 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.optinstructions;
import org.jetbrains.java.decompiler.code.Instruction;
import java.io.DataOutputStream;
import java.io.IOException;
public class ASTORE extends Instruction {
private static final int[] opcodes = new int[]{opc_astore_0, opc_astore_1, opc_astore_2, opc_astore_3};
public void writeToStream(DataOutputStream out, int offset) throws IOException {
int index = getOperand(0);
if (index > 3) {
if (wide) {
out.writeByte(opc_wide);
}
out.writeByte(opc_astore);
if (wide) {
out.writeShort(index);
}
else {
out.writeByte(index);
}
}
else {
out.writeByte(opcodes[index]);
}
}
public int length() {
int index = getOperand(0);
if (index > 3) {
if (wide) {
return 4;
}
else {
return 2;
}
}
else {
return 1;
}
}
}

View File

@@ -1,34 +0,0 @@
// 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.optinstructions;
import org.jetbrains.java.decompiler.code.Instruction;
import java.io.DataOutputStream;
import java.io.IOException;
public class BIPUSH extends Instruction {
private static final int[] opcodes =
new int[]{opc_iconst_m1, opc_iconst_0, opc_iconst_1, opc_iconst_2, opc_iconst_3, opc_iconst_4, opc_iconst_5};
public void writeToStream(DataOutputStream out, int offset) throws IOException {
int value = getOperand(0);
if (value < -1 || value > 5) {
out.writeByte(opc_bipush);
out.writeByte(value);
}
else {
out.writeByte(opcodes[value + 1]);
}
}
public int length() {
int value = getOperand(0);
if (value < -1 || value > 5) {
return 2;
}
else {
return 1;
}
}
}

View File

@@ -1,20 +0,0 @@
// 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.optinstructions;
import org.jetbrains.java.decompiler.code.Instruction;
import java.io.DataOutputStream;
import java.io.IOException;
public class CHECKCAST extends Instruction {
public void writeToStream(DataOutputStream out, int offset) throws IOException {
out.writeByte(opc_checkcast);
out.writeShort(getOperand(0));
}
public int length() {
return 3;
}
}

View File

@@ -1,46 +0,0 @@
// 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.optinstructions;
import org.jetbrains.java.decompiler.code.Instruction;
import java.io.DataOutputStream;
import java.io.IOException;
public class DLOAD extends Instruction {
private static final int[] opcodes = new int[]{opc_dload_0, opc_dload_1, opc_dload_2, opc_dload_3};
public void writeToStream(DataOutputStream out, int offset) throws IOException {
int index = getOperand(0);
if (index > 3) {
if (wide) {
out.writeByte(opc_wide);
}
out.writeByte(opc_dload);
if (wide) {
out.writeShort(index);
}
else {
out.writeByte(index);
}
}
else {
out.writeByte(opcodes[index]);
}
}
public int length() {
int index = getOperand(0);
if (index > 3) {
if (wide) {
return 4;
}
else {
return 2;
}
}
else {
return 1;
}
}
}

View File

@@ -1,46 +0,0 @@
// 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.optinstructions;
import org.jetbrains.java.decompiler.code.Instruction;
import java.io.DataOutputStream;
import java.io.IOException;
public class DSTORE extends Instruction {
private static final int[] opcodes = new int[]{opc_dstore_0, opc_dstore_1, opc_dstore_2, opc_dstore_3};
public void writeToStream(DataOutputStream out, int offset) throws IOException {
int index = getOperand(0);
if (index > 3) {
if (wide) {
out.writeByte(opc_wide);
}
out.writeByte(opc_dstore);
if (wide) {
out.writeShort(index);
}
else {
out.writeByte(index);
}
}
else {
out.writeByte(opcodes[index]);
}
}
public int length() {
int index = getOperand(0);
if (index > 3) {
if (wide) {
return 4;
}
else {
return 2;
}
}
else {
return 1;
}
}
}

View File

@@ -1,46 +0,0 @@
// 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.optinstructions;
import org.jetbrains.java.decompiler.code.Instruction;
import java.io.DataOutputStream;
import java.io.IOException;
public class FLOAD extends Instruction {
private static final int[] opcodes = new int[]{opc_fload_0, opc_fload_1, opc_fload_2, opc_fload_3};
public void writeToStream(DataOutputStream out, int offset) throws IOException {
int index = getOperand(0);
if (index > 3) {
if (wide) {
out.writeByte(opc_wide);
}
out.writeByte(opc_fload);
if (wide) {
out.writeShort(index);
}
else {
out.writeByte(index);
}
}
else {
out.writeByte(opcodes[index]);
}
}
public int length() {
int index = getOperand(0);
if (index > 3) {
if (wide) {
return 4;
}
else {
return 2;
}
}
else {
return 1;
}
}
}

View File

@@ -1,46 +0,0 @@
// 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.optinstructions;
import org.jetbrains.java.decompiler.code.Instruction;
import java.io.DataOutputStream;
import java.io.IOException;
public class FSTORE extends Instruction {
private static final int[] opcodes = new int[]{opc_fstore_0, opc_fstore_1, opc_fstore_2, opc_fstore_3};
public void writeToStream(DataOutputStream out, int offset) throws IOException {
int index = getOperand(0);
if (index > 3) {
if (wide) {
out.writeByte(opc_wide);
}
out.writeByte(opc_fstore);
if (wide) {
out.writeShort(index);
}
else {
out.writeByte(index);
}
}
else {
out.writeByte(opcodes[index]);
}
}
public int length() {
int index = getOperand(0);
if (index > 3) {
if (wide) {
return 4;
}
else {
return 2;
}
}
else {
return 1;
}
}
}

View File

@@ -1,19 +0,0 @@
// 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.optinstructions;
import org.jetbrains.java.decompiler.code.Instruction;
import java.io.DataOutputStream;
import java.io.IOException;
public class GETFIELD extends Instruction {
public void writeToStream(DataOutputStream out, int offset) throws IOException {
out.writeByte(opc_getfield);
out.writeShort(getOperand(0));
}
public int length() {
return 3;
}
}

View File

@@ -1,19 +0,0 @@
// 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.optinstructions;
import org.jetbrains.java.decompiler.code.Instruction;
import java.io.DataOutputStream;
import java.io.IOException;
public class GETSTATIC extends Instruction {
public void writeToStream(DataOutputStream out, int offset) throws IOException {
out.writeByte(opc_getstatic);
out.writeShort(getOperand(0));
}
public int length() {
return 3;
}
}

View File

@@ -1,32 +0,0 @@
// 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.optinstructions;
import org.jetbrains.java.decompiler.code.JumpInstruction;
import java.io.DataOutputStream;
import java.io.IOException;
public class GOTO extends JumpInstruction {
public void writeToStream(DataOutputStream out, int offset) throws IOException {
int operand = getOperand(0);
if (operand < -32768 || operand > 32767) {
out.writeByte(opc_goto_w);
out.writeInt(operand);
}
else {
out.writeByte(opc_goto);
out.writeShort(operand);
}
}
public int length() {
int operand = getOperand(0);
if (operand < -32768 || operand > 32767) {
return 5;
}
else {
return 3;
}
}
}

View File

@@ -1,19 +0,0 @@
// 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.optinstructions;
import org.jetbrains.java.decompiler.code.JumpInstruction;
import java.io.DataOutputStream;
import java.io.IOException;
public class GOTO_W extends JumpInstruction {
public void writeToStream(DataOutputStream out, int offset) throws IOException {
out.writeByte(opc_goto_w);
out.writeInt(getOperand(0));
}
public int length() {
return 5;
}
}

View File

@@ -1,29 +0,0 @@
// 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.optinstructions;
import org.jetbrains.java.decompiler.code.Instruction;
import java.io.DataOutputStream;
import java.io.IOException;
public class IINC extends Instruction {
public void writeToStream(DataOutputStream out, int offset) throws IOException {
if (wide) {
out.writeByte(opc_wide);
}
out.writeByte(opc_iinc);
if (wide) {
out.writeShort(getOperand(0));
out.writeShort(getOperand(1));
}
else {
out.writeByte(getOperand(0));
out.writeByte(getOperand(1));
}
}
public int length() {
return wide ? 6 : 3;
}
}

View File

@@ -1,41 +0,0 @@
// 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.optinstructions;
import org.jetbrains.java.decompiler.code.Instruction;
import java.io.DataOutputStream;
import java.io.IOException;
public class ILOAD extends Instruction {
private static final int[] opcodes = new int[]{opc_iload_0, opc_iload_1, opc_iload_2, opc_iload_3};
public void writeToStream(DataOutputStream out, int offset) throws IOException {
int index = getOperand(0);
if (index > 3) {
if (wide) {
out.writeByte(opc_wide);
}
out.writeByte(opc_iload);
if (wide) {
out.writeShort(index);
}
else {
out.writeByte(index);
}
}
else {
out.writeByte(opcodes[index]);
}
}
public int length() {
int index = getOperand(0);
if (index > 3) {
return wide ? 4 : 2;
}
else {
return 1;
}
}
}

View File

@@ -1,19 +0,0 @@
// 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.optinstructions;
import org.jetbrains.java.decompiler.code.Instruction;
import java.io.DataOutputStream;
import java.io.IOException;
public class INSTANCEOF extends Instruction {
public void writeToStream(DataOutputStream out, int offset) throws IOException {
out.writeByte(opc_instanceof);
out.writeShort(getOperand(0));
}
public int length() {
return 3;
}
}

View File

@@ -1,21 +0,0 @@
// 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.optinstructions;
import org.jetbrains.java.decompiler.code.Instruction;
import java.io.DataOutputStream;
import java.io.IOException;
public class INVOKEDYNAMIC extends Instruction {
public void writeToStream(DataOutputStream out, int offset) throws IOException {
out.writeByte(opc_invokedynamic);
out.writeShort(getOperand(0));
out.writeByte(0);
out.writeByte(0);
}
public int length() {
return 5;
}
}

View File

@@ -1,21 +0,0 @@
// 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.optinstructions;
import org.jetbrains.java.decompiler.code.Instruction;
import java.io.DataOutputStream;
import java.io.IOException;
public class INVOKEINTERFACE extends Instruction {
public void writeToStream(DataOutputStream out, int offset) throws IOException {
out.writeByte(opc_invokeinterface);
out.writeShort(getOperand(0));
out.writeByte(getOperand(1));
out.writeByte(0);
}
public int length() {
return 5;
}
}

View File

@@ -1,19 +0,0 @@
// 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.optinstructions;
import org.jetbrains.java.decompiler.code.Instruction;
import java.io.DataOutputStream;
import java.io.IOException;
public class INVOKESPECIAL extends Instruction {
public void writeToStream(DataOutputStream out, int offset) throws IOException {
out.writeByte(opc_invokespecial);
out.writeShort(getOperand(0));
}
public int length() {
return 3;
}
}

View File

@@ -1,19 +0,0 @@
// 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.optinstructions;
import org.jetbrains.java.decompiler.code.Instruction;
import java.io.DataOutputStream;
import java.io.IOException;
public class INVOKESTATIC extends Instruction {
public void writeToStream(DataOutputStream out, int offset) throws IOException {
out.writeByte(opc_invokestatic);
out.writeShort(getOperand(0));
}
public int length() {
return 3;
}
}

View File

@@ -1,19 +0,0 @@
// 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.optinstructions;
import org.jetbrains.java.decompiler.code.Instruction;
import java.io.DataOutputStream;
import java.io.IOException;
public class INVOKEVIRTUAL extends Instruction {
public void writeToStream(DataOutputStream out, int offset) throws IOException {
out.writeByte(opc_invokevirtual);
out.writeShort(getOperand(0));
}
public int length() {
return 3;
}
}

View File

@@ -1,41 +0,0 @@
// 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.optinstructions;
import org.jetbrains.java.decompiler.code.Instruction;
import java.io.DataOutputStream;
import java.io.IOException;
public class ISTORE extends Instruction {
private static final int[] opcodes = new int[]{opc_istore_0, opc_istore_1, opc_istore_2, opc_istore_3};
public void writeToStream(DataOutputStream out, int offset) throws IOException {
int index = getOperand(0);
if (index > 3) {
if (wide) {
out.writeByte(opc_wide);
}
out.writeByte(opc_istore);
if (wide) {
out.writeShort(index);
}
else {
out.writeByte(index);
}
}
else {
out.writeByte(opcodes[index]);
}
}
public int length() {
int index = getOperand(0);
if (index > 3) {
return wide ? 4 : 2;
}
else {
return 1;
}
}
}

View File

@@ -1,32 +0,0 @@
// 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.optinstructions;
import org.jetbrains.java.decompiler.code.JumpInstruction;
import java.io.DataOutputStream;
import java.io.IOException;
public class JSR extends JumpInstruction {
public void writeToStream(DataOutputStream out, int offset) throws IOException {
int operand = getOperand(0);
if (operand < -32768 || operand > 32767) {
out.writeByte(opc_jsr_w);
out.writeInt(operand);
}
else {
out.writeByte(opc_jsr);
out.writeShort(operand);
}
}
public int length() {
int operand = getOperand(0);
if (operand < -32768 || operand > 32767) {
return 5;
}
else {
return 3;
}
}
}

View File

@@ -1,19 +0,0 @@
// 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.optinstructions;
import org.jetbrains.java.decompiler.code.JumpInstruction;
import java.io.DataOutputStream;
import java.io.IOException;
public class JSR_W extends JumpInstruction {
public void writeToStream(DataOutputStream out, int offset) throws IOException {
out.writeByte(opc_jsr_w);
out.writeInt(getOperand(0));
}
public int length() {
return 5;
}
}

View File

@@ -1,19 +0,0 @@
// 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.optinstructions;
import org.jetbrains.java.decompiler.code.Instruction;
import java.io.DataOutputStream;
import java.io.IOException;
public class LDC extends Instruction {
public void writeToStream(DataOutputStream out, int offset) throws IOException {
out.writeByte(opc_ldc);
out.writeByte(getOperand(0));
}
public int length() {
return 2;
}
}

View File

@@ -1,19 +0,0 @@
// 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.optinstructions;
import org.jetbrains.java.decompiler.code.Instruction;
import java.io.DataOutputStream;
import java.io.IOException;
public class LDC2_W extends Instruction {
public void writeToStream(DataOutputStream out, int offset) throws IOException {
out.writeByte(opc_ldc2_w);
out.writeShort(getOperand(0));
}
public int length() {
return 3;
}
}

View File

@@ -1,19 +0,0 @@
// 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.optinstructions;
import org.jetbrains.java.decompiler.code.Instruction;
import java.io.DataOutputStream;
import java.io.IOException;
public class LDC_W extends Instruction {
public void writeToStream(DataOutputStream out, int offset) throws IOException {
out.writeByte(opc_ldc_w);
out.writeShort(getOperand(0));
}
public int length() {
return 3;
}
}

View File

@@ -1,41 +0,0 @@
// 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.optinstructions;
import org.jetbrains.java.decompiler.code.Instruction;
import java.io.DataOutputStream;
import java.io.IOException;
public class LLOAD extends Instruction {
private static final int[] opcodes = new int[]{opc_lload_0, opc_lload_1, opc_lload_2, opc_lload_3};
public void writeToStream(DataOutputStream out, int offset) throws IOException {
int index = getOperand(0);
if (index > 3) {
if (wide) {
out.writeByte(opc_wide);
}
out.writeByte(opc_lload);
if (wide) {
out.writeShort(index);
}
else {
out.writeByte(index);
}
}
else {
out.writeByte(opcodes[index]);
}
}
public int length() {
int index = getOperand(0);
if (index > 3) {
return wide ? 4 : 2;
}
else {
return 1;
}
}
}

View File

@@ -1,28 +0,0 @@
// 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.optinstructions;
import org.jetbrains.java.decompiler.code.SwitchInstruction;
import java.io.DataOutputStream;
import java.io.IOException;
public class LOOKUPSWITCH extends SwitchInstruction {
public void writeToStream(DataOutputStream out, int offset) throws IOException {
out.writeByte(opc_lookupswitch);
int padding = 3 - (offset % 4);
for (int i = 0; i < padding; i++) {
out.writeByte(0);
}
for (int i = 0; i < operandsCount(); i++) {
out.writeInt(getOperand(i));
}
}
public int length() {
return 1 + operandsCount() * 4;
}
}

View File

@@ -1,41 +0,0 @@
// 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.optinstructions;
import org.jetbrains.java.decompiler.code.Instruction;
import java.io.DataOutputStream;
import java.io.IOException;
public class LSTORE extends Instruction {
private static final int[] opcodes = new int[]{opc_lstore_0, opc_lstore_1, opc_lstore_2, opc_lstore_3};
public void writeToStream(DataOutputStream out, int offset) throws IOException {
int index = getOperand(0);
if (index > 3) {
if (wide) {
out.writeByte(opc_wide);
}
out.writeByte(opc_lstore);
if (wide) {
out.writeShort(index);
}
else {
out.writeByte(index);
}
}
else {
out.writeByte(opcodes[index]);
}
}
public int length() {
int index = getOperand(0);
if (index > 3) {
return wide ? 4 : 2;
}
else {
return 1;
}
}
}

View File

@@ -1,20 +0,0 @@
// 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.optinstructions;
import org.jetbrains.java.decompiler.code.Instruction;
import java.io.DataOutputStream;
import java.io.IOException;
public class MULTIANEWARRAY extends Instruction {
public void writeToStream(DataOutputStream out, int offset) throws IOException {
out.writeByte(opc_multianewarray);
out.writeShort(getOperand(0));
out.writeByte(getOperand(1));
}
public int length() {
return 4;
}
}

View File

@@ -1,19 +0,0 @@
// 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.optinstructions;
import org.jetbrains.java.decompiler.code.Instruction;
import java.io.DataOutputStream;
import java.io.IOException;
public class NEW extends Instruction {
public void writeToStream(DataOutputStream out, int offset) throws IOException {
out.writeByte(opc_new);
out.writeShort(getOperand(0));
}
public int length() {
return 3;
}
}

View File

@@ -1,19 +0,0 @@
// 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.optinstructions;
import org.jetbrains.java.decompiler.code.Instruction;
import java.io.DataOutputStream;
import java.io.IOException;
public class NEWARRAY extends Instruction {
public void writeToStream(DataOutputStream out, int offset) throws IOException {
out.writeByte(opc_newarray);
out.writeByte(getOperand(0));
}
public int length() {
return 2;
}
}

View File

@@ -1,19 +0,0 @@
// 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.optinstructions;
import org.jetbrains.java.decompiler.code.Instruction;
import java.io.DataOutputStream;
import java.io.IOException;
public class PUTFIELD extends Instruction {
public void writeToStream(DataOutputStream out, int offset) throws IOException {
out.writeByte(opc_putfield);
out.writeShort(getOperand(0));
}
public int length() {
return 3;
}
}

View File

@@ -1,19 +0,0 @@
// 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.optinstructions;
import org.jetbrains.java.decompiler.code.Instruction;
import java.io.DataOutputStream;
import java.io.IOException;
public class PUTSTATIC extends Instruction {
public void writeToStream(DataOutputStream out, int offset) throws IOException {
out.writeByte(opc_putstatic);
out.writeShort(getOperand(0));
}
public int length() {
return 3;
}
}

View File

@@ -1,27 +0,0 @@
// 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.optinstructions;
import org.jetbrains.java.decompiler.code.Instruction;
import java.io.DataOutputStream;
import java.io.IOException;
public class RET extends Instruction {
public void writeToStream(DataOutputStream out, int offset) throws IOException {
if (wide) {
out.writeByte(opc_wide);
}
out.writeByte(opc_ret);
if (wide) {
out.writeShort(getOperand(0));
}
else {
out.writeByte(getOperand(0));
}
}
public int length() {
return wide ? 4 : 2;
}
}

View File

@@ -1,19 +0,0 @@
// 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.optinstructions;
import org.jetbrains.java.decompiler.code.Instruction;
import java.io.DataOutputStream;
import java.io.IOException;
public class SIPUSH extends Instruction {
public void writeToStream(DataOutputStream out, int offset) throws IOException {
out.writeByte(opc_sipush);
out.writeShort(getOperand(0));
}
public int length() {
return 3;
}
}

View File

@@ -1,28 +0,0 @@
// 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.optinstructions;
import org.jetbrains.java.decompiler.code.SwitchInstruction;
import java.io.DataOutputStream;
import java.io.IOException;
public class TABLESWITCH extends SwitchInstruction {
public void writeToStream(DataOutputStream out, int offset) throws IOException {
out.writeByte(opc_tableswitch);
int padding = 3 - (offset % 4);
for (int i = 0; i < padding; i++) {
out.writeByte(0);
}
for (int i = 0; i < operandsCount(); i++) {
out.writeInt(getOperand(i));
}
}
public int length() {
return 1 + operandsCount() * 4;
}
}