本文整理匯總了Java中org.objectweb.asm.commons.GeneratorAdapter.loadArg方法的典型用法代碼示例。如果您正苦於以下問題:Java GeneratorAdapter.loadArg方法的具體用法?Java GeneratorAdapter.loadArg怎麽用?Java GeneratorAdapter.loadArg使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.objectweb.asm.commons.GeneratorAdapter
的用法示例。
在下文中一共展示了GeneratorAdapter.loadArg方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: loadArguments
import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
@Contract("null, null, null, !null -> fail")
private static void loadArguments(GeneratorAdapter ga, Type[] interfaceTypes, Type[] targetTypes, boolean isTargetPublic) {
Ensure.ensureCondition(interfaceTypes.length == targetTypes.length,
"Interface and target parameter count don't match!");
/* Iterate through all types */
for(int i = 0; i < interfaceTypes.length; i++) {
Type interfaceType = interfaceTypes[i];
Type targetType = targetTypes[i];
ga.loadArg(i);
/* Do not do boxing/unboxing if MethodHandle.invoke is used, it handles them on its own */
if(!isTargetPublic) continue;
if(isPrimitive(interfaceType)) {
if(!isPrimitive(targetType)) {
ga.box(targetType);
}
} else {
if(isPrimitive(targetType)) {
ga.unbox(targetType);
} else {
if(interfaceType.equals(OBJECT)) {
ga.checkCast(targetType);
ga.cast(interfaceType, targetType);
}
}
}
}
}
示例2: emitUnboxedLocal
import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
private void emitUnboxedLocal(GeneratorAdapter gen, LocalBinding lb){
int argoff = canBeDirect ?0:1;
Class primc = lb.getPrimitiveType();
if(closes.containsKey(lb))
{
gen.loadThis();
gen.getField(objtype, lb.name, Type.getType(primc));
}
else if(lb.isArg)
gen.loadArg(lb.idx-argoff);
else
gen.visitVarInsn(Type.getType(primc).getOpcode(Opcodes.ILOAD), lb.idx);
}
示例3: generateFieldWriteMethod
import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
@Contract("null, null, null, null, null, null, _, _ -> fail")
static void generateFieldWriteMethod(ClassVisitor cv, Method interfaceMethod,
Type reflectorClass, Type targetClass, Type fieldType, String fieldName,
int flags, int mhIndex) {
String methodName = interfaceMethod.getName();
String methodDesc = Type.getMethodDescriptor(interfaceMethod);
MethodVisitor mv = cv.visitMethod(ACC_PUBLIC, methodName, methodDesc, null, null);
GeneratorAdapter adapter = new GeneratorAdapter(mv, ACC_PUBLIC, methodName, methodDesc);
adapter.visitCode();
/* Load MethodHandle, if required */
loadMH(adapter, reflectorClass, flags, mhIndex);
/* Load instance, if required */
loadInstance(adapter, reflectorClass, targetClass, flags);
/* Load method parameter into stack */
adapter.loadArg(0);
if((flags & Magic.REFLECTOR_METHOD_USE_METHODHANDLE) != 0) {
/* Build MethodHandle descriptor */
String mhDescriptor = newDescriptor()
.accepts(((flags & Magic.REFLECTOR_METHOD_USE_INSTANCE) != 0 ?
((flags & Magic.TARGET_CLASS_VISIBILITY_PUBLIC) != 0 ? targetClass : OBJECT).getDescriptor(): "")
+ fieldType.getDescriptor())
.toString();
/* Select right MethodHandle invoker */
String mhInvoker = (flags & Magic.TARGET_CLASS_VISIBILITY_PUBLIC) != 0 && (flags & Magic.RETURN_TYPE_PUBLIC) != 0 ? "invokeExact" : "invoke";
/* Invoke MethodHandle */
adapter.visitMethodInsn(INVOKEVIRTUAL, MH.getInternalName(), mhInvoker, mhDescriptor, false);
} else {
if((flags & Magic.REFLECTOR_METHOD_USE_INSTANCE) != 0)
adapter.putField(targetClass, fieldName, fieldType);
else
adapter.putStatic(targetClass, fieldName, fieldType);
}
/* Return */
adapter.returnValue();
/* End method */
adapter.endMethod();
}