當前位置: 首頁>>代碼示例>>Java>>正文


Java GeneratorAdapter.putField方法代碼示例

本文整理匯總了Java中org.objectweb.asm.commons.GeneratorAdapter.putField方法的典型用法代碼示例。如果您正苦於以下問題:Java GeneratorAdapter.putField方法的具體用法?Java GeneratorAdapter.putField怎麽用?Java GeneratorAdapter.putField使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.objectweb.asm.commons.GeneratorAdapter的用法示例。


在下文中一共展示了GeneratorAdapter.putField方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: emitAssign

import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
public void emitAssign(C context, ObjExpr objx, GeneratorAdapter gen,
                       Expr val){
	if(targetClass != null && field != null)
		{
		target.emit(C.EXPRESSION, objx, gen);
		gen.checkCast(getType(targetClass));
		val.emit(C.EXPRESSION, objx, gen);
		gen.visitLineNumber(line, gen.mark());
		gen.dupX1();
		HostExpr.emitUnboxArg(objx, gen, field.getType());
		gen.putField(getType(targetClass), fieldName, Type.getType(field.getType()));
		}
	else
		{
		target.emit(C.EXPRESSION, objx, gen);
		gen.push(fieldName);
		val.emit(C.EXPRESSION, objx, gen);
		gen.visitLineNumber(line, gen.mark());
		gen.invokeStatic(REFLECTOR_TYPE, setInstanceFieldMethod);
		}
	if(context == C.STATEMENT)
		gen.pop();
}
 
開發者ID:mrange,項目名稱:fsharpadvent2016,代碼行數:24,代碼來源:Compiler.java

示例2: emitLetFnInits

import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
public void emitLetFnInits(GeneratorAdapter gen, ObjExpr objx, IPersistentSet letFnLocals){
	//objx arg is enclosing objx, not this
	gen.checkCast(objtype);

	for(ISeq s = RT.keys(closes); s != null; s = s.next())
		{
		LocalBinding lb = (LocalBinding) s.first();
		if(letFnLocals.contains(lb))
			{
			Class primc = lb.getPrimitiveType();
			gen.dup();
			if(primc != null)
				{
				objx.emitUnboxedLocal(gen, lb);
				gen.putField(objtype, lb.name, Type.getType(primc));
				}
			else
				{
				objx.emitLocal(gen, lb, false);
				gen.putField(objtype, lb.name, OBJECT_TYPE);
				}
			}
		}
	gen.pop();

}
 
開發者ID:mrange,項目名稱:fsharpadvent2016,代碼行數:27,代碼來源:Compiler.java

示例3: emitAssignLocal

import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
public void emitAssignLocal(GeneratorAdapter gen, LocalBinding lb,Expr val){
	if(!isMutable(lb))
		throw new IllegalArgumentException("Cannot assign to non-mutable: " + lb.name);
	Class primc = lb.getPrimitiveType();
	gen.loadThis();
	if(primc != null)
		{
		if(!(val instanceof MaybePrimitiveExpr && ((MaybePrimitiveExpr) val).canEmitPrimitive()))
			throw new IllegalArgumentException("Must assign primitive to primitive mutable: " + lb.name);
		MaybePrimitiveExpr me = (MaybePrimitiveExpr) val;
		me.emitUnboxed(C.EXPRESSION, this, gen);
		gen.putField(objtype, lb.name, Type.getType(primc));
		}
	else
		{
		val.emit(C.EXPRESSION, this, gen);
		gen.putField(objtype, lb.name, OBJECT_TYPE);
		}
}
 
開發者ID:mrange,項目名稱:fsharpadvent2016,代碼行數:20,代碼來源:Compiler.java

示例4: 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();
}
 
開發者ID:mikroskeem,項目名稱:Shuriken,代碼行數:46,代碼來源:MethodGenerator.java


注:本文中的org.objectweb.asm.commons.GeneratorAdapter.putField方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。