org.objectweb.asm.Opcodes# CALOAD 源码实例Demo

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

源代码1 项目: Concurnas   文件: Utils.java

public static void applyArrayLoad(BytecodeOutputter mv, Type origType) {
	if(origType instanceof PrimativeType && origType.getArrayLevels() == 1 )
	{
		PrimativeTypeEnum ee = ((PrimativeType)origType).type;
		int op;
		switch(ee)
		{
			case BOOLEAN: op = Opcodes.BALOAD; break; 
			case CHAR: op = Opcodes.CALOAD; break; 
			case FLOAT: op = Opcodes.FALOAD; break; 
			case DOUBLE: op = Opcodes.DALOAD; break; 
			case SHORT: op = Opcodes.SALOAD; break; 
			case INT: op = Opcodes.IALOAD; break; 
			case BYTE: op = Opcodes.BALOAD; break; 
			default: op = Opcodes.LALOAD; break;//long 
		}
		mv.visitInsn(op);
		
	}
	else
	{//HERE BE PROBLEMS
		if(TypeCheckUtils.hasRefLevelsAndIsArray(origType)){
			mv.visitInsn(Opcodes.SWAP);
			extractAndCastArrayRef(mv, origType);
			mv.visitInsn(Opcodes.SWAP);
		}
		
		mv.visitInsn(Opcodes.AALOAD);
	}
}
 
源代码2 项目: serianalyzer   文件: JVMImpl.java

/**
 * @param opcode
 * @return
 */
private static Type toType ( int opcode ) {
    switch ( opcode ) {
    case Opcodes.LLOAD:
        return Type.LONG_TYPE;
    case Opcodes.ILOAD:
        return Type.INT_TYPE;
    case Opcodes.FLOAD:
        return Type.FLOAT_TYPE;
    case Opcodes.DLOAD:
        return Type.DOUBLE_TYPE;
    case Opcodes.ALOAD:
        return Type.getType("Ljava/lang/Object;"); //$NON-NLS-1$
    case Opcodes.IALOAD:
        return Type.INT_TYPE;
    case Opcodes.LALOAD:
        return Type.LONG_TYPE;
    case Opcodes.FALOAD:
        return Type.FLOAT_TYPE;
    case Opcodes.DALOAD:
        return Type.DOUBLE_TYPE;
    case Opcodes.BALOAD:
        return Type.BYTE_TYPE;
    case Opcodes.CALOAD:
        return Type.CHAR_TYPE;
    case Opcodes.SALOAD:
        return Type.SHORT_TYPE;
    }
    return Type.VOID_TYPE;
}
 
源代码3 项目: es6draft   文件: InstructionAssembler.java

public final void aload(Type type) {
    switch (type.getOpcode(Opcodes.IALOAD)) {
    case Opcodes.IALOAD:
        iaload();
        return;
    case Opcodes.LALOAD:
        laload();
        return;
    case Opcodes.FALOAD:
        faload();
        return;
    case Opcodes.DALOAD:
        daload();
        return;
    case Opcodes.AALOAD:
        aaload();
        return;
    case Opcodes.BALOAD:
        baload();
        return;
    case Opcodes.CALOAD:
        caload();
        return;
    case Opcodes.SALOAD:
        saload();
        return;
    default:
        throw new IllegalArgumentException();
    }
}
 
源代码4 项目: zelixkiller   文件: StackHelper.java

public InsnValue loadFromArray(AbstractInsnNode insn, InsnValue value1, InsnValue indexValue) throws AnalyzerException {
	Object indexObj = indexValue.getValue(), arrayObj = value1.getValue();
	int index = indexObj == null ? -1 : ((Number) indexObj).intValue();
	boolean arrayNotSimulated = arrayObj == null;
	Type t = arrayNotSimulated ? null : Type.getType(arrayObj.getClass());
	switch (insn.getOpcode()) {
	case Opcodes.IALOAD:
		if (arrayNotSimulated) {
			return InsnValue.INT_VALUE;
		}
		// Sometimes Object[] contain values. Stringer obfuscator does this.
		// TODO: Have this sort of check for others?
		boolean oarr = t.equals(InsnValue.REFERENCE_ARR_VALUE.getType());
		if (oarr) {
			int[] ia = (int[]) arrayObj;
			return InsnValue.intValue(ia[index]);
		}else{
			Object[] obarr = (Object[]) arrayObj;
			Object o = obarr[index];
			if (o == null){
				return InsnValue.INT_VALUE;
			}
			return InsnValue.intValue(((Number) o).intValue());
		}
	case Opcodes.LALOAD:
		if (arrayNotSimulated) {
			return InsnValue.LONG_VALUE;
		}
		long[] la = (long[]) arrayObj;
		return InsnValue.longValue(la[index]);
	case Opcodes.FALOAD:
		if (arrayNotSimulated) {
			return InsnValue.FLOAT_VALUE;
		}
		float[] fa = (float[]) arrayObj;
		return InsnValue.floatValue(fa[index]);
	case Opcodes.DALOAD:
		if (arrayNotSimulated) {
			return InsnValue.DOUBLE_VALUE;
		}
		double[] da = (double[]) arrayObj;
		return InsnValue.doubleValue(da[index]);
	case Opcodes.AALOAD:
		// TODO: Check if it's an object array, but the contents aren't objects
		return InsnValue.REFERENCE_VALUE;
	case Opcodes.BALOAD:
		if (arrayNotSimulated) {
			return InsnValue.BYTE_VALUE;
		}
		boolean db = t.equals(InsnValue.DOUBLE_ARR_VALUE.getType()), in = t.equals(InsnValue.INT_ARR_VALUE.getType()), saa = t.equals(InsnValue.SHORT_ARR_VALUE.getType());
		if (db) {
			double[] dba = (double[]) arrayObj;
			return InsnValue.intValue(dba[index]);
		} else if (in) {
			int[] ina = (int[]) arrayObj;
			return InsnValue.intValue(ina[index]);
		} else if (saa){
			short[] saaa = (short[]) arrayObj;
			return InsnValue.intValue(saaa[index]);
		} else {
			System.err.println("UNKNOWN TYPE BALOAD: " + t);
			throw new RuntimeException();
		}

	case Opcodes.CALOAD:
		if (arrayNotSimulated) {
			return InsnValue.CHAR_VALUE;
		}
		char[] ca = (char[]) arrayObj;
		return InsnValue.charValue(ca[index]);
	case Opcodes.SALOAD:
		if (arrayNotSimulated) {
			return InsnValue.SHORT_VALUE;
		}
		short[] sa = (short[]) arrayObj;
		return InsnValue.intValue((short) sa[index]);
	}

	return null;
}
 
源代码5 项目: CodenameOne   文件: ArrayLoadExpression.java

public static int tryReduce(List<Instruction> instructions, int index) {
    Instruction instr = instructions.get(index);
    switch (instr.getOpcode()) {
        case Opcodes.AALOAD:
        case Opcodes.FALOAD:
        case Opcodes.CALOAD:
        case Opcodes.DALOAD:
        case Opcodes.BALOAD:
        case Opcodes.IALOAD:
        case Opcodes.LALOAD:
        case Opcodes.SALOAD:
            break;
        default:
            return -1;
    }
    
    if (index < 2) {
        return -1;
    }
    
    Instruction indexInstr = instructions.get(index-1);
    if (!(indexInstr instanceof AssignableExpression)) {
        return -1;
    }
    
    Instruction arrInstr = instructions.get(index-2);
    if (!(arrInstr instanceof AssignableExpression)) {
        return -1;
    }
    
    ArrayLoadExpression out = new ArrayLoadExpression();
    out.loadInstruction = instr;
    out.indexInstruction = indexInstr;
    out.targetArrayInstruction = arrInstr;
    
    instructions.remove(index-2);
    instructions.remove(index-2);
    instructions.remove(index-2);
    instructions.add(index-2, out);
    return index-2;
}
 
 方法所在类
 同类方法