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


Java GeneratorAdapter.invokeStatic方法代碼示例

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


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

示例1: visitEnd

import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
public void visitEnd() {
	if (!done && found) {
		done = true;
		try {
			GeneratorAdapter mg = new GeneratorAdapter(Opcodes.ACC_PRIVATE | Opcodes.ACC_STATIC, new Method(LOG_INTERNAL_METHOD, LOG_METHOD_SIGNATURE), LOG_METHOD_SIGNATURE, new Type[] {}, this);

			Label start = mg.mark();
			mg.invokeStatic(LOG_INTERNAL_TYPE, Method.getMethod(LOG_INTERNAL_CLASS.getMethod(LOG_METHOD_NAME)));
			mg.returnValue();
			Label end   = mg.mark();
			mg.catchException(start, end, JAVA_LANG_THROWABLE_TYPE);
			mg.returnValue();
			
			mg.endMethod();
		} catch (NoSuchMethodException nsme) {
			System.err.println("Unable to find Agent.rlogCallChain method");
			System.err.println("M:"+nsme);
			nsme.printStackTrace();
		}
	}
	
	super.visitEnd();
}
 
開發者ID:RuiChen08,項目名稱:dacapobench,代碼行數:25,代碼來源:CallChainInstrument.java

示例2: visitEnd

import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
public void visitEnd() {
	if (!foundClinit && instrument()) {
		// didn't find <clinit> so lets make one
		try {
			GeneratorAdapter mg = new GeneratorAdapter(Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC, new Method(CLINIT_NAME, CLINIT_SIGNATURE), CLINIT_SIGNATURE, new Type[] {}, this);
			
			Label start = mg.mark();
			mg.push(className);
			mg.invokeStatic(LOG_INTERNAL_TYPE, Method.getMethod(LOG_INTERNAL_CLASS.getMethod(LOG_METHOD_NAME, String.class)));
			Label end   = mg.mark();
			mg.returnValue();
			
			mg.catchException(start, end, JAVA_LANG_THROWABLE_TYPE);
			mg.returnValue();
			
			mg.endMethod();
		} catch (NoSuchMethodException nsme) {
			System.out.println("Unable to find Agent.reportClass method");
		}
	}
	
	super.visitEnd();
}
 
開發者ID:RuiChen08,項目名稱:dacapobench,代碼行數:25,代碼來源:ClinitInstrument.java

示例3: establishCallback

import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
public static void establishCallback(ClassNode cn, MethodNode mn) {
    if (!mn.desc.startsWith("()")) {
        MethodNode blank = new MethodNode();
        Method method = new Method(mn.name, mn.desc);
        GeneratorAdapter adapter = new GeneratorAdapter(mn.access, method, blank);
        adapter.visitCode();
        adapter.push(cn.name + "." + mn.name + "  " + mn.desc);
        adapter.loadArgArray();
        adapter.invokeStatic(Type.getType(CallFactory.class), new Method("testInvoke",
                "(Ljava/lang/String;[Ljava/lang/Object;)V"));
        for (AbstractInsnNode ain : mn.instructions.toArray()) {
            if (ain instanceof VarInsnNode) {
                mn.instructions.insertBefore(ain, blank.instructions);
                return;
            }
        }
    }
}
 
開發者ID:disassemble-io,項目名稱:agent-callback,代碼行數:19,代碼來源:CallFactory.java

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

示例5: 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:skejserjensen,項目名稱:eclojure,代碼行數:24,代碼來源:Compiler.java

示例6: emit

import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
public void emit(C context, ObjExpr objx, GeneratorAdapter gen){
	boolean allKeysConstant = true;
	boolean allConstantKeysUnique = true;
	IPersistentSet constantKeys = PersistentHashSet.EMPTY;
	for(int i = 0; i < keyvals.count(); i+=2)
		{
		Expr k = (Expr) keyvals.nth(i);
		if(k instanceof LiteralExpr)
			{
			Object kval = k.eval();
			if (constantKeys.contains(kval))
				allConstantKeysUnique = false;
			else
				constantKeys = (IPersistentSet)constantKeys.cons(kval);
			}
		else
			allKeysConstant = false;
		}
	MethodExpr.emitArgsAsArray(keyvals, objx, gen);
	if((allKeysConstant && allConstantKeysUnique) || (keyvals.count() <= 2))
		gen.invokeStatic(RT_TYPE, mapUniqueKeysMethod);
	else
		gen.invokeStatic(RT_TYPE, mapMethod);
	if(context == C.STATEMENT)
		gen.pop();
}
 
開發者ID:mrange,項目名稱:fsharpadvent2016,代碼行數:27,代碼來源:Compiler.java

示例7: emitUnboxed

import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
public void emitUnboxed(C context, ObjExpr objx, GeneratorAdapter gen){
	Method ms = new Method("invokeStatic", getReturnType(), paramtypes);
	if(variadic)
		{
		for(int i = 0; i < paramclasses.length - 1; i++)
			{
			Expr e = (Expr) args.nth(i);
			if(maybePrimitiveType(e) == paramclasses[i])
				{
				((MaybePrimitiveExpr) e).emitUnboxed(C.EXPRESSION, objx, gen);
				}
			else
				{
				e.emit(C.EXPRESSION, objx, gen);
				HostExpr.emitUnboxArg(objx, gen, paramclasses[i]);
				}
			}
		IPersistentVector restArgs = RT.subvec(args,paramclasses.length - 1,args.count());
		MethodExpr.emitArgsAsArray(restArgs,objx,gen);
		gen.invokeStatic(Type.getType(ArraySeq.class), Method.getMethod("clojure.lang.ArraySeq create(Object[])"));
		}
	else
		MethodExpr.emitTypedArgs(objx, gen, paramclasses, args);

	gen.invokeStatic(target, ms);
}
 
開發者ID:mrange,項目名稱:fsharpadvent2016,代碼行數:27,代碼來源:Compiler.java

示例8: trace

import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
protected static void trace( GeneratorAdapter mv, int argsNumber) {
    StringBuilder methodSignature = new StringBuilder("void trace(String");
    for (int i = 0; i < argsNumber - 1; i++) {
        methodSignature.append(", String");
    }
    methodSignature.append(")");
    mv.invokeStatic(Type.getObjectType(PACKAGE + "/AndroidInstantRuntime"),
            Method.getMethod(methodSignature.toString()));
}
 
開發者ID:meili,項目名稱:Aceso,代碼行數:10,代碼來源:IncrementalVisitor.java

示例9: trace

import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
protected static void trace(GeneratorAdapter mv, String s1,
                            String s2, String s3) {
    mv.push(s1);
    mv.push(s2);
    mv.push(s3);
    mv.invokeStatic(Type.getType(PACKAGE + ".AndroidInstantRuntime"),
            Method.getMethod("void trace(String, String, String)"));
}
 
開發者ID:dodola,項目名稱:AnoleFix,代碼行數:9,代碼來源:IncrementalVisitor.java

示例10: emitThenForHashes

import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
private void emitThenForHashes(ObjExpr objx, GeneratorAdapter gen, Expr test, Expr then, Label defaultLabel, boolean emitUnboxed){
    expr.emit(C.EXPRESSION, objx, gen);
    test.emit(C.EXPRESSION, objx, gen);
    if(testType == hashIdentityKey)
        {
        gen.visitJumpInsn(IF_ACMPNE, defaultLabel);
        }
    else
        {
        gen.invokeStatic(UTIL_TYPE, equivMethod);
        gen.ifZCmp(GeneratorAdapter.EQ, defaultLabel);
        }
    emitExpr(objx, gen, then, emitUnboxed);
}
 
開發者ID:mrange,項目名稱:fsharpadvent2016,代碼行數:15,代碼來源:Compiler.java

示例11: emitThenForInts

import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
private void emitThenForInts(ObjExpr objx, GeneratorAdapter gen, Type exprType, Expr test, Expr then, Label defaultLabel, boolean emitUnboxed){
    if (exprType == null)
        {
        expr.emit(C.EXPRESSION, objx, gen);
        test.emit(C.EXPRESSION, objx, gen);
        gen.invokeStatic(UTIL_TYPE, equivMethod);
        gen.ifZCmp(GeneratorAdapter.EQ, defaultLabel);
        emitExpr(objx, gen, then, emitUnboxed);
        }
    else if (exprType == Type.LONG_TYPE)
        {
        ((NumberExpr)test).emitUnboxed(C.EXPRESSION, objx, gen);
        expr.emitUnboxed(C.EXPRESSION, objx, gen);
        gen.ifCmp(Type.LONG_TYPE, GeneratorAdapter.NE, defaultLabel);
        emitExpr(objx, gen, then, emitUnboxed);
        }
    else if (exprType == Type.INT_TYPE
            || exprType == Type.SHORT_TYPE
            || exprType == Type.BYTE_TYPE)
        {
        if (isShiftMasked())
            {
            ((NumberExpr)test).emitUnboxed(C.EXPRESSION, objx, gen);
            expr.emitUnboxed(C.EXPRESSION, objx, gen);
            gen.cast(exprType, Type.LONG_TYPE);
            gen.ifCmp(Type.LONG_TYPE, GeneratorAdapter.NE, defaultLabel);
            }
        // else direct match
        emitExpr(objx, gen, then, emitUnboxed);
        }
    else
        {
        gen.goTo(defaultLabel);
        }
}
 
開發者ID:skejserjensen,項目名稱:eclojure,代碼行數:36,代碼來源:Compiler.java

示例12: emitExprForHashes

import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
private void emitExprForHashes(ObjExpr objx, GeneratorAdapter gen){
    expr.emit(C.EXPRESSION, objx, gen);
    gen.invokeStatic(UTIL_TYPE,hashMethod);
    emitShiftMask(gen);
}
 
開發者ID:skejserjensen,項目名稱:eclojure,代碼行數:6,代碼來源:Compiler.java

示例13: emitUnboxArg

import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
public static void emitUnboxArg(ObjExpr objx, GeneratorAdapter gen, Class paramType){
		if(paramType.isPrimitive())
			{
			if(paramType == boolean.class)
				{
				gen.checkCast(BOOLEAN_TYPE);
				gen.invokeVirtual(BOOLEAN_TYPE, booleanValueMethod);
//				Label falseLabel = gen.newLabel();
//				Label endLabel = gen.newLabel();
//				gen.ifNull(falseLabel);
//				gen.push(1);
//				gen.goTo(endLabel);
//				gen.mark(falseLabel);
//				gen.push(0);
//				gen.mark(endLabel);
				}
			else if(paramType == char.class)
				{
				gen.checkCast(CHAR_TYPE);
				gen.invokeVirtual(CHAR_TYPE, charValueMethod);
				}
			else
				{
//				System.out.println("NOT fnexpr for defn var: " + var + "init: " + init.getClass());
				Method m = null;
				gen.checkCast(NUMBER_TYPE);
				if(RT.booleanCast(RT.UNCHECKED_MATH.deref()))
					{
					if(paramType == int.class)
						m = Method.getMethod("int uncheckedIntCast(Object)");
					else if(paramType == float.class)
						m = Method.getMethod("float uncheckedFloatCast(Object)");
					else if(paramType == double.class)
						m = Method.getMethod("double uncheckedDoubleCast(Object)");
					else if(paramType == long.class)
						m = Method.getMethod("long uncheckedLongCast(Object)");
					else if(paramType == byte.class)
						m = Method.getMethod("byte uncheckedByteCast(Object)");
					else if(paramType == short.class)
						m = Method.getMethod("short uncheckedShortCast(Object)");					
					}
				else
					{
					if(paramType == int.class)
						m = Method.getMethod("int intCast(Object)");
					else if(paramType == float.class)
						m = Method.getMethod("float floatCast(Object)");
					else if(paramType == double.class)
						m = Method.getMethod("double doubleCast(Object)");
					else if(paramType == long.class)
						m = Method.getMethod("long longCast(Object)");
					else if(paramType == byte.class)
						m = Method.getMethod("byte byteCast(Object)");
					else if(paramType == short.class)
						m = Method.getMethod("short shortCast(Object)");
					}
				gen.invokeStatic(RT_TYPE, m);
				}
			}
		else
			{
			gen.checkCast(Type.getType(paramType));
			}
	}
 
開發者ID:mrange,項目名稱:fsharpadvent2016,代碼行數:65,代碼來源:Compiler.java

示例14: emitBoxReturn

import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
public static void emitBoxReturn(ObjExpr objx, GeneratorAdapter gen, Class returnType){
		if(returnType.isPrimitive())
			{
			if(returnType == boolean.class)
				{
				Label falseLabel = gen.newLabel();
				Label endLabel = gen.newLabel();
				gen.ifZCmp(GeneratorAdapter.EQ, falseLabel);
				gen.getStatic(BOOLEAN_OBJECT_TYPE, "TRUE", BOOLEAN_OBJECT_TYPE);
				gen.goTo(endLabel);
				gen.mark(falseLabel);
				gen.getStatic(BOOLEAN_OBJECT_TYPE, "FALSE", BOOLEAN_OBJECT_TYPE);
//				NIL_EXPR.emit(C.EXPRESSION, fn, gen);
				gen.mark(endLabel);
				}
			else if(returnType == void.class)
				{
				NIL_EXPR.emit(C.EXPRESSION, objx, gen);
				}
			else if(returnType == char.class)
					{
					gen.invokeStatic(CHAR_TYPE, charValueOfMethod);
					}
				else
					{
					if(returnType == int.class)
						{
						gen.invokeStatic(INTEGER_TYPE, intValueOfMethod);
//						gen.visitInsn(I2L);
//						gen.invokeStatic(NUMBERS_TYPE, Method.getMethod("Number num(long)"));
						}
					else if(returnType == float.class)
						{
						gen.invokeStatic(FLOAT_TYPE, floatValueOfMethod);

//						gen.visitInsn(F2D);
//						gen.invokeStatic(DOUBLE_TYPE, doubleValueOfMethod);
						}
					else if(returnType == double.class)
							gen.invokeStatic(DOUBLE_TYPE, doubleValueOfMethod);
					else if(returnType == long.class)
							gen.invokeStatic(NUMBERS_TYPE, Method.getMethod("Number num(long)"));
					else if(returnType == byte.class)
							gen.invokeStatic(BYTE_TYPE, byteValueOfMethod);
					else if(returnType == short.class)
							gen.invokeStatic(SHORT_TYPE, shortValueOfMethod);
					}
			}
	}
 
開發者ID:skejserjensen,項目名稱:eclojure,代碼行數:50,代碼來源:Compiler.java

示例15: emitBody

import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
static void emitBody(ObjExpr objx, GeneratorAdapter gen, Class retClass, Expr body) {
		MaybePrimitiveExpr be = (MaybePrimitiveExpr) body;
		if(Util.isPrimitive(retClass) && be.canEmitPrimitive())
			{
			Class bc = maybePrimitiveType(be);
			if(bc == retClass)
				be.emitUnboxed(C.RETURN, objx, gen);
			else if(retClass == long.class && bc == int.class)
				{
				be.emitUnboxed(C.RETURN, objx, gen);
				gen.visitInsn(I2L);
				}
			else if(retClass == double.class && bc == float.class)
				{
				be.emitUnboxed(C.RETURN, objx, gen);
				gen.visitInsn(F2D);
				}
			else if(retClass == int.class && bc == long.class)
				{
				be.emitUnboxed(C.RETURN, objx, gen);
				gen.invokeStatic(RT_TYPE, Method.getMethod("int intCast(long)"));
				}
			else if(retClass == float.class && bc == double.class)
				{
				be.emitUnboxed(C.RETURN, objx, gen);
				gen.visitInsn(D2F);
				}
			else
				throw new IllegalArgumentException("Mismatched primitive return, expected: "
				                                   + retClass + ", had: " + be.getJavaClass());
			}
		else
			{
			body.emit(C.RETURN, objx, gen);
			if(retClass == void.class)
				{
				gen.pop();
				}
			else
				gen.unbox(Type.getType(retClass));
			}
}
 
開發者ID:skejserjensen,項目名稱:eclojure,代碼行數:43,代碼來源:Compiler.java


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