parent
71d8f4d689
commit
29de7ad72e
@ -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"
|
|
||||||
}; |
|
||||||
} |
|
@ -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; |
|
||||||
} |
|
||||||
} |
|
@ -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.
|
// 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; |
package org.jetbrains.java.decompiler.code; |
||||||
|
|
||||||
import java.io.DataOutputStream; |
|
||||||
import java.io.IOException; |
|
||||||
|
|
||||||
public class Instruction implements CodeConstants { |
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 || |
||||||
|
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 static boolean equals(Instruction i1, Instruction i2) { |
||||||
// public fields
|
return i1 != null && i2 != null && |
||||||
// *****************************************************************************
|
(i1 == i2 || |
||||||
|
i1.opcode == i2.opcode && |
||||||
public int opcode; |
i1.wide == i2.wide && |
||||||
|
i1.operandsCount() == i2.operandsCount()); |
||||||
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 final int opcode; |
||||||
|
public final int group; |
||||||
|
public final boolean wide; |
||||||
|
public final int bytecodeVersion; |
||||||
|
|
||||||
// *****************************************************************************
|
protected final int[] operands; |
||||||
// public methods
|
|
||||||
// *****************************************************************************
|
|
||||||
|
|
||||||
public Instruction() { |
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 int length() { |
public void initInstruction(InstructionSequence seq) { } |
||||||
return 1; |
|
||||||
} |
|
||||||
|
|
||||||
public int operandsCount() { |
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]; |
return operands[index]; |
||||||
} |
} |
||||||
|
|
||||||
public Instruction clone() { |
public boolean canFallThrough() { |
||||||
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() { |
|
||||||
return opcode != opc_goto && opcode != opc_goto_w && opcode != opc_ret && |
return opcode != opc_goto && opcode != opc_goto_w && opcode != opc_ret && |
||||||
!(opcode >= opc_ireturn && opcode <= opc_return) && opcode != opc_athrow |
!(opcode >= opc_ireturn && opcode <= opc_return) && |
||||||
&& opcode != opc_jsr && opcode != opc_tableswitch && opcode != opc_lookupswitch; |
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; |
|
||||||
} |
} |
||||||
|
|
||||||
// should be overwritten by subclasses
|
@Override |
||||||
public void initInstruction(InstructionSequence seq) { |
@SuppressWarnings("MethodDoesntCallSuperMethod") |
||||||
} |
public Instruction clone() { |
||||||
|
return create(opcode, wide, group, bytecodeVersion, operands == null ? null : operands.clone()); |
||||||
// 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; |
|
||||||
} |
} |
||||||
} |
} |
@ -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.
|
// 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; |
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 class JumpInstruction extends Instruction { |
||||||
|
|
||||||
public int destination; |
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) { |
public void initInstruction(InstructionSequence seq) { |
||||||
destination = seq.getPointerByRelOffset(this.getOperand(0)); |
destination = seq.getPointerByRelOffset(this.operand(0)); |
||||||
} |
} |
||||||
|
|
||||||
|
@Override |
||||||
public JumpInstruction clone() { |
public JumpInstruction clone() { |
||||||
JumpInstruction newinstr = (JumpInstruction)super.clone(); |
JumpInstruction copy = (JumpInstruction)super.clone(); |
||||||
|
copy.destination = destination; |
||||||
newinstr.destination = destination; |
return copy; |
||||||
return newinstr; |
|
||||||
} |
} |
||||||
} |
} |
@ -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.
|
// 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; |
package org.jetbrains.java.decompiler.code; |
||||||
|
|
||||||
/* |
|
||||||
* opc_tableswitch, lookupswitch |
|
||||||
*/ |
|
||||||
|
|
||||||
public class SwitchInstruction extends Instruction { |
public class SwitchInstruction extends Instruction { |
||||||
|
|
||||||
private int[] destinations; |
private int[] destinations; |
||||||
|
|
||||||
private int[] values; |
private int[] values; |
||||||
|
private int defaultDestination; |
||||||
|
|
||||||
private int defaultdest; |
public SwitchInstruction(int opcode, int group, boolean wide, int bytecodeVersion, int[] operands) { |
||||||
|
super(opcode, group, wide, bytecodeVersion, operands); |
||||||
public SwitchInstruction() { |
|
||||||
} |
} |
||||||
|
|
||||||
|
@Override |
||||||
public void initInstruction(InstructionSequence seq) { |
public void initInstruction(InstructionSequence seq) { |
||||||
|
defaultDestination = seq.getPointerByRelOffset(operands[0]); |
||||||
|
|
||||||
int pref = (opcode == CodeConstants.opc_tableswitch ? 3 : 2); |
int prefix = opcode == CodeConstants.opc_tableswitch ? 3 : 2; |
||||||
int len = this.getOperands().length - pref; |
int len = operands.length - prefix; |
||||||
defaultdest = seq.getPointerByRelOffset(this.getOperand(0)); |
|
||||||
|
|
||||||
int low = 0; |
int low = 0; |
||||||
|
|
||||||
if (opcode == CodeConstants.opc_lookupswitch) { |
if (opcode == CodeConstants.opc_lookupswitch) { |
||||||
len /= 2; |
len /= 2; |
||||||
} |
} |
||||||
else { |
else { |
||||||
low = this.getOperand(1); |
low = operands[1]; |
||||||
} |
} |
||||||
|
|
||||||
destinations = new int[len]; |
destinations = new int[len]; |
||||||
values = new int[len]; |
values = new int[len]; |
||||||
|
|
||||||
for (int i = 0, k = 0; i < len; i++, k++) { |
for (int i = 0, k = 0; i < len; i++, k++) { |
||||||
if (opcode == CodeConstants.opc_lookupswitch) { |
if (opcode == CodeConstants.opc_lookupswitch) { |
||||||
values[i] = this.getOperand(pref + k); |
values[i] = operands[prefix + k]; |
||||||
k++; |
k++; |
||||||
} |
} |
||||||
else { |
else { |
||||||
values[i] = low + k; |
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() { |
public int[] getDestinations() { |
||||||
return destinations; |
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() { |
public int[] getValues() { |
||||||
return values; |
return values; |
||||||
} |
} |
||||||
|
|
||||||
public void setValues(int[] values) { |
public int getDefaultDestination() { |
||||||
this.values = values; |
return defaultDestination; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public SwitchInstruction clone() { |
||||||
|
SwitchInstruction copy = (SwitchInstruction)super.clone(); |
||||||
|
copy.defaultDestination = defaultDestination; |
||||||
|
copy.destinations = destinations.clone(); |
||||||
|
copy.values = values.clone(); |
||||||
|
return copy; |
||||||
} |
} |
||||||
} |
} |
@ -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]; |
|
||||||
} |
|
||||||
} |
|
@ -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; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -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; |
|
||||||
} |
|
||||||
} |
|
@ -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; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -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; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -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; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
@ -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; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -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; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -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; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -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; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -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; |
|
||||||
} |
|
||||||
} |
|
@ -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; |
|
||||||
} |
|
||||||
} |
|
@ -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; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -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; |
|
||||||
} |
|
||||||
} |
|
@ -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; |
|
||||||
} |
|
||||||
} |
|
@ -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; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -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; |
|
||||||
} |
|
||||||
} |
|
@ -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; |
|
||||||
} |
|
||||||
} |
|
@ -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; |
|
||||||
} |
|
||||||
} |
|
@ -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; |
|
||||||
} |
|
||||||
} |
|
@ -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; |
|
||||||
} |
|
||||||
} |
|
@ -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; |
|
||||||
} |
|
||||||
} |
|
@ -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; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -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; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -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; |
|
||||||
} |
|
||||||
} |
|
@ -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; |
|
||||||
} |
|
||||||
} |
|
@ -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; |
|
||||||
} |
|
||||||
} |
|
@ -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; |
|
||||||
} |
|
||||||
} |
|
@ -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; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -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; |
|
||||||
} |
|
||||||
} |
|
@ -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; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -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; |
|
||||||
} |
|
||||||
} |
|
@ -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; |
|
||||||
} |
|
||||||
} |
|
@ -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; |
|
||||||
} |
|
||||||
} |
|
@ -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; |
|
||||||
} |
|
||||||
} |
|
@ -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; |
|
||||||
} |
|
||||||
} |
|
@ -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; |
|
||||||
} |
|
||||||
} |
|
@ -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; |
|
||||||
} |
|
||||||
} |
|
@ -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; |
|
||||||
} |
|
||||||
} |
|
@ -1,197 +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.modules.decompiler; |
|
||||||
|
|
||||||
import org.jetbrains.java.decompiler.modules.decompiler.stats.DoStatement; |
|
||||||
import org.jetbrains.java.decompiler.modules.decompiler.stats.Statement; |
|
||||||
|
|
||||||
import java.util.ArrayList; |
|
||||||
import java.util.HashMap; |
|
||||||
import java.util.List; |
|
||||||
|
|
||||||
|
|
||||||
public class EliminateLoopsHelper { |
|
||||||
|
|
||||||
|
|
||||||
// public static boolean eliminateLoops(Statement root) {
|
|
||||||
//
|
|
||||||
// boolean ret = eliminateLoopsRec(root);
|
|
||||||
//
|
|
||||||
// if(ret) {
|
|
||||||
// SequenceHelper.condenseSequences(root);
|
|
||||||
//
|
|
||||||
// HashSet<Integer> setReorderedIfs = new HashSet<Integer>();
|
|
||||||
//
|
|
||||||
// SimplifyExprentsHelper sehelper = new SimplifyExprentsHelper(false);
|
|
||||||
// while(sehelper.simplifyStackVarsStatement(root, setReorderedIfs, null)) {
|
|
||||||
// SequenceHelper.condenseSequences(root);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return ret;
|
|
||||||
// }
|
|
||||||
|
|
||||||
private static boolean eliminateLoopsRec(Statement stat) { |
|
||||||
|
|
||||||
for (Statement st : stat.getStats()) { |
|
||||||
if (eliminateLoopsRec(st)) { |
|
||||||
return true; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
if (stat.type == Statement.TYPE_DO && isLoopRedundant((DoStatement)stat)) { |
|
||||||
return true; |
|
||||||
} |
|
||||||
|
|
||||||
return false; |
|
||||||
} |
|
||||||
|
|
||||||
private static boolean isLoopRedundant(DoStatement loop) { |
|
||||||
|
|
||||||
if (loop.getLooptype() != DoStatement.LOOP_DO) { |
|
||||||
return false; |
|
||||||
} |
|
||||||
|
|
||||||
// get parent loop if exists
|
|
||||||
Statement parentloop = loop.getParent(); |
|
||||||
while (parentloop != null && parentloop.type != Statement.TYPE_DO) { |
|
||||||
parentloop = parentloop.getParent(); |
|
||||||
} |
|
||||||
|
|
||||||
if (parentloop == null || parentloop.getBasichead() != loop.getBasichead()) { |
|
||||||
return false; |
|
||||||
} |
|
||||||
|
|
||||||
// collect relevant break edges
|
|
||||||
List<StatEdge> lstBreakEdges = new ArrayList<>(); |
|
||||||
for (StatEdge edge : loop.getLabelEdges()) { |
|
||||||
if (edge.getType() == StatEdge.TYPE_BREAK) { // all break edges are explicit because of LOOP_DO type
|
|
||||||
lstBreakEdges.add(edge); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
Statement loopcontent = loop.getFirst(); |
|
||||||
|
|
||||||
boolean firstok = loopcontent.getAllSuccessorEdges().isEmpty(); |
|
||||||
if (!firstok) { |
|
||||||
StatEdge edge = loopcontent.getAllSuccessorEdges().get(0); |
|
||||||
firstok = (edge.closure == loop && edge.getType() == StatEdge.TYPE_BREAK); |
|
||||||
if (firstok) { |
|
||||||
lstBreakEdges.remove(edge); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
if (!lstBreakEdges.isEmpty()) { |
|
||||||
if (firstok) { |
|
||||||
|
|
||||||
HashMap<Integer, Boolean> statLabeled = new HashMap<>(); |
|
||||||
List<Statement> lstEdgeClosures = new ArrayList<>(); |
|
||||||
|
|
||||||
for (StatEdge edge : lstBreakEdges) { |
|
||||||
Statement minclosure = LowBreakHelper.getMinClosure(loopcontent, edge.getSource()); |
|
||||||
lstEdgeClosures.add(minclosure); |
|
||||||
} |
|
||||||
|
|
||||||
int precount = loop.isLabeled() ? 1 : 0; |
|
||||||
for (Statement st : lstEdgeClosures) { |
|
||||||
if (!statLabeled.containsKey(st.id)) { |
|
||||||
boolean btemp = st.isLabeled(); |
|
||||||
precount += btemp ? 1 : 0; |
|
||||||
statLabeled.put(st.id, btemp); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
for (int i = 0; i < lstBreakEdges.size(); i++) { |
|
||||||
Statement st = lstEdgeClosures.get(i); |
|
||||||
statLabeled.put(st.id, LowBreakHelper.isBreakEdgeLabeled(lstBreakEdges.get(i).getSource(), st) | statLabeled.get(st.id)); |
|
||||||
} |
|
||||||
|
|
||||||
for (int i = 0; i < lstBreakEdges.size(); i++) { |
|
||||||
lstEdgeClosures.set(i, getMaxBreakLift(lstEdgeClosures.get(i), lstBreakEdges.get(i), statLabeled, loop)); |
|
||||||
} |
|
||||||
|
|
||||||
statLabeled.clear(); |
|
||||||
for (Statement st : lstEdgeClosures) { |
|
||||||
statLabeled.put(st.id, st.isLabeled()); |
|
||||||
} |
|
||||||
|
|
||||||
for (int i = 0; i < lstBreakEdges.size(); i++) { |
|
||||||
Statement st = lstEdgeClosures.get(i); |
|
||||||
statLabeled.put(st.id, LowBreakHelper.isBreakEdgeLabeled(lstBreakEdges.get(i).getSource(), st) | statLabeled.get(st.id)); |
|
||||||
} |
|
||||||
|
|
||||||
long postcount = statLabeled.values().stream().filter(Boolean::booleanValue).count(); |
|
||||||
|
|
||||||
if (precount <= postcount) { |
|
||||||
return false; |
|
||||||
} |
|
||||||
else { |
|
||||||
for (int i = 0; i < lstBreakEdges.size(); i++) { |
|
||||||
lstEdgeClosures.get(i).addLabeledEdge(lstBreakEdges.get(i)); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
else { |
|
||||||
return false; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
eliminateLoop(loop, parentloop); |
|
||||||
|
|
||||||
return true; |
|
||||||
} |
|
||||||
|
|
||||||
private static Statement getMaxBreakLift(Statement stat, StatEdge edge, HashMap<Integer, Boolean> statLabeled, Statement max) { |
|
||||||
|
|
||||||
Statement closure = stat; |
|
||||||
Statement newclosure = stat; |
|
||||||
|
|
||||||
while ((newclosure = getNextBreakLift(newclosure, edge, statLabeled, max)) != null) { |
|
||||||
closure = newclosure; |
|
||||||
} |
|
||||||
|
|
||||||
return closure; |
|
||||||
} |
|
||||||
|
|
||||||
private static Statement getNextBreakLift(Statement stat, StatEdge edge, HashMap<Integer, Boolean> statLabeled, Statement max) { |
|
||||||
|
|
||||||
Statement closure = stat.getParent(); |
|
||||||
|
|
||||||
while (closure != null && closure != max && !closure.containsStatementStrict(edge.getDestination())) { |
|
||||||
|
|
||||||
boolean edge_labeled = LowBreakHelper.isBreakEdgeLabeled(edge.getSource(), closure); |
|
||||||
boolean stat_labeled = statLabeled.containsKey(closure.id) ? statLabeled.get(closure.id) : closure.isLabeled(); |
|
||||||
|
|
||||||
if (stat_labeled || !edge_labeled) { |
|
||||||
return closure; |
|
||||||
} |
|
||||||
|
|
||||||
closure = closure.getParent(); |
|
||||||
} |
|
||||||
|
|
||||||
return null; |
|
||||||
} |
|
||||||
|
|
||||||
private static void eliminateLoop(Statement loop, Statement parentloop) { |
|
||||||
|
|
||||||
// move continue edges to the parent loop
|
|
||||||
List<StatEdge> lst = new ArrayList<>(loop.getLabelEdges()); |
|
||||||
for (StatEdge edge : lst) { |
|
||||||
loop.removePredecessor(edge); |
|
||||||
edge.getSource().changeEdgeNode(Statement.DIRECTION_FORWARD, edge, parentloop); |
|
||||||
parentloop.addPredecessor(edge); |
|
||||||
|
|
||||||
parentloop.addLabeledEdge(edge); |
|
||||||
} |
|
||||||
|
|
||||||
// remove the last break edge, if exists
|
|
||||||
Statement loopcontent = loop.getFirst(); |
|
||||||
if (!loopcontent.getAllSuccessorEdges().isEmpty()) { |
|
||||||
loopcontent.removeSuccessor(loopcontent.getAllSuccessorEdges().get(0)); |
|
||||||
} |
|
||||||
|
|
||||||
// replace loop with its content
|
|
||||||
loop.getParent().replaceStatement(loop, loopcontent); |
|
||||||
} |
|
||||||
} |
|
@ -1,194 +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.modules.decompiler; |
|
||||||
|
|
||||||
import org.jetbrains.java.decompiler.modules.decompiler.stats.IfStatement; |
|
||||||
import org.jetbrains.java.decompiler.modules.decompiler.stats.Statement; |
|
||||||
import org.jetbrains.java.decompiler.modules.decompiler.stats.SynchronizedStatement; |
|
||||||
|
|
||||||
import java.util.List; |
|
||||||
|
|
||||||
public class LowBreakHelper { |
|
||||||
|
|
||||||
public static void lowBreakLabels(Statement root) { |
|
||||||
|
|
||||||
lowBreakLabelsRec(root); |
|
||||||
|
|
||||||
liftBreakLabels(root); |
|
||||||
} |
|
||||||
|
|
||||||
private static void lowBreakLabelsRec(Statement stat) { |
|
||||||
|
|
||||||
while (true) { |
|
||||||
|
|
||||||
boolean found = false; |
|
||||||
|
|
||||||
for (StatEdge edge : stat.getLabelEdges()) { |
|
||||||
if (edge.getType() == StatEdge.TYPE_BREAK) { |
|
||||||
Statement minclosure = getMinClosure(stat, edge.getSource()); |
|
||||||
if (minclosure != stat) { |
|
||||||
minclosure.addLabeledEdge(edge); |
|
||||||
edge.labeled = isBreakEdgeLabeled(edge.getSource(), minclosure); |
|
||||||
found = true; |
|
||||||
break; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
if (!found) { |
|
||||||
break; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
for (Statement st : stat.getStats()) { |
|
||||||
lowBreakLabelsRec(st); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public static boolean isBreakEdgeLabeled(Statement source, Statement closure) { |
|
||||||
|
|
||||||
if (closure.type == Statement.TYPE_DO || closure.type == Statement.TYPE_SWITCH) { |
|
||||||
|
|
||||||
Statement parent = source.getParent(); |
|
||||||
|
|
||||||
if (parent == closure) { |
|
||||||
return false; |
|
||||||
} |
|
||||||
else { |
|
||||||
return isBreakEdgeLabeled(parent, closure) || |
|
||||||
(parent.type == Statement.TYPE_DO || parent.type == Statement.TYPE_SWITCH); |
|
||||||
} |
|
||||||
} |
|
||||||
else { |
|
||||||
return true; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public static Statement getMinClosure(Statement closure, Statement source) { |
|
||||||
|
|
||||||
while (true) { |
|
||||||
|
|
||||||
Statement newclosure = null; |
|
||||||
|
|
||||||
switch (closure.type) { |
|
||||||
case Statement.TYPE_SEQUENCE: |
|
||||||
Statement last = closure.getStats().getLast(); |
|
||||||
|
|
||||||
if (isOkClosure(closure, source, last)) { |
|
||||||
newclosure = last; |
|
||||||
} |
|
||||||
break; |
|
||||||
case Statement.TYPE_IF: |
|
||||||
IfStatement ifclosure = (IfStatement)closure; |
|
||||||
if (isOkClosure(closure, source, ifclosure.getIfstat())) { |
|
||||||
newclosure = ifclosure.getIfstat(); |
|
||||||
} |
|
||||||
else if (isOkClosure(closure, source, ifclosure.getElsestat())) { |
|
||||||
newclosure = ifclosure.getElsestat(); |
|
||||||
} |
|
||||||
break; |
|
||||||
case Statement.TYPE_TRYCATCH: |
|
||||||
for (Statement st : closure.getStats()) { |
|
||||||
if (isOkClosure(closure, source, st)) { |
|
||||||
newclosure = st; |
|
||||||
break; |
|
||||||
} |
|
||||||
} |
|
||||||
break; |
|
||||||
case Statement.TYPE_SYNCRONIZED: |
|
||||||
Statement body = ((SynchronizedStatement)closure).getBody(); |
|
||||||
|
|
||||||
if (isOkClosure(closure, source, body)) { |
|
||||||
newclosure = body; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
if (newclosure == null) { |
|
||||||
break; |
|
||||||
} |
|
||||||
|
|
||||||
closure = newclosure; |
|
||||||
} |
|
||||||
|
|
||||||
return closure; |
|
||||||
} |
|
||||||
|
|
||||||
private static boolean isOkClosure(Statement closure, Statement source, Statement stat) { |
|
||||||
|
|
||||||
boolean ok = false; |
|
||||||
|
|
||||||
if (stat != null && stat.containsStatementStrict(source)) { |
|
||||||
|
|
||||||
List<StatEdge> lst = stat.getAllSuccessorEdges(); |
|
||||||
|
|
||||||
ok = lst.isEmpty(); |
|
||||||
if (!ok) { |
|
||||||
StatEdge edge = lst.get(0); |
|
||||||
ok = (edge.closure == closure && edge.getType() == StatEdge.TYPE_BREAK); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
return ok; |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
private static void liftBreakLabels(Statement stat) { |
|
||||||
|
|
||||||
for (Statement st : stat.getStats()) { |
|
||||||
liftBreakLabels(st); |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
while (true) { |
|
||||||
|
|
||||||
boolean found = false; |
|
||||||
|
|
||||||
for (StatEdge edge : stat.getLabelEdges()) { |
|
||||||
if (edge.explicit && edge.labeled && edge.getType() == StatEdge.TYPE_BREAK) { |
|
||||||
|
|
||||||
Statement newclosure = getMaxBreakLift(stat, edge); |
|
||||||
|
|
||||||
if (newclosure != null) { |
|
||||||
newclosure.addLabeledEdge(edge); |
|
||||||
edge.labeled = isBreakEdgeLabeled(edge.getSource(), newclosure); |
|
||||||
|
|
||||||
found = true; |
|
||||||
break; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
if (!found) { |
|
||||||
break; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
private static Statement getMaxBreakLift(Statement stat, StatEdge edge) { |
|
||||||
|
|
||||||
Statement closure = null; |
|
||||||
Statement newclosure = stat; |
|
||||||
|
|
||||||
while ((newclosure = getNextBreakLift(newclosure, edge)) != null) { |
|
||||||
closure = newclosure; |
|
||||||
} |
|
||||||
|
|
||||||
return closure; |
|
||||||
} |
|
||||||
|
|
||||||
private static Statement getNextBreakLift(Statement stat, StatEdge edge) { |
|
||||||
|
|
||||||
Statement closure = stat.getParent(); |
|
||||||
|
|
||||||
while (closure != null && !closure.containsStatementStrict(edge.getDestination())) { |
|
||||||
|
|
||||||
boolean labeled = isBreakEdgeLabeled(edge.getSource(), closure); |
|
||||||
if (closure.isLabeled() || !labeled) { |
|
||||||
return closure; |
|
||||||
} |
|
||||||
|
|
||||||
closure = closure.getParent(); |
|
||||||
} |
|
||||||
|
|
||||||
return null; |
|
||||||
} |
|
||||||
} |
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue