下面列出了org.objectweb.asm.Opcodes# CASTORE 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
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);
}
}
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();
}
}