本文整理匯總了Java中org.objectweb.asm.commons.GeneratorAdapter.arrayLoad方法的典型用法代碼示例。如果您正苦於以下問題:Java GeneratorAdapter.arrayLoad方法的具體用法?Java GeneratorAdapter.arrayLoad怎麽用?Java GeneratorAdapter.arrayLoad使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.objectweb.asm.commons.GeneratorAdapter
的用法示例。
在下文中一共展示了GeneratorAdapter.arrayLoad方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: restore
import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
@Override
protected void restore(GeneratorAdapter mv, List<Type> args) {
// At this point, init$args has been called and the result Object is on the stack.
// The value of that Object is Object[] with exactly n + 1 elements.
// The first element is a string with the qualified name of the constructor to call.
// The remaining elements are the constructtor arguments.
// Create a new local that holds the result of init$args call.
mv.visitTypeInsn(Opcodes.CHECKCAST, "[Ljava/lang/Object;");
int constructorArgs = mv.newLocal(Type.getType("[Ljava/lang/Object;"));
mv.storeLocal(constructorArgs);
// Reinstate local values
mv.loadLocal(locals);
int stackIndex = 0;
for (int arrayIndex = 0; arrayIndex < args.size(); arrayIndex++) {
Type arg = args.get(arrayIndex);
// Do not restore "this"
if (arrayIndex > 0) {
// duplicates the array
mv.dup();
// index in the array of objects to restore the boxed parameter.
mv.push(arrayIndex);
// get it from the array
mv.arrayLoad(Type.getType(Object.class));
// unbox the argument
ByteCodeUtils.unbox(mv, arg);
// restore the argument
mv.visitVarInsn(arg.getOpcode(Opcodes.ISTORE), stackIndex);
}
// stack index must progress according to the parameter type we just processed.
stackIndex += arg.getSize();
}
// pops the array
mv.pop();
// Push a null for the marker parameter.
mv.loadLocal(constructorArgs);
mv.visitInsn(Opcodes.ACONST_NULL);
// Invoke the constructor
mv.visitMethodInsn(Opcodes.INVOKESPECIAL, thisClassName, "<init>", DISPATCHING_THIS_SIGNATURE, false);
mv.goTo(end.getLabel());
}