本文整理匯總了Java中org.objectweb.asm.commons.GeneratorAdapter.getField方法的典型用法代碼示例。如果您正苦於以下問題:Java GeneratorAdapter.getField方法的具體用法?Java GeneratorAdapter.getField怎麽用?Java GeneratorAdapter.getField使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.objectweb.asm.commons.GeneratorAdapter
的用法示例。
在下文中一共展示了GeneratorAdapter.getField方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: loadMH
import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
@Contract("null, null, _, _ -> fail")
private static void loadMH(GeneratorAdapter adapter, Type reflectorClass, int flags, int mhIndex) {
if((flags & Magic.REFLECTOR_METHOD_USE_METHODHANDLE) == 0) return;
/* Load MethodHandle field */
adapter.loadThis();
adapter.getField(notNull(reflectorClass, "Reflector class shouldn't be null!"), MHF, MH_ARRAY);
/* Load index */
if(mhIndex >= 0 && mhIndex <= 5)
/* ICONST_x offset is 3, iow ICONST_0 = 3, ICONST_1 = 4 */
adapter.visitInsn(ICONST_0 + mhIndex);
else
adapter.visitIntInsn(BIPUSH, mhIndex);
/* Load MethodHandle from array */
adapter.visitInsn(AALOAD);
}
示例2: emit
import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
public void emit(C context, ObjExpr objx, GeneratorAdapter gen){
if(targetClass != null && field != null)
{
target.emit(C.EXPRESSION, objx, gen);
gen.visitLineNumber(line, gen.mark());
gen.checkCast(getType(targetClass));
gen.getField(getType(targetClass), fieldName, Type.getType(field.getType()));
//if(context != C.STATEMENT)
HostExpr.emitBoxReturn(objx, gen, field.getType());
if(context == C.STATEMENT)
{
gen.pop();
}
}
else
{
target.emit(C.EXPRESSION, objx, gen);
gen.visitLineNumber(line, gen.mark());
gen.push(fieldName);
gen.push(requireField);
gen.invokeStatic(REFLECTOR_TYPE, invokeNoArgInstanceMember);
if(context == C.STATEMENT)
gen.pop();
}
}
示例3: loadInstance
import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
@Contract("null, null, null, _ -> fail")
private static void loadInstance(GeneratorAdapter adapter, Type reflectorClass, Type targetClass, int flags) {
if((flags & Magic.REFLECTOR_METHOD_USE_INSTANCE) == 0) return;
adapter.loadThis();
adapter.getField(reflectorClass, REFF, (flags & Magic.TARGET_CLASS_VISIBILITY_PUBLIC) != 0 ? targetClass : OBJECT);
}
示例4: emitUnboxed
import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
public void emitUnboxed(C context, ObjExpr objx, GeneratorAdapter gen){
if(targetClass != null && field != null)
{
target.emit(C.EXPRESSION, objx, gen);
gen.visitLineNumber(line, gen.mark());
gen.checkCast(getType(targetClass));
gen.getField(getType(targetClass), fieldName, Type.getType(field.getType()));
}
else
throw new UnsupportedOperationException("Unboxed emit of unknown member");
}
示例5: 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);
}
示例6: generateFieldReadMethod
import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
@Contract("null, null, null, null, null, null, _, _ -> fail")
static void generateFieldReadMethod(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);
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() : "")
.returns(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.getField(targetClass, fieldName, fieldType);
else
adapter.getStatic(targetClass, fieldName, fieldType);
}
/* Return */
handleReturn(adapter, interfaceMethod, fieldType);
adapter.returnValue();
/* End method */
adapter.endMethod();
}