Java Code Examples for org.objectweb.asm.Opcodes#CASTORE

The following examples show how to use org.objectweb.asm.Opcodes#CASTORE . 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: Utils.java    From Concurnas with MIT License 5 votes vote down vote up
public static void applyArrayStore(BytecodeOutputter mv, Type origType, BytecodeGennerator bcv, boolean onInit) {
	if(origType instanceof PrimativeType && origType.getArrayLevels() == 1 )
	{
		PrimativeTypeEnum ee = ((PrimativeType)origType).type;
		int op;
		switch(ee)
		{
			case BOOLEAN: op = Opcodes.BASTORE; break; 
			case CHAR: op = Opcodes.CASTORE; break; 
			case FLOAT: op = Opcodes.FASTORE; break; 
			case DOUBLE: op = Opcodes.DASTORE; break; 
			case SHORT: op = Opcodes.SASTORE; break; 
			case INT: op = Opcodes.IASTORE; break; 
			case BYTE: op = Opcodes.BASTORE; break; 
			default: op = Opcodes.LASTORE; break;//long 
		}
		mv.visitInsn(op);
		
		
	}
	else
	{
		if(!onInit && TypeCheckUtils.hasRefLevelsAndIsArray(origType)){
			int tempSlot = bcv.createNewLocalVar(bcv.getTempVarName(), origType, false);
			mv.visitVarInsn(ASTORE, tempSlot);
			
			mv.visitInsn(Opcodes.SWAP);
			extractAndCastArrayRef(mv, origType);
			//mv.visitFieldInsn(GETFIELD, "com/concurnas/bootstrap/runtime/ref/LocalArray", "ar", "[Ljava/lang/Object;");
			//mv.visitTypeInsn(CHECKCAST, "[Lcom/concurnas/runtime/ref/Local;");
			mv.visitInsn(Opcodes.SWAP);
			
			mv.visitVarInsn(ALOAD, tempSlot);
		}
		
		mv.visitInsn(Opcodes.AASTORE);
	}
}
 
Example 2
Source File: InstructionAssembler.java    From es6draft with MIT License 5 votes vote down vote up
public final void astore(Type type) {
    switch (type.getOpcode(Opcodes.IASTORE)) {
    case Opcodes.IASTORE:
        iastore();
        return;
    case Opcodes.LASTORE:
        lastore();
        return;
    case Opcodes.FASTORE:
        fastore();
        return;
    case Opcodes.DASTORE:
        dastore();
        return;
    case Opcodes.AASTORE:
        aastore();
        return;
    case Opcodes.BASTORE:
        bastore();
        return;
    case Opcodes.CASTORE:
        castore();
        return;
    case Opcodes.SASTORE:
        sastore();
        return;
    default:
        throw new IllegalArgumentException();
    }
}