List of usage examples for org.objectweb.asm Opcodes INVOKEVIRTUAL
int INVOKEVIRTUAL
To view the source code for org.objectweb.asm Opcodes INVOKEVIRTUAL.
Click Source Link
From source file:com.asakusafw.dag.compiler.codegen.AsmUtil.java
License:Apache License
/** * Sets {@code null} to a {@code ValueOption}. * @param method the target method/*from www .j a v a 2 s . co m*/ */ public static void setNullOption(MethodVisitor method) { method.visitMethodInsn(Opcodes.INVOKEVIRTUAL, VALUE_OPTION_TYPE.getInternalName(), "setNull", Type.getMethodDescriptor(typeOf(VALUE_OPTION_TYPE)), false); }
From source file:com.asakusafw.dag.compiler.codegen.AsmUtil.java
License:Apache License
/** * Invokes {@code DataModel#reset()}./*w ww . j a va2s . c o m*/ * @param method the target method * @param dataType the data type */ public static void resetDataModel(MethodVisitor method, TypeDescription dataType) { method.visitMethodInsn(Opcodes.INVOKEVIRTUAL, typeOf(dataType).getInternalName(), "reset", Type.getMethodDescriptor(Type.VOID_TYPE), false); }
From source file:com.asakusafw.dag.compiler.codegen.AsmUtil.java
License:Apache License
/** * Invokes {@code DataModel#copyFrom(DataModel)}. * @param method the target method/*from w w w.java 2s. c o m*/ * @param dataType the data type */ public static void copyDataModel(MethodVisitor method, TypeDescription dataType) { method.visitMethodInsn(Opcodes.INVOKEVIRTUAL, typeOf(dataType).getInternalName(), "copyFrom", Type.getMethodDescriptor(Type.VOID_TYPE, typeOf(dataType)), false); }
From source file:com.asakusafw.dag.compiler.codegen.CoGroupInputAdapterGenerator.java
License:Apache License
/** * Generates {@link ExtractInputAdapter} class. * @param context the current context/*from w ww. j a v a 2s. c o m*/ * @param inputs the target output ports * @param target the target class * @return the generated class data */ public ClassData generate(ClassGeneratorContext context, List<Spec> inputs, ClassDescription target) { ClassWriter writer = AsmUtil.newWriter(target, CoGroupInputAdapter.class); defineAdapterConstructor(writer, CoGroupInputAdapter.class, v -> { for (Spec spec : inputs) { ClassDescription supplier = SupplierGenerator.get(context, spec.dataType); v.visitVarInsn(Opcodes.ALOAD, 0); getConst(v, spec.id); getConst(v, typeOf(supplier)); getEnumConstant(v, spec.bufferType); v.visitMethodInsn(Opcodes.INVOKEVIRTUAL, target.getInternalName(), "bind", //$NON-NLS-1$ Type.getMethodDescriptor(typeOf(CoGroupInputAdapter.class), typeOf(String.class), typeOf(Class.class), typeOf(CoGroupInputAdapter.BufferType.class)), false); v.visitInsn(Opcodes.POP); } }); return new ClassData(target, writer::toByteArray); }
From source file:com.asakusafw.dag.compiler.codegen.EdgeDataTableAdapterGenerator.java
License:Apache License
/** * Generates {@link EdgeDataTableAdapter} class. * @param context the current context//from w ww . j a v a 2s. co m * @param specs the target output ports * @param target the target class * @return the generated class data */ public ClassData generate(ClassGeneratorContext context, List<Spec> specs, ClassDescription target) { ClassWriter writer = AsmUtil.newWriter(target, EdgeDataTableAdapter.class); defineAdapterConstructor(writer, EdgeDataTableAdapter.class, v -> { LocalVarRef self = new LocalVarRef(Opcodes.ALOAD, 0); int index = 0; for (Spec spec : specs) { ClassDescription keyBuilder; if (spec.group.getGrouping().isEmpty()) { keyBuilder = null; } else { keyBuilder = generateKeyBuilder(context, spec, qualify(target, "k", index)); } ClassDescription copier = ObjectCopierGenerator.get(context, spec.dataType); ClassDescription comparator = toComparatorClass(context, spec); TypeDescription[] keyElementTypes = toKeyElementTypes(context, spec); self.load(v); getConst(v, spec.tableId); getConst(v, spec.inputId); getConst(v, keyBuilder); getConst(v, copier); getConst(v, comparator); getArray(v, typeOf(Class.class), keyElementTypes); v.visitMethodInsn(Opcodes.INVOKEVIRTUAL, target.getInternalName(), "bind", Type.getMethodDescriptor(typeOf(EdgeDataTableAdapter.class), typeOf(String.class), typeOf(String.class), typeOf(Class.class), typeOf(Class.class), typeOf(Class.class), typeOf(Class[].class)), false); v.visitInsn(Opcodes.POP); index++; } }); return new ClassData(target, writer::toByteArray); }
From source file:com.asakusafw.dag.compiler.codegen.EdgeOutputAdapterGenerator.java
License:Apache License
/** * Generates {@link EdgeOutputAdapter} class. * @param context the current context/*from ww w . j a v a2s . c o m*/ * @param specs the target output ports * @param target the target class * @return the generated class data */ public ClassData generate(ClassGeneratorContext context, List<Spec> specs, ClassDescription target) { ClassWriter writer = AsmUtil.newWriter(target, EdgeOutputAdapter.class); defineAdapterConstructor(writer, EdgeOutputAdapter.class, v -> { for (Spec spec : specs) { v.visitVarInsn(Opcodes.ALOAD, 0); getConst(v, spec.id); getConst(v, spec.mapper); getConst(v, spec.copier); getConst(v, spec.combiner); v.visitMethodInsn(Opcodes.INVOKEVIRTUAL, target.getInternalName(), "bind", Type.getMethodDescriptor(typeOf(EdgeOutputAdapter.class), typeOf(String.class), typeOf(Class.class), typeOf(Class.class), typeOf(Class.class)), false); v.visitInsn(Opcodes.POP); } }); return new ClassData(target, writer::toByteArray); }
From source file:com.asakusafw.dag.compiler.codegen.ExtractInputAdapterGenerator.java
License:Apache License
/** * Generates {@link ExtractInputAdapter} class. * @param context the current context/*from w w w . j a v a 2s. c o m*/ * @param input the target input spec * @param target the target class * @return the generated class data */ public ClassData generate(ClassGeneratorContext context, Spec input, ClassDescription target) { ClassWriter writer = newWriter(target, ExtractInputAdapter.class); defineAdapterConstructor(writer, ExtractInputAdapter.class, v -> { v.visitVarInsn(Opcodes.ALOAD, 0); getConst(v, input.id); v.visitMethodInsn(Opcodes.INVOKEVIRTUAL, target.getInternalName(), "bind", //$NON-NLS-1$ Type.getMethodDescriptor(typeOf(ExtractInputAdapter.class), typeOf(String.class)), false); v.visitInsn(Opcodes.POP); }); return new ClassData(target, writer::toByteArray); }
From source file:com.asakusafw.dag.compiler.codegen.OperationAdapterGenerator.java
License:Apache License
/** * Generates {@link OperationAdapter} class. * @param context the current context// www. ja v a2 s . c o m * @param operation the target operation * @param target the target class * @return the generated class data */ public ClassData generate(ClassGeneratorContext context, OperationSpec operation, ClassDescription target) { ClassDescription inner = addInner(context, operation, target); ClassWriter writer = newWriter(target, BasicOperationAdapter.class); defineAdapterConstructor(writer, BasicOperationAdapter.class, v -> { v.visitVarInsn(Opcodes.ALOAD, 0); getConst(v, inner); v.visitMethodInsn(Opcodes.INVOKEVIRTUAL, target.getInternalName(), "bind", Type.getMethodDescriptor(typeOf(BasicOperationAdapter.class), typeOf(Class.class)), false); v.visitInsn(Opcodes.POP); }); return new ClassData(target, writer::toByteArray); }
From source file:com.asakusafw.dag.compiler.codegen.SupplierGenerator.java
License:Apache License
private static ClassData generate0(TypeDescription source, ClassDescription target) { ClassWriter writer = newWriter(target, Object.class, Supplier.class); defineEmptyConstructor(writer, Object.class); defineGetter(writer, typeOf(Object.class), "get", v -> { v.visitVarInsn(Opcodes.ALOAD, 0); v.visitMethodInsn(Opcodes.INVOKEVIRTUAL, target.getInternalName(), "get", Type.getMethodDescriptor(typeOf(source)), false); v.visitInsn(Opcodes.ARETURN);/*from www . jav a 2s .c om*/ }); defineGetter(writer, typeOf(source), "get", v -> { getNew(v, source); v.visitInsn(Opcodes.ARETURN); }); writer.visitEnd(); return new ClassData(target, writer::toByteArray); }
From source file:com.asakusafw.dag.compiler.codegen.UnionRecordSerDeSupplierGenerator.java
License:Apache License
/** * Generates {@link UnionRecordSerDeSupplier} class. * @param context the current context// w w w . ja v a 2s . com * @param upstreams the upstream specifications * @param downstream the downstream specification * @param target the target class * @return the generated class data */ public static ClassData generate(ClassGeneratorContext context, List<Upstream> upstreams, Downstream downstream, ClassDescription target) { Arguments.requireNonNull(context); Arguments.requireNonNull(upstreams); Arguments.requireNonNull(downstream); ClassWriter writer = newWriter(target, UnionRecordSerDeSupplier.class); defineEmptyConstructor(writer, UnionRecordSerDeSupplier.class, v -> { LocalVarRef self = new LocalVarRef(Opcodes.ALOAD, 0); self.load(v); upstreams.forEach(s -> { // this.upstream(tags, elementSerDe) getList(v, s.tags); getConst(v, s.element); v.visitMethodInsn(Opcodes.INVOKEVIRTUAL, typeOf(UnionRecordSerDeSupplier.class).getInternalName(), "upstream", //$NON-NLS-1$ Type.getMethodDescriptor(typeOf(UnionRecordSerDeSupplier.class), typeOf(Collection.class), typeOf(Class.class)), false); }); downstream.tags.forEach(s -> { // this.downstream(tag) getConst(v, s); v.visitMethodInsn(Opcodes.INVOKEVIRTUAL, typeOf(UnionRecordSerDeSupplier.class).getInternalName(), "downstream", //$NON-NLS-1$ Type.getMethodDescriptor(typeOf(UnionRecordSerDeSupplier.class), typeOf(String.class)), false); }); v.visitInsn(Opcodes.POP); }); writer.visitEnd(); return new ClassData(target, writer::toByteArray); }