org.objectweb.asm.Type#toString ( )源码实例Demo

下面列出了org.objectweb.asm.Type#toString ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

/**
 * Generates a method that looks like this:
 * <p>
 * private static int compare(double, double);
 * Flags: PRIVATE, STATIC
 * Code:
 * 0: dload_0
 * 1: dload_2
 * 2: dcmpl (<--- The opcode)
 * 3: ireturn
 *
 * @param cn     The ClassNode the method is supposed to be
 * @param opcode the comparision opcode. Allowed opcodes: LCMP, FCMPL, FCMPG, DCMPL, DCMPG
 * @return The method node
 */
private static MethodNode generateComparisionMethod(ClassNode cn, int opcode) {
    if (!(opcode >= Opcodes.LCMP && opcode <= Opcodes.DCMPG))
        throw new IllegalArgumentException("The opcode must be LCMP, FCMPL, FCMPG, DCMPL or DCMPG");

    // The type of numbers which are compared
    Type type = opcode == Opcodes.LCMP ? Type.LONG_TYPE : (opcode == Opcodes.FCMPG || opcode == Opcodes.FCMPL) ? Type.FLOAT_TYPE : Type.DOUBLE_TYPE;
    String desc = "(" + type.toString() + type.toString() + ")I";

    MethodNode methodNode = new MethodNode(Opcodes.ACC_PRIVATE | Opcodes.ACC_STATIC, NameUtils.generateMethodName(cn, desc), desc, null, new String[0]);

    methodNode.instructions = new InsnList();

    methodNode.instructions.add(new VarInsnNode(type.getOpcode(Opcodes.ILOAD), 0));
    methodNode.instructions.add(new VarInsnNode(type.getOpcode(Opcodes.ILOAD), type.getSize()));
    methodNode.instructions.add(new InsnNode(opcode));
    methodNode.instructions.add(new InsnNode(Opcodes.IRETURN));

    return methodNode;
}
 
源代码2 项目: obfuscator   文件: Utils.java
public static String getInternalName(Type type) {
    switch (type.toString()) {
        case "V":
            return "void";
        case "Z":
            return "boolean";
        case "C":
            return "char";
        case "B":
            return "byte";
        case "S":
            return "short";
        case "I":
            return "int";
        case "F":
            return "float";
        case "J":
            return "long";
        case "D":
            return "double";
        default:
            throw new IllegalArgumentException("Type not known.");
    }
}
 
源代码3 项目: obfuscator   文件: NodeUtils.java
public static AbstractInsnNode getWrapperMethod(Type type) {
    if (type.getSort() != Type.VOID && TYPE_TO_WRAPPER.containsKey(type)) {
        return new MethodInsnNode(Opcodes.INVOKESTATIC, TYPE_TO_WRAPPER.get(type), "valueOf", "(" + type.toString() + ")L" + TYPE_TO_WRAPPER.get(type) + ";", false);
    }

    return new InsnNode(Opcodes.NOP);
}
 
源代码4 项目: Mixin   文件: MixinTargetContext.java
private String transformSingleDescriptor(Type type) {
    if (type.getSort() < Type.ARRAY) {
        return type.toString();
    }

    return this.transformSingleDescriptor(type.toString(), false);
}
 
源代码5 项目: maple-ir   文件: GenerationVerifier.java
static int size(Type t) {
	String s = t.toString();
	switch(s) {
		case "D":
		case "J":
			return 2;
		default:
			return 1;
	}
}
 
源代码6 项目: maple-ir   文件: NegationExpr.java
@Override
public Type getType() {
	Type t = expression.getType();
	if (t.getSort() >= Type.BOOLEAN && t.getSort() <= Type.INT) {
		return Type.INT_TYPE;
	} else if (t == Type.LONG_TYPE || t == Type.FLOAT_TYPE || t == Type.DOUBLE_TYPE) {
		return t;
	} else {
		throw new IllegalArgumentException(t.toString());
	}
}
 
源代码7 项目: maple-ir   文件: TypeUtils.java
public static int getSubtractOpcode(Type type) {
	if (type == Type.INT_TYPE) {
		return ISUB;
	} else if (type == Type.LONG_TYPE) {
		return LSUB;
	} else if (type == Type.FLOAT_TYPE) {
		return FSUB;
	} else if (type == Type.DOUBLE_TYPE) {
		return DSUB;
	} else {
		throw new IllegalArgumentException(type.toString());
	}
}
 
源代码8 项目: maple-ir   文件: TypeUtils.java
public static int getMultiplyOpcode(Type type) {
	if (type == Type.INT_TYPE) {
		return IMUL;
	} else if (type == Type.LONG_TYPE) {
		return LMUL;
	} else if (type == Type.FLOAT_TYPE) {
		return FMUL;
	} else if (type == Type.DOUBLE_TYPE) {
		return DMUL;
	} else {
		throw new IllegalArgumentException(type.toString());
	}
}
 
源代码9 项目: maple-ir   文件: TypeUtils.java
public static int getDivideOpcode(Type type) {
	if (type == Type.INT_TYPE) {
		return IDIV;
	} else if (type == Type.LONG_TYPE) {
		return LDIV;
	} else if (type == Type.FLOAT_TYPE) {
		return FDIV;
	} else if (type == Type.DOUBLE_TYPE) {
		return DDIV;
	} else {
		throw new IllegalArgumentException(type.toString());
	}
}
 
源代码10 项目: maple-ir   文件: TypeUtils.java
public static int getRemainderOpcode(Type type) {
	if (type == Type.INT_TYPE) {
		return IREM;
	} else if (type == Type.LONG_TYPE) {
		return LREM;
	} else if (type == Type.FLOAT_TYPE) {
		return FREM;
	} else if (type == Type.DOUBLE_TYPE) {
		return DREM;
	} else {
		throw new IllegalArgumentException(type.toString());
	}
}
 
源代码11 项目: maple-ir   文件: TypeUtils.java
public static int getBitAndOpcode(Type type) {
	if (type == Type.INT_TYPE) {
		return IAND;
	} else if (type == Type.LONG_TYPE) {
		return LAND;
	} else {
		throw new IllegalArgumentException(type.toString());
	}
}
 
源代码12 项目: maple-ir   文件: TypeUtils.java
public static int getBitOrOpcode(Type type) {
	if (type == Type.INT_TYPE) {
		return IOR;
	} else if (type == Type.LONG_TYPE) {
		return LOR;
	} else {
		throw new IllegalArgumentException(type.toString());
	}
}
 
源代码13 项目: maple-ir   文件: TypeUtils.java
public static int getBitXorOpcode(Type type) {
	if (type == Type.INT_TYPE) {
		return IXOR;
	} else if (type == Type.LONG_TYPE) {
		return LXOR;
	} else {
		throw new IllegalArgumentException(type.toString());
	}
}
 
源代码14 项目: maple-ir   文件: TypeUtils.java
public static int getBitShiftLeftOpcode(Type type) {
	if (type == Type.INT_TYPE) {
		return ISHL;
	} else if (type == Type.LONG_TYPE) {
		return LSHL;
	} else {
		throw new IllegalArgumentException(type.toString());
	}
}
 
源代码15 项目: maple-ir   文件: TypeUtils.java
public static int bitShiftRightOpcode(Type type) {
	if (type == Type.INT_TYPE) {
		return ISHR;
	} else if (type == Type.LONG_TYPE) {
		return LSHR;
	} else {
		throw new IllegalArgumentException(type.toString());
	}
}
 
源代码16 项目: maple-ir   文件: TypeUtils.java
public static int getBitShiftRightUnsignedOpcode(Type type) {
	if (type == Type.INT_TYPE) {
		return IUSHR;
	} else if (type == Type.LONG_TYPE) {
		return LUSHR;
	} else {
		throw new IllegalArgumentException(type.toString());
	}
}
 
源代码17 项目: maple-ir   文件: TypeUtils.java
public static int getNegateOpcode(Type type) {
	if (type == Type.INT_TYPE || type == Type.SHORT_TYPE || type == Type.BYTE_TYPE) {
		return Opcodes.INEG;
	} else if (type == Type.LONG_TYPE) {
		return Opcodes.LNEG;
	} else if (type == Type.FLOAT_TYPE) {
		return Opcodes.FNEG;
	} else if (type == Type.DOUBLE_TYPE) {
		return Opcodes.DNEG;
	} else {
		throw new IllegalArgumentException(type.toString());
	}
}
 
源代码18 项目: maple-ir   文件: TypeUtils.java
public static int getDupOpcode(Type type) {
	if (type.getSize() == 1) {
		return Opcodes.DUP;
	} else if (type.getSize() == 2) {
		return Opcodes.DUP2;
	} else {
		throw new IllegalArgumentException(type.toString());
	}
}
 
源代码19 项目: maple-ir   文件: TypeUtils.java
public static int getPopOpcode(Type type) {
	if (type.getSize() == 1) {
		return Opcodes.POP;
	} else if (type.getSize() == 2) {
		return Opcodes.POP2;
	} else {
		throw new IllegalArgumentException(type.toString());
	}
}
 
源代码20 项目: maple-ir   文件: ReflectiveFunctorFactory.java
@Override
public EvaluationFunctor<Boolean> branch(Type lt, Type rt, ConditionalJumpStmt.ComparisonType type) {
	Type opType = TypeUtils.resolveBinOpType(lt, rt);
	String name = lt.getClassName() + type.name() + rt.getClassName() + "OPTYPE" + opType.getClassName() + "RETbool";

	String desc = "(" + lt.getDescriptor() + rt.getDescriptor() + ")Z";

	if(cache.containsKey(name)) {
		return _get(name);
	}

	MethodNode m = makeBase(name, desc);
	{
		InsnList insns = new InsnList();
		
		insns.add(new VarInsnNode(TypeUtils.getVariableLoadOpcode(lt), 0));
		cast(insns, lt, opType);
		insns.add(new VarInsnNode(TypeUtils.getVariableLoadOpcode(rt), lt.getSize()));
		cast(insns, rt, opType);
		

		LabelNode trueSuccessor = new LabelNode();
		
		if (opType == Type.INT_TYPE) {
			insns.add(new JumpInsnNode(Opcodes.IF_ICMPEQ + type.ordinal(), trueSuccessor));
		} else if (opType == Type.LONG_TYPE) {
			insns.add(new InsnNode(Opcodes.LCMP));
			insns.add(new JumpInsnNode(Opcodes.IFEQ + type.ordinal(), trueSuccessor));
		} else if (opType == Type.FLOAT_TYPE) {
			insns.add(new InsnNode((type == ConditionalJumpStmt.ComparisonType.LT || type == ConditionalJumpStmt.ComparisonType.LE) ? Opcodes.FCMPL : Opcodes.FCMPG));
			insns.add(new JumpInsnNode(Opcodes.IFEQ + type.ordinal(), trueSuccessor));
		} else if (opType == Type.DOUBLE_TYPE) {
			insns.add(new InsnNode((type == ConditionalJumpStmt.ComparisonType.LT || type == ConditionalJumpStmt.ComparisonType.LE) ? Opcodes.DCMPL : Opcodes.DCMPG));
			insns.add(new JumpInsnNode(Opcodes.IFEQ + type.ordinal(), trueSuccessor));
		} else {
			throw new IllegalArgumentException(opType.toString());
		}
		
		branchReturn(insns, trueSuccessor);
		
		m.node.instructions = insns;
	}
	
	return buildBridge(m);
}