Example usage for org.objectweb.asm.commons Method getMethod

List of usage examples for org.objectweb.asm.commons Method getMethod

Introduction

In this page you can find the example usage for org.objectweb.asm.commons Method getMethod.

Prototype

public static Method getMethod(final String method) 

Source Link

Document

Returns a Method corresponding to the given Java method declaration.

Usage

From source file:com.android.build.gradle.internal2.incremental.IncrementalVisitor.java

License:Apache License

protected static void trace(@NonNull GeneratorAdapter mv, @Nullable String s) {
    mv.push(s);/*  www  .j  a va2 s .c o  m*/
    mv.invokeStatic(Type.getObjectType(PACKAGE + "/AndroidInstantRuntime"),
            Method.getMethod("void trace(String)"));
}

From source file:com.android.build.gradle.internal2.incremental.IncrementalVisitor.java

License:Apache License

protected static void trace(@NonNull GeneratorAdapter mv, @Nullable String s1, @Nullable String s2) {
    mv.push(s1);/*from ww  w. java  2 s .co  m*/
    mv.push(s2);
    mv.invokeStatic(Type.getObjectType(PACKAGE + "/AndroidInstantRuntime"),
            Method.getMethod("void trace(String, String)"));
}

From source file:com.android.build.gradle.internal2.incremental.IncrementalVisitor.java

License:Apache License

protected static void trace(@NonNull GeneratorAdapter mv, @Nullable String s1, @Nullable String s2,
        @Nullable String s3) {/*  w w  w. j a  v a  2  s  .  c o  m*/
    mv.push(s1);
    mv.push(s2);
    mv.push(s3);
    mv.invokeStatic(Type.getObjectType(PACKAGE + "/AndroidInstantRuntime"),
            Method.getMethod("void trace(String, String, String)"));
}

From source file:com.android.build.gradle.internal2.incremental.IncrementalVisitor.java

License:Apache License

protected static void trace(@NonNull GeneratorAdapter mv, @Nullable String s1, @Nullable String s2,
        @Nullable String s3, @Nullable String s4) {
    mv.push(s1);/* w w w  . jav  a2 s.c o  m*/
    mv.push(s2);
    mv.push(s3);
    mv.push(s4);
    mv.invokeStatic(Type.getObjectType(PACKAGE + "/AndroidInstantRuntime"),
            Method.getMethod("void trace(String, String, String, String)"));
}

From source file:com.android.build.gradle.internal2.incremental.IncrementalVisitor.java

License:Apache License

protected static void trace(@NonNull GeneratorAdapter mv, int argsNumber) {
    StringBuilder methodSignature = new StringBuilder("void trace(String");
    for (int i = 0; i < argsNumber - 1; i++) {
        methodSignature.append(", String");
    }/*from w  ww .  ja  v a  2s.  co m*/
    methodSignature.append(")");
    mv.invokeStatic(Type.getObjectType(PACKAGE + "/AndroidInstantRuntime"),
            Method.getMethod(methodSignature.toString()));
}

From source file:com.axway.jmb.builders.Fields.java

License:Open Source License

public static void addFieldToClass(int access, ClassField field, AdviceAdapter constructor, ClassVisitor clazz,
        String classFullyQualifiedName) {
    if (field.isArray()) {
        clazz.visitField(access, field.getName(),
                field.getType().getArrayJvmType(field.getArrayDimension()).getDescriptor(), null, null);

        constructor.push(field.getArrayDimension());
        constructor.newArray(field.getType().getArrayJvmType(field.getArrayDimension()));
        constructor.putField(Type.getType(classFullyQualifiedName), field.getName(),
                field.getType().getArrayJvmType(field.getArrayDimension()));
    } else {//from   w w  w .j  a  v  a  2 s.co m
        if (field.getType() == JMBVariableType.RECORD) {
            clazz.visitField(access, field.getName(), field.getRecordType().getDescriptor(), null, null);

            constructor.newInstance(field.getRecordType());
            constructor.dup();
            constructor.invokeConstructor(field.getRecordType(), Method.getMethod("void <init>()"));

            constructor.putField(Type.getType(classFullyQualifiedName), field.getName(), field.getRecordType());
        } else {
            clazz.visitField(access, field.getName(), field.getType().getJvmType().getDescriptor(), null, null);
        }
        if (field.isInitializationAvailable()) {
            constructor.putField(Type.getType(classFullyQualifiedName), field.getName(),
                    field.getType().getJvmType());
        }
    }
}

From source file:com.axway.jmb.JMessageBuilderVisitorImpl.java

License:Open Source License

@Override
public Void visitBuiltinFunctionCall(BuiltinFunctionCallContext ctx) {
    super.visitBuiltinFunctionCall(ctx);
    debug(" visitBuiltinFunctionCall()");
    if (ctx.builtinFunction().CURRENTDATE() != null) {
        currentMethod.invokeStatic(Type.getType(Builtin.class),
                Method.getMethod("java.util.Date currentDate ()"));
    }/*from ww w. ja v a2s  . c  o m*/

    return null;
}

From source file:com.axway.jmb.MethodBuilder.java

License:Open Source License

public void addLocalVariable(LocalVariable var) {
    int varPos;//from w  w w  . j  a va2  s.co m
    debug(" addLocalVariable():" + var.getName() + " " + this);
    if (var.isArray()) {
        varPos = newLocal(var.getType().getArrayJvmType(var.getArrayDimension()));
        push(var.getArrayDimension());
        newArray(var.getType().getArrayJvmType(var.getArrayDimension()));
        storeLocal(varPos, var.getType().getArrayJvmType(var.getArrayDimension()));
    } else {
        if (var.getType() == JMBVariableType.RECORD) {
            varPos = newLocal(var.getRecordType());
            newInstance(var.getRecordType());
            dup();
            invokeConstructor(var.getRecordType(), Method.getMethod("void <init>()"));
            storeLocal(varPos, var.getRecordType());
        } else {
            varPos = newLocal(var.getType().getJvmType());
        }
        if (var.isInitializationAvailable()) {
            storeLocal(varPos, var.getType().getJvmType());
        }
    }

    var.setArrayPosition(varPos);
    localVars.put(var.getName(), var);

    if (var.getType() == JMBVariableType.STRING) {
        //         push( "Salut!" );
        //         invokeConstructor( var.getType().getJvmType(), Method.getMethod("void <init>(java.lang.String)") );

        //         getStatic(Type.getType(System.class), "out", Type.getType(PrintStream.class));
        //         push( "Salut!" );
        //         invokeVirtual(Type.getType(PrintStream.class),
        //                  Method.getMethod("void println (String)"));

    }
    if (var.getType() == JMBVariableType.FIXED_STRING) {

    }
    debug(" varPos: " + varPos);
}

From source file:com.axway.jmb.MethodBuilder.java

License:Open Source License

public void pushOnStack(Object val) {
    debug("## push value " + val);
    if (val instanceof Long) {
        newInstance(JMBVariableType.INTEGER.getJvmType());
        dup();/*  ww  w .  jav  a  2s  .c o m*/
        push(((Long) val).longValue());
        invokeConstructor(JMBVariableType.INTEGER.getJvmType(), Method.getMethod("void <init>(long)"));
        return;
    }
    if (val instanceof Double) {
        newInstance(JMBVariableType.FLOAT.getJvmType());
        dup();
        push(((Double) val).doubleValue());
        invokeConstructor(JMBVariableType.FLOAT.getJvmType(), Method.getMethod("void <init>(double)"));
        return;
    }
    if (val instanceof String) {
        newInstance(JMBVariableType.STRING.getJvmType());
        dup();
        push((String) val);
        invokeConstructor(JMBVariableType.STRING.getJvmType(),
                Method.getMethod("void <init>(java.lang.String)"));
        return;
    }
}

From source file:com.axway.jmb.MethodBuilder.java

License:Open Source License

public void storeInLocalVar(String varName, boolean isStatementCall, int statementCallCurrentParameterIndex)
        throws CompileException {
    LocalVariable lv = localVars.get(varName);
    if (lv == null)
        throw new CompileException("Local variable " + varName + " used, but not defined.");

    if (isStatementCall) {
        visitInsn(Opcodes.DUP);//  w ww .j  a  va2 s. c  o m
        visitInsn(Opcodes.ICONST_0 + statementCallCurrentParameterIndex);
        visitInsn(AALOAD);
    }

    if (lv.isArray()) {
        visitTypeInsn(CHECKCAST, lv.getType().getArrayJvmType(lv.getArrayDimension()).toString());
        storeLocal(lv.getArrayPosition(), lv.getType().getArrayJvmType(lv.getArrayDimension()));
    } else {
        if (lv.getType() == JMBVariableType.FIXED_STRING) {
            invokeVirtual(Type.getType(String.class), Method.getMethod("char[] toCharArray()"));
            push((int) lv.getFixedStringLength());
            invokeStatic(Type.getType(Arrays.class), Method.getMethod("char[] copyOf(char[], int)"));
        } else if (lv.getType() == JMBVariableType.STRING) {
            invokeVirtual(Type.getType(Object.class), Method.getMethod("String toString()"));
        } else if (lv.getType() == JMBVariableType.INTEGER) {
            visitTypeInsn(CHECKCAST, "java/lang/Long");
        } else if (lv.getType() == JMBVariableType.FLOAT) {
            visitTypeInsn(CHECKCAST, "java/lang/Double");
        } else if (lv.getType() == JMBVariableType.DATE) {
            visitTypeInsn(CHECKCAST, "java/util/Date");
        }

        storeLocal(lv.getArrayPosition(), lv.getType().getJvmType());
    }

    debug("## store _" + lv.getArrayPosition());
}