List of usage examples for org.objectweb.asm.commons Method Method
public Method(final String name, final Type returnType, final Type[] argumentTypes)
From source file:com.google.code.nanorm.internal.introspect.asm.MapperBuilder.java
License:Apache License
/** * Generate mapper method.// ww w . j av a2 s . c om * * @param owner self type * @param cw class writer * @param config method configuration */ private static void visitMethod(Type owner, ClassWriter cw, MethodConfig config) { java.lang.reflect.Method ifaceMethod = config.getMethod(); Type returnType = Type.getType(ifaceMethod.getReturnType()); Type[] args = new Type[ifaceMethod.getParameterTypes().length]; for (int i = 0; i < args.length; ++i) { args[i] = Type.getType(ifaceMethod.getParameterTypes()[i]); } Method method = new Method(ifaceMethod.getName(), returnType, args); GeneratorAdapter mg = new GeneratorAdapter(Opcodes.ACC_PUBLIC, method, null, null, cw); // Factory mg.loadThis(); mg.getField(owner, "delegate", QUERY_DELEGATE_TYPE); // Statement config mg.loadThis(); mg.getField(owner, "configs", STATEMENT_CONFIGS_ARR_TYPE); mg.push(config.getIndex()); mg.arrayLoad(Type.getType(StatementConfig.class)); // Arguments mg.loadArgArray(); mg.invokeInterface(QUERY_DELEGATE_TYPE, QUERY_METHOD); mg.unbox(returnType); mg.returnValue(); mg.endMethod(); // Copy the annotations copyAnnotations(ifaceMethod, null, mg); }
From source file:com.google.template.soy.jbcsrc.ConstructorRef.java
License:Apache License
/** * Returns a new {@link ConstructorRef} that refers to a constructor on the given type with the * given parameter types.//from www . j av a 2s .c o m */ static ConstructorRef create(TypeInfo type, Iterable<Type> argTypes) { return create(type, new Method("<init>", Type.VOID_TYPE, Iterables.toArray(argTypes, Type.class))); }
From source file:com.google.template.soy.jbcsrc.restricted.ConstructorRef.java
License:Apache License
/** * Returns a new {@link ConstructorRef} that refers to a constructor on the given type with the * given parameter types./* ww w. ja v a 2 s.c om*/ */ public static ConstructorRef create(TypeInfo type, Iterable<Type> argTypes) { return create(type, new Method("<init>", Type.VOID_TYPE, Iterables.toArray(argTypes, Type.class))); }
From source file:com.navercorp.pinpoint.profiler.instrument.ASMMethodVariables.java
License:Apache License
void box(final InsnList instructions, Type type) { if (type.getSort() == Type.OBJECT || type.getSort() == Type.ARRAY) { return;/*from w w w . j a va2 s . c om*/ } if (type == Type.VOID_TYPE) { // push null instructions.add(new InsnNode(Opcodes.ACONST_NULL)); } else { Type boxed = getBoxedType(type); // new instance. newInstance(instructions, boxed); if (type.getSize() == 2) { // Pp -> Ppo -> oPpo -> ooPpo -> ooPp -> o // dupX2 dupX2(instructions); // dupX2 dupX2(instructions); // pop pop(instructions); } else { // p -> po -> opo -> oop -> o // dupX1 dupX1(instructions); // swap swap(instructions); } invokeConstructor(instructions, boxed, new Method("<init>", Type.VOID_TYPE, new Type[] { type })); } }
From source file:com.xruby.compiler.codegen.CgUtil.java
License:BSD License
public static Method getMethod(String method, Type returnType) { return new Method(method, returnType, Types.NULL_TYPE_ARRAY); }
From source file:com.xruby.compiler.codegen.CgUtil.java
License:BSD License
public static Method getMethod(String method, Type returnType, Type... params) { return new Method(method, returnType, params); }
From source file:com.xruby.compiler.codegen.CgUtil.java
License:BSD License
public static Method getMethod(String method, Class returnType, Class... params) { Type[] types = new Type[params.length]; for (int i = 0; i < params.length; i++) { types[i] = Type.getType(params[i]); }/*from www .jav a 2 s. c o m*/ return new Method(method, Type.getType(returnType), types); }
From source file:erjang.beam.BuiltInFunction.java
License:Apache License
/** * @param m//from w w w . j a v a 2 s.co m */ public BuiltInFunction(java.lang.reflect.Method m) { this.javaMethod = m; this.owner = Type.getType(m.getDeclaringClass()); this.method = new Method(m.getName(), Type.getType(m.getReturnType()), Type.getArgumentTypes(m)); isVirtual = !Modifier.isStatic(m.getModifiers()); boolean p = false; for (Class c : m.getExceptionTypes()) { if (Pausable.class.equals(c)) { p = true; break; } } isPausable = p; }
From source file:io.datakernel.codegen.AsmBuilder.java
License:Apache License
/** * Creates a new method for a dynamic class * * @param methodName name of method//ww w .ja v a2 s . com * @param returnClass type which returns this method * @param argumentTypes list of types of arguments * @param expression function which will be processed * @return changed AsmFunctionFactory */ public AsmBuilder<T> method(String methodName, Class<?> returnClass, List<? extends Class<?>> argumentTypes, Expression expression) { Type[] types = new Type[argumentTypes.size()]; for (int i = 0; i < argumentTypes.size(); i++) { types[i] = getType(argumentTypes.get(i)); } return method(new Method(methodName, getType(returnClass), types), expression); }
From source file:io.datakernel.codegen.AsmBuilder.java
License:Apache License
/** * Create a new static method for a dynamic class * /*from w w w .j a va 2 s . c o m*/ * @param methodName name of method * @param returnClass type which returns this method * @param argumentTypes list of types of arguments * @param expression function which will be processed * @return changed AsmFunctionFactory */ public AsmBuilder<T> staticMethod(String methodName, Class<?> returnClass, List<? extends Class<?>> argumentTypes, Expression expression) { Type[] types = new Type[argumentTypes.size()]; for (int i = 0; i < argumentTypes.size(); i++) { types[i] = getType(argumentTypes.get(i)); } return staticMethod(new Method(methodName, getType(returnClass), types), expression); }