Java Code Examples for org.objectweb.asm.util.Printer#OPCODES

The following examples show how to use org.objectweb.asm.util.Printer#OPCODES . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TypeUtils.java    From maple-ir with GNU General Public License v3.0 6 votes vote down vote up
public static Type getPrimitiveArrayType(int opcode) {
	switch (opcode) {
		case T_BOOLEAN:
			return Type.getType("[Z");
		case T_BYTE:
			return Type.getType("[B");
		case T_SHORT:
			return Type.getType("[S");
		case T_CHAR:
			return Type.getType("[C");
		case T_INT:
			return Type.getType("[I");
		case T_LONG:
			return Type.getType("[J");
		case T_FLOAT:
			return Type.getType("[F");
		case T_DOUBLE:
			return Type.getType("[D");
		default:
			throw new IllegalArgumentException(Printer.OPCODES[opcode]);
	}
}
 
Example 2
Source File: ConditionalJumpStmt.java    From maple-ir with GNU General Public License v3.0 6 votes vote down vote up
public static ComparisonType getType(int opcode) {
	switch (opcode) {
		case Opcodes.IF_ACMPEQ:
		case Opcodes.IF_ICMPEQ:
		case Opcodes.IFEQ:
			return EQ;
		case Opcodes.IF_ACMPNE:
		case Opcodes.IF_ICMPNE:
		case Opcodes.IFNE:
			return NE;
		case Opcodes.IF_ICMPGT:
		case Opcodes.IFGT:
			return GT;
		case Opcodes.IF_ICMPGE:
		case Opcodes.IFGE:
			return GE;
		case Opcodes.IF_ICMPLT:
		case Opcodes.IFLT:
			return LT;
		case Opcodes.IF_ICMPLE:
		case Opcodes.IFLE:
			return LE;
		default:
			throw new IllegalArgumentException(Printer.OPCODES[opcode]);
	}
}
 
Example 3
Source File: GenerationPass.java    From maple-ir with GNU General Public License v3.0 5 votes vote down vote up
protected void _load_field(int opcode, String owner, String name, String desc) {
	save_stack(false);
	if(opcode == GETFIELD || opcode == GETSTATIC) {
		Expr inst = null;
		if(opcode == GETFIELD) {
			inst = pop();
		}
		FieldLoadExpr fExpr = new FieldLoadExpr(inst, owner, name, desc, opcode == GETSTATIC);
		int index = currentStack.height();
		Type type = assign_stack(index, fExpr);
		push(load_stack(index, type));
	} else {
		throw new UnsupportedOperationException(Printer.OPCODES[opcode] + " " + owner + "." + name + "   " + desc);
	}
}
 
Example 4
Source File: TypeUtils.java    From maple-ir with GNU General Public License v3.0 5 votes vote down vote up
public static ArrayType resolve(int opcode) {
	if(opcode >= IALOAD && opcode <= SALOAD) {
		return values()[opcode - IALOAD];
	} else if(opcode >= IASTORE && opcode <= SASTORE) {
		return values()[opcode - IASTORE];
	} else {
		throw new UnsupportedOperationException(Printer.OPCODES[opcode]);
	}
}
 
Example 5
Source File: TypeUtils.java    From maple-ir with GNU General Public License v3.0 5 votes vote down vote up
public static Type getLoadType(int opcode) {
	if (opcode == ILOAD) {
		return Type.INT_TYPE;
	} else if (opcode == LLOAD) {
		return Type.LONG_TYPE;
	} else if (opcode == FLOAD) {
		return Type.FLOAT_TYPE;
	} else if (opcode == DLOAD) {
		return Type.DOUBLE_TYPE;
	} else if (opcode == ALOAD) {
		return OBJECT_TYPE;
	} else {
		throw new IllegalArgumentException(Printer.OPCODES[opcode]);
	}
}
 
Example 6
Source File: TypeUtils.java    From maple-ir with GNU General Public License v3.0 5 votes vote down vote up
public static Type getStoreType(int opcode) {
	if (opcode == ISTORE) {
		return Type.INT_TYPE;
	} else if (opcode == LSTORE) {
		return Type.LONG_TYPE;
	} else if (opcode == FSTORE) {
		return Type.FLOAT_TYPE;
	} else if (opcode == DSTORE) {
		return Type.DOUBLE_TYPE;
	} else if (opcode == ASTORE) {
		return OBJECT_TYPE;
	} else {
		throw new IllegalArgumentException(Printer.OPCODES[opcode]);
	}
}
 
Example 7
Source File: TypeUtils.java    From maple-ir with GNU General Public License v3.0 5 votes vote down vote up
public static Type getCastType(int opcode) {
	switch (opcode) {
		case I2B:
			return Type.BYTE_TYPE;
		case I2C:
			return Type.CHAR_TYPE;
		case I2S:
			return Type.SHORT_TYPE;
		case L2I:
		case F2I:
		case D2I:
			return Type.INT_TYPE;
		case I2L:
		case F2L:
		case D2L:
			return Type.LONG_TYPE;
		case I2F:
		case L2F:
		case D2F:
			return Type.FLOAT_TYPE;
		case I2D:
		case L2D:
		case F2D:
			return Type.DOUBLE_TYPE;
		default:
			throw new IllegalArgumentException(Printer.OPCODES[opcode]);
	}
}
 
Example 8
Source File: ComparisonExpr.java    From maple-ir with GNU General Public License v3.0 5 votes vote down vote up
public static ValueComparisonType resolve(int opcode) {
	if(opcode == LCMP) {
		return CMP;
	} else if(opcode == FCMPG || opcode == DCMPG) {
		return ValueComparisonType.GT;
	} else if(opcode == FCMPL || opcode == DCMPL) {
		return ValueComparisonType.LT;
	} else {
		throw new UnsupportedOperationException(Printer.OPCODES[opcode]);
	}
}
 
Example 9
Source File: ComparisonExpr.java    From maple-ir with GNU General Public License v3.0 5 votes vote down vote up
public static Type resolveType(int opcode) {
	if(opcode == LCMP) {
		return Type.LONG_TYPE;
	} else if(opcode == FCMPG || opcode == FCMPL) {
		return Type.FLOAT_TYPE;
	} else if(opcode == DCMPG || opcode == DCMPL) {
		return Type.DOUBLE_TYPE;
	} else {
		throw new UnsupportedOperationException(Printer.OPCODES[opcode]);
	}
}
 
Example 10
Source File: ArithmeticExpr.java    From maple-ir with GNU General Public License v3.0 5 votes vote down vote up
public static Operator resolve(int bOpcode) {
	if(bOpcode >= IADD && bOpcode <= DREM){
		return values()[(int)Math.floor((bOpcode - IADD) / 4) + Operator.ADD.ordinal()];
	} else if(bOpcode >= ISHL && bOpcode <= LUSHR) {
		return values()[(int)Math.floor((bOpcode - ISHL) / 2) + Operator.SHL.ordinal()];
	} else if(bOpcode == IAND || bOpcode == LAND) {
		return Operator.AND;
	} else if(bOpcode == IOR || bOpcode == LOR) {
		return Operator.OR;
	} else if(bOpcode == IXOR || bOpcode == LXOR) {
		return Operator.XOR;
	} else {
		throw new UnsupportedOperationException(Printer.OPCODES[bOpcode]);
	}
}
 
Example 11
Source File: SAXCodeAdapter.java    From JByteMod-Beta with GNU General Public License v2.0 5 votes vote down vote up
@Override
public final void visitTableSwitchInsn(final int min, final int max, final Label dflt, final Label... labels) {
  AttributesImpl attrs = new AttributesImpl();
  attrs.addAttribute("", "min", "min", "", Integer.toString(min));
  attrs.addAttribute("", "max", "max", "", Integer.toString(max));
  attrs.addAttribute("", "dflt", "dflt", "", getLabel(dflt));
  String o = Printer.OPCODES[Opcodes.TABLESWITCH];
  sa.addStart(o, attrs);
  for (int i = 0; i < labels.length; i++) {
    AttributesImpl att2 = new AttributesImpl();
    att2.addAttribute("", "name", "name", "", getLabel(labels[i]));
    sa.addElement("label", att2);
  }
  sa.addEnd(o);
}
 
Example 12
Source File: SAXCodeAdapter.java    From JByteMod-Beta with GNU General Public License v2.0 5 votes vote down vote up
@Override
public final void visitLookupSwitchInsn(final Label dflt, final int[] keys, final Label[] labels) {
  AttributesImpl att = new AttributesImpl();
  att.addAttribute("", "dflt", "dflt", "", getLabel(dflt));
  String o = Printer.OPCODES[Opcodes.LOOKUPSWITCH];
  sa.addStart(o, att);
  for (int i = 0; i < labels.length; i++) {
    AttributesImpl att2 = new AttributesImpl();
    att2.addAttribute("", "name", "name", "", getLabel(labels[i]));
    att2.addAttribute("", "key", "key", "", Integer.toString(keys[i]));
    sa.addElement("label", att2);
  }
  sa.addEnd(o);
}
 
Example 13
Source File: InstructionGraphNode.java    From grappa with Apache License 2.0 5 votes vote down vote up
@Override
public String toString()
{
    return instruction.getOpcode() != -1
        ? Printer.OPCODES[instruction.getOpcode()]
        : super.toString();
}
 
Example 14
Source File: GizmoMethodVisitor.java    From gizmo with Apache License 2.0 4 votes vote down vote up
private static String getOpString(final int opcode) {
    return Printer.OPCODES[opcode];
}
 
Example 15
Source File: ArithmeticExpr.java    From maple-ir with GNU General Public License v3.0 4 votes vote down vote up
public static Type resolveType(int bOpcode) {
	switch(bOpcode) {
		case IADD:
		case ISUB:
		case IMUL:
		case IDIV:
		case IREM:
		case INEG:
		case ISHL:
		case ISHR:
		case IUSHR:
		case IAND:
		case IOR:
		case IXOR:
			return Type.INT_TYPE;
		case LADD:
		case LSUB:
		case LMUL:
		case LDIV:
		case LREM:
		case LNEG:
		case LSHL:
		case LSHR:
		case LUSHR:
		case LAND:
		case LOR:
		case LXOR:
			return Type.LONG_TYPE;
		case FADD:
		case FSUB:
		case FMUL:
		case FDIV:
		case FREM:
		case FNEG:
			return Type.FLOAT_TYPE;
		case DADD:
		case DSUB:
		case DMUL:
		case DDIV:
		case DREM:
		case DNEG:
			return Type.DOUBLE_TYPE;
			
		default:
			throw new UnsupportedOperationException(Printer.OPCODES[bOpcode]);
	}
}
 
Example 16
Source File: JumpEdge.java    From maple-ir with GNU General Public License v3.0 4 votes vote down vote up
@Override
public String toGraphString() {
	return Printer.OPCODES[opcode];
}