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


Java GeneratorAdapter.swap方法代碼示例

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


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

示例1: emit

import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
public void emit(C context, ObjExpr objx, GeneratorAdapter gen){
    Label endLabel = gen.newLabel();
    Label faultLabel = gen.newLabel();

    gen.visitLineNumber(line, gen.mark());
    gen.getStatic(objx.objtype, objx.thunkNameStatic(siteIndex),ObjExpr.ILOOKUP_THUNK_TYPE);
    gen.dup();  //thunk, thunk
    target.emit(C.EXPRESSION, objx, gen); //thunk,thunk,target
    gen.visitLineNumber(line, gen.mark());
    gen.dupX2();                          //target,thunk,thunk,target
    gen.invokeInterface(ObjExpr.ILOOKUP_THUNK_TYPE, Method.getMethod("Object get(Object)")); //target,thunk,result
    gen.dupX2();                          //result,target,thunk,result
    gen.visitJumpInsn(IF_ACMPEQ, faultLabel); //result,target
    gen.pop();                                //result
    gen.goTo(endLabel);

    gen.mark(faultLabel);    //result,target
    gen.swap();              //target,result
    gen.pop();               //target
 gen.dup();               //target,target
    gen.getStatic(objx.objtype, objx.siteNameStatic(siteIndex),ObjExpr.KEYWORD_LOOKUPSITE_TYPE);  //target,target,site
    gen.swap();              //target,site,target
    gen.invokeInterface(ObjExpr.ILOOKUP_SITE_TYPE,
                        Method.getMethod("clojure.lang.ILookupThunk fault(Object)"));    //target,new-thunk
 gen.dup();   //target,new-thunk,new-thunk
 gen.putStatic(objx.objtype, objx.thunkNameStatic(siteIndex),ObjExpr.ILOOKUP_THUNK_TYPE);  //target,new-thunk
 gen.swap();              //new-thunk,target
 gen.invokeInterface(ObjExpr.ILOOKUP_THUNK_TYPE, Method.getMethod("Object get(Object)")); //result

    gen.mark(endLabel);
    if(context == C.STATEMENT)
        gen.pop();
}
 
開發者ID:mrange,項目名稱:fsharpadvent2016,代碼行數:34,代碼來源:Compiler.java

示例2: emitProto

import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
public void emitProto(C context, ObjExpr objx, GeneratorAdapter gen){
	Label onLabel = gen.newLabel();
	Label callLabel = gen.newLabel();
	Label endLabel = gen.newLabel();

	Var v = ((VarExpr)fexpr).var;

	Expr e = (Expr) args.nth(0);
	e.emit(C.EXPRESSION, objx, gen);
	gen.dup(); //target, target
	gen.invokeStatic(UTIL_TYPE,Method.getMethod("Class classOf(Object)")); //target,class
	gen.getStatic(objx.objtype, objx.cachedClassName(siteIndex),CLASS_TYPE); //target,class,cached-class
	gen.visitJumpInsn(IF_ACMPEQ, callLabel); //target
	if(protocolOn != null)
		{
		gen.dup(); //target, target			
		gen.instanceOf(Type.getType(protocolOn));
		gen.ifZCmp(GeneratorAdapter.NE, onLabel);
		}

	gen.dup(); //target, target
	gen.invokeStatic(UTIL_TYPE,Method.getMethod("Class classOf(Object)")); //target,class
	gen.putStatic(objx.objtype, objx.cachedClassName(siteIndex),CLASS_TYPE); //target

	gen.mark(callLabel); //target
	objx.emitVar(gen, v);
	gen.invokeVirtual(VAR_TYPE, Method.getMethod("Object getRawRoot()")); //target, proto-fn
	gen.swap();
	emitArgsAndCall(1, context,objx,gen);
	gen.goTo(endLabel);

	gen.mark(onLabel); //target
	if(protocolOn != null)
		{
		MethodExpr.emitTypedArgs(objx, gen, onMethod.getParameterTypes(), RT.subvec(args,1,args.count()));
		if(context == C.RETURN)
			{
			ObjMethod method = (ObjMethod) METHOD.deref();
			method.emitClearLocals(gen);
			}
		Method m = new Method(onMethod.getName(), Type.getReturnType(onMethod), Type.getArgumentTypes(onMethod));
		gen.invokeInterface(Type.getType(protocolOn), m);
		HostExpr.emitBoxReturn(objx, gen, onMethod.getReturnType());
		}
	gen.mark(endLabel);
}
 
開發者ID:mrange,項目名稱:fsharpadvent2016,代碼行數:47,代碼來源:Compiler.java


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