当前位置: 首页>>代码示例>>Java>>正文


Java GeneratorAdapter.invokeInterface方法代码示例

本文整理汇总了Java中org.objectweb.asm.commons.GeneratorAdapter.invokeInterface方法的典型用法代码示例。如果您正苦于以下问题:Java GeneratorAdapter.invokeInterface方法的具体用法?Java GeneratorAdapter.invokeInterface怎么用?Java GeneratorAdapter.invokeInterface使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.objectweb.asm.commons.GeneratorAdapter的用法示例。


在下文中一共展示了GeneratorAdapter.invokeInterface方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: emitArgsAndCall

import org.objectweb.asm.commons.GeneratorAdapter; //导入方法依赖的package包/类
void emitArgsAndCall(int firstArgToEmit, C context, ObjExpr objx, GeneratorAdapter gen){
	for(int i = firstArgToEmit; i < Math.min(MAX_POSITIONAL_ARITY, args.count()); i++)
		{
		Expr e = (Expr) args.nth(i);
		e.emit(C.EXPRESSION, objx, gen);
		}
	if(args.count() > MAX_POSITIONAL_ARITY)
		{
		PersistentVector restArgs = PersistentVector.EMPTY;
		for(int i = MAX_POSITIONAL_ARITY; i < args.count(); i++)
			{
			restArgs = restArgs.cons(args.nth(i));
			}
		MethodExpr.emitArgsAsArray(restArgs, objx, gen);
		}
	gen.visitLineNumber(line, gen.mark());

	if(context == C.RETURN)
		{
		ObjMethod method = (ObjMethod) METHOD.deref();
		method.emitClearLocals(gen);
		}

	gen.invokeInterface(IFN_TYPE, new Method("invoke", OBJECT_TYPE, ARG_TYPES[Math.min(MAX_POSITIONAL_ARITY + 1,
	                                                                                   args.count())]));
}
 
开发者ID:mrange,项目名称:fsharpadvent2016,代码行数:27,代码来源:Compiler.java

示例2: doRedirect

import org.objectweb.asm.commons.GeneratorAdapter; //导入方法依赖的package包/类
@Override
protected void doRedirect( GeneratorAdapter mv, int change) {
    mv.loadLocal(change);
    mv.push(AcesoProguardMap.instance().getMtdIndex(visitedClassName, IncrementalTool.getMtdSig(mtdName,mtdDesc)));
    ByteCodeUtils.newVariableArray(mv, ByteCodeUtils.toLocalVariables(types));

    // now invoke the generic dispatch method.
    mv.invokeInterface(IncrementalVisitor.CHANGE_TYPE, Method.getMethod("Object access$dispatch(int, Object[])"));
}
 
开发者ID:meili,项目名称:Aceso,代码行数:10,代码来源:MethodRedirection.java

示例3: redirect

import org.objectweb.asm.commons.GeneratorAdapter; //导入方法依赖的package包/类
/**
 * Adds the instructions to do a generic redirection.
 * <p/>
 * Note that the generated bytecode does not have a direct translation to code, but as an
 * example, the following code block gets inserted.
 * <code>
 * if ($change != null) {
 * $change.access$dispatch($name, new object[] { arg0, ... argsN })
 * $anyCodeInsertedbyRestore
 * }
 * $originalMethodBody
 * </code>
 *
 * @param mv     the method visitor to add the instructions to.
 * @param change the local variable containing the alternate implementation.
 * @param args   the type of the local variable that need to be forwarded.
 */
void redirect(GeneratorAdapter mv, int change, List<Type> args) {
    // code to check if a new implementation of the current class is available.
    Label l0 = new Label();
    mv.loadLocal(change);
    mv.visitJumpInsn(Opcodes.IFNULL, l0);
    mv.loadLocal(change);
    mv.push(name);

    // create an array of objects capable of containing all the parameters and optionally the "this"
    createLocals(mv, args);

    // we need to maintain the stack index when loading parameters from, as for long and double
    // values, it uses 2 stack elements, all others use only 1 stack element.
    int stackIndex = 0;
    for (int arrayIndex = 0; arrayIndex < args.size(); arrayIndex++) {
        Type arg = args.get(arrayIndex);
        // duplicate the array of objects reference, it will be used to store the value in.
        mv.dup();
        // index in the array of objects to store the boxed parameter.
        mv.push(arrayIndex);
        // Pushes the appropriate local variable on the stack
        redirectLocal(mv, stackIndex, arg);
        // potentially box up intrinsic types.
        mv.box(arg);
        mv.arrayStore(Type.getType(Object.class));
        // stack index must progress according to the parameter type we just processed.
        stackIndex += arg.getSize();
    }

    // now invoke the generic dispatch method.
    mv.invokeInterface(IncrementalVisitor.CHANGE_TYPE, Method.getMethod("Object access$dispatch(String, Object[])"));

    // Restore the state after the redirection
    restore(mv, args);
    // jump label for classes without any new implementation, just invoke the original
    // method implementation.
    mv.visitLabel(l0);
}
 
开发者ID:dodola,项目名称:AnoleFix,代码行数:56,代码来源:Redirection.java

示例4: emit

import org.objectweb.asm.commons.GeneratorAdapter; //导入方法依赖的package包/类
public void emit(C context, ObjExpr objx, GeneratorAdapter gen){
	expr.emit(C.EXPRESSION, objx, gen);
	gen.checkCast(IOBJ_TYPE);
	meta.emit(C.EXPRESSION, objx, gen);
	gen.checkCast(IPERSISTENTMAP_TYPE);
	gen.invokeInterface(IOBJ_TYPE, withMetaMethod);
	if(context == C.STATEMENT)
		{
		gen.pop();
		}
}
 
开发者ID:mrange,项目名称:fsharpadvent2016,代码行数:12,代码来源:Compiler.java

示例5: emitMethods

import org.objectweb.asm.commons.GeneratorAdapter; //导入方法依赖的package包/类
protected void emitMethods(ClassVisitor cv){
	for(ISeq s = RT.seq(methods); s != null; s = s.next())
		{
		ObjMethod method = (ObjMethod) s.first();
		method.emit(this, cv);
		}
	//emit bridge methods
	for(Map.Entry<IPersistentVector,Set<Class>> e : covariants.entrySet())
		{
		java.lang.reflect.Method m = mmap.get(e.getKey());
		Class[] params = m.getParameterTypes();
		Type[] argTypes = new Type[params.length];

		for(int i = 0; i < params.length; i++)
			{
			argTypes[i] = Type.getType(params[i]);
			}

		Method target = new Method(m.getName(), Type.getType(m.getReturnType()), argTypes);

		for(Class retType : e.getValue())
			{
		        Method meth = new Method(m.getName(), Type.getType(retType), argTypes);

			GeneratorAdapter gen = new GeneratorAdapter(ACC_PUBLIC + ACC_BRIDGE,
	                                            meth,
	                                            null,
	                                            //todo don't hardwire this
	                                            EXCEPTION_TYPES,
	                                            cv);
			gen.visitCode();
			gen.loadThis();
			gen.loadArgs();
			gen.invokeInterface(Type.getType(m.getDeclaringClass()),target);
			gen.returnValue();
			gen.endMethod();
			}
		}
}
 
开发者ID:mrange,项目名称:fsharpadvent2016,代码行数:40,代码来源:Compiler.java

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

示例7: 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.invokeInterface方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。