本文整理匯總了Java中org.objectweb.asm.commons.GeneratorAdapter.loadLocal方法的典型用法代碼示例。如果您正苦於以下問題:Java GeneratorAdapter.loadLocal方法的具體用法?Java GeneratorAdapter.loadLocal怎麽用?Java GeneratorAdapter.loadLocal使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.objectweb.asm.commons.GeneratorAdapter
的用法示例。
在下文中一共展示了GeneratorAdapter.loadLocal方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: redirect
import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
/**
* Adds the instructions to do a generic redirection.
*/
protected void redirect(GeneratorAdapter mv, int change) {
// code to check if a new implementation of the current class is available.
Label l0 = new Label();
mv.loadLocal(change);
mv.visitJumpInsn(Opcodes.IFNULL, l0);
doRedirect(mv, change);
// Return
if (type == Type.VOID_TYPE) {
mv.pop();
} else {
ByteCodeUtils.unbox(mv, type);
}
mv.returnValue();
// jump label for classes without any new implementation, just invoke the original
// method implementation.
mv.visitLabel(l0);
}
示例2: doRedirect
import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
@Override
protected void doRedirect( GeneratorAdapter mv, int change) {
mv.loadLocal(change);
mv.push(AcesoProguardMap.instance().getMtdIndex(visitedClassName, IncrementalTool.getMtdSig(mtdName,mtdDesc)));
ByteCodeUtils.newVariableArray(mv, ByteCodeUtils.toLocalVariables(types));
// now invoke the generic dispatch method.
mv.invokeInterface(IncrementalVisitor.CHANGE_TYPE, Method.getMethod("Object access$dispatch(int, Object[])"));
}
示例3: redirect
import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
/**
* Adds the instructions to do a generic redirection.
* <p/>
* Note that the generated bytecode does not have a direct translation to code, but as an
* example, the following code block gets inserted.
* <code>
* if ($change != null) {
* $change.access$dispatch($name, new object[] { arg0, ... argsN })
* $anyCodeInsertedbyRestore
* }
* $originalMethodBody
* </code>
*
* @param mv the method visitor to add the instructions to.
* @param change the local variable containing the alternate implementation.
* @param args the type of the local variable that need to be forwarded.
*/
void redirect(GeneratorAdapter mv, int change, List<Type> args) {
// code to check if a new implementation of the current class is available.
Label l0 = new Label();
mv.loadLocal(change);
mv.visitJumpInsn(Opcodes.IFNULL, l0);
mv.loadLocal(change);
mv.push(name);
// create an array of objects capable of containing all the parameters and optionally the "this"
createLocals(mv, args);
// we need to maintain the stack index when loading parameters from, as for long and double
// values, it uses 2 stack elements, all others use only 1 stack element.
int stackIndex = 0;
for (int arrayIndex = 0; arrayIndex < args.size(); arrayIndex++) {
Type arg = args.get(arrayIndex);
// duplicate the array of objects reference, it will be used to store the value in.
mv.dup();
// index in the array of objects to store the boxed parameter.
mv.push(arrayIndex);
// Pushes the appropriate local variable on the stack
redirectLocal(mv, stackIndex, arg);
// potentially box up intrinsic types.
mv.box(arg);
mv.arrayStore(Type.getType(Object.class));
// stack index must progress according to the parameter type we just processed.
stackIndex += arg.getSize();
}
// now invoke the generic dispatch method.
mv.invokeInterface(IncrementalVisitor.CHANGE_TYPE, Method.getMethod("Object access$dispatch(String, Object[])"));
// Restore the state after the redirection
restore(mv, args);
// jump label for classes without any new implementation, just invoke the original
// method implementation.
mv.visitLabel(l0);
}
示例4: redirectLocal
import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
@Override
protected void redirectLocal(GeneratorAdapter mv, int stackIndex, Type arg) {
// If the stack index is 0, we do not send the local variable 0 (this) as it
// cannot escape the constructor. Instead, we use this argument position to send
// a reference to the locals array where the redirected method will return their
// values.
if (stackIndex == 0) {
mv.loadLocal(locals);
} else {
super.redirectLocal(mv, stackIndex, arg);
}
}
示例5: 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());
}