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


Java GeneratorAdapter.invokeVirtual方法代碼示例

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


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

示例1: visitx

import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
private void visitx(GeneratorAdapter mv, List<String> strings) {
    if (strings.size() == 1) {
        visitCase(strings.get(0));
        return;
    }
    for (String string : strings) {
        Label label = new Label();
        visitString();
        mv.visitLdcInsn(string);
        mv.invokeVirtual(STRING_TYPE, Method.getMethod("boolean equals(Object)"));
        mv.visitJumpInsn(Opcodes.IFEQ, label);
        visitCase(string);
        mv.visitLabel(label);
    }

    visitDefault();
}
 
開發者ID:meili,項目名稱:Aceso,代碼行數:18,代碼來源:IntSwitch.java

示例2: visitx

import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
/**
 * Emit code for a string if-else block.
 *
 *     if (s.equals("collided_method1")) {
 *         visit(s);
 *     } else if (s.equals("collided_method2")) {
 *         visit(s);
 *     }
 *
 * In the most common case of just one string, this degenerates to:
 *
 *      visit(s)
 *
 */
private void visitx(GeneratorAdapter mv, List<String> strings) {
    if (strings.size() == 1) {
        visitCase(strings.get(0));
        return;
    }
    for (int i = 0; i < strings.size(); ++i) {
        String string = strings.get(i);
        Label label = new Label();
        visitString();
        mv.visitLdcInsn(string);
        mv.invokeVirtual(STRING_TYPE, Method.getMethod("boolean equals(Object)"));
        mv.visitJumpInsn(Opcodes.IFEQ, label);
        visitCase(string);
        mv.visitLabel(label);
    }

    visitDefault();
}
 
開發者ID:dodola,項目名稱:AnoleFix,代碼行數:33,代碼來源:StringSwitch.java

示例3: unbox

import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
/**
 * Generates unboxing bytecode for the passed type. An {@link Object} is expected to be on the
 * stack when these bytecodes are inserted.
 *
 * ASM takes a short cut when dealing with short/byte types and convert them into int rather
 * than short/byte types. This is not an issue on the jvm nor Android's ART but it is an issue
 * on Dalvik.
 *
 * @param mv the {@link GeneratorAdapter} generating a method implementation.
 * @param type the expected un-boxed type.
 */
public static void unbox(GeneratorAdapter mv, Type type) {
    if (type.equals(Type.SHORT_TYPE)) {
        mv.checkCast(NUMBER_TYPE);
        mv.invokeVirtual(NUMBER_TYPE, SHORT_VALUE);
    } else if (type.equals(Type.BYTE_TYPE)) {
        mv.checkCast(NUMBER_TYPE);
        mv.invokeVirtual(NUMBER_TYPE, BYTE_VALUE);
    } else {
        mv.unbox(type);
    }
}
 
開發者ID:Idtk,項目名稱:Hotfix,代碼行數:23,代碼來源:ByteCodeUtils.java

示例4: emitAssign

import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
public void emitAssign(C context, ObjExpr objx, GeneratorAdapter gen,
                       Expr val){
	objx.emitVar(gen, var);
	val.emit(C.EXPRESSION, objx, gen);
	gen.invokeVirtual(VAR_TYPE, setMethod);
	if(context == C.STATEMENT)
		gen.pop();
}
 
開發者ID:mrange,項目名稱:fsharpadvent2016,代碼行數:9,代碼來源:Compiler.java

示例5: emit

import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
public void emit(C context, ObjExpr objx, GeneratorAdapter gen){
	gen.getStatic(RT_TYPE,"CURRENT_NS",VAR_TYPE);
	gen.invokeVirtual(VAR_TYPE, derefMethod);
	gen.checkCast(NS_TYPE);
	gen.push(c);
	gen.invokeStatic(RT_TYPE, forNameMethod);
	gen.invokeVirtual(NS_TYPE, importClassMethod);
	if(context == C.STATEMENT)
		gen.pop();
}
 
開發者ID:mrange,項目名稱:fsharpadvent2016,代碼行數:11,代碼來源:Compiler.java

示例6: emitVarValue

import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
public void emitVarValue(GeneratorAdapter gen, Var v){
	Integer i = (Integer) vars.valAt(v);
	if(!v.isDynamic())
		{
		emitConstant(gen, i);
		gen.invokeVirtual(VAR_TYPE, varGetRawMethod);
		}
	else
		{
		emitConstant(gen, i);
		gen.invokeVirtual(VAR_TYPE, varGetMethod);
		}
}
 
開發者ID:mrange,項目名稱:fsharpadvent2016,代碼行數:14,代碼來源:Compiler.java

示例7: emitExprForInts

import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
private void emitExprForInts(ObjExpr objx, GeneratorAdapter gen, Type exprType, Label defaultLabel){
    if (exprType == null)
        {
        if(RT.booleanCast(RT.WARN_ON_REFLECTION.deref()))
            {
            RT.errPrintWriter()
              .format("Performance warning, %s:%d:%d - case has int tests, but tested expression is not primitive.\n",
                      SOURCE_PATH.deref(), line, column);
            }
        expr.emit(C.EXPRESSION, objx, gen);
        gen.instanceOf(NUMBER_TYPE);
        gen.ifZCmp(GeneratorAdapter.EQ, defaultLabel);
        expr.emit(C.EXPRESSION, objx, gen);
        gen.checkCast(NUMBER_TYPE);
        gen.invokeVirtual(NUMBER_TYPE, intValueMethod);
        emitShiftMask(gen);
        }
    else if (exprType == Type.LONG_TYPE
            || exprType == Type.INT_TYPE
            || exprType == Type.SHORT_TYPE
            || exprType == Type.BYTE_TYPE)
        {
        expr.emitUnboxed(C.EXPRESSION, objx, gen);
        gen.cast(exprType, Type.INT_TYPE);
        emitShiftMask(gen);
        }
    else
        {
        gen.goTo(defaultLabel);
        }
}
 
開發者ID:mrange,項目名稱:fsharpadvent2016,代碼行數:32,代碼來源:Compiler.java

示例8: visitHashMethod

import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
void visitHashMethod(GeneratorAdapter mv) {
    mv.invokeVirtual(STRING_TYPE, Method.getMethod("int hashCode()"));
}
 
開發者ID:dodola,項目名稱:AnoleFix,代碼行數:4,代碼來源:StringSwitch.java

示例9: transform

import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
@Override
@Unsafe(Unsafe.ASM_API)
public byte[] transform(String name, String transformedName, byte[] basicClass) {
	String srgName = this.srgName;
	if (!AlchemyEngine.isRuntimeDeobfuscationEnabled())
		srgName = DeobfuscatingRemapper.instance().mapMethodName(transformedName, this.srgName, desc);
	AlchemyTransformerManager.transform("<proxy>" + name + "|" + transformedName + "#" + proxyMethod.name + proxyMethod.signature
			+ "\n->  " + target + "#" + srgName + desc);
	ClassReader reader = new ClassReader(basicClass);
	ClassWriter writer = ASMHelper.newClassWriter(ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES);
	ClassNode node = new ClassNode(ASM5);
	reader.accept(node, 0);
	MethodNode oldMethod = null, newMethod = new MethodNode(proxyMethod.access, proxyMethod.name, proxyMethod.desc, proxyMethod.signature,
			proxyMethod.exceptions.toArray(new String[proxyMethod.exceptions.size()]));
	for (MethodNode method : node.methods)
		if (method.name.equals(proxyMethod.name) && method.desc.equals(proxyMethod.desc)) {
			oldMethod = method;
			GeneratorAdapter adapter = new GeneratorAdapter(newMethod, method.access, method.name, method.desc);
			Type owner = Type.getType(ASMHelper.getClassDesc(target));
			Method targetMethod = new Method(srgName, desc);
			switch (opcode) {
				case INVOKESTATIC:
					adapter.loadArgs();
					adapter.invokeStatic(owner, targetMethod);
					break;
				case INVOKEVIRTUAL:
					adapter.loadArgs();
					adapter.invokeVirtual(owner, targetMethod);
					break;
				case INVOKESPECIAL:
					adapter.invokeStatic(Type.getType(AlchemyEngine.class), new Method("lookup",
							"()Ljava/lang/invoke/MethodHandles$Lookup;"));
					adapter.push(srgName);
					Type args[] = Type.getArgumentTypes(desc);
					adapter.visitFieldInsn(GETSTATIC, "java/lang/Void", "TYPE", "Ljava/lang/Class;");
					adapter.push(args.length);
					adapter.newArray(Type.getType(Class.class));
					for (Type arg : args) {
						adapter.dup();
						adapter.push(arg);
						adapter.arrayStore(Type.getType(Class.class));
					}
					adapter.invokeStatic(Type.getType(MethodType.class), new Method("methodType",
							"(Ljava/lang/Class;[Ljava/lang/Class;)Ljava/lang/invoke/MethodType;"));
					adapter.push(owner);
					adapter.dupX2();
					adapter.invokeVirtual(Type.getType(MethodHandles.Lookup.class), new Method("findSpecial",
							"(Ljava/lang/Class;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/Class;)Ljava/lang/invoke/MethodHandle;"));
					adapter.loadArgs();
					adapter.invokeVirtual(Type.getType(MethodHandle.class), new Method("invoke", proxyMethod.desc));
					break;
				case INVOKEINTERFACE:
					adapter.loadArgs();
					adapter.invokeInterface(owner, targetMethod);
					break;
				default:
					AlchemyRuntimeException.onException(new RuntimeException("Unsupported opcode: " + opcode));
			}
			adapter.returnValue();
			adapter.endMethod();
			break;
		}
	node.methods.remove(oldMethod);
	node.methods.add(newMethod);
	node.accept(writer);
	return writer.toByteArray();
}
 
開發者ID:NekoCaffeine,項目名稱:Alchemy,代碼行數:68,代碼來源:TransformerProxy.java

示例10: 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

示例11: 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.invokeVirtual方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。