Example usage for org.objectweb.asm.tree MultiANewArrayInsnNode MultiANewArrayInsnNode

List of usage examples for org.objectweb.asm.tree MultiANewArrayInsnNode MultiANewArrayInsnNode

Introduction

In this page you can find the example usage for org.objectweb.asm.tree MultiANewArrayInsnNode MultiANewArrayInsnNode.

Prototype

public MultiANewArrayInsnNode(final String descriptor, final int numDimensions) 

Source Link

Document

Constructs a new MultiANewArrayInsnNode .

Usage

From source file:com.github.fge.grappa.transform.CodeBlock.java

License:Apache License

public CodeBlock multianewarray(String arrayDesc, int dims) {
    instructionList.add(new MultiANewArrayInsnNode(arrayDesc, dims));
    return this;
}

From source file:com.github.fge.grappa.transform.CodeBlock.java

License:Apache License

public CodeBlock visitMultiANewArrayInsn(String desc, int dims) {
    instructionList.add(new MultiANewArrayInsnNode(desc, dims));
    return this;
}

From source file:de.tuberlin.uebb.jbop.optimizer.ClassNodeBuilder.java

License:Open Source License

/**
 * Initializes a classField of type Array in the default lastConstructor with the given length.
 * (eg: if fieldType of field "field" is "double[]", field = new double[length] is called).
 * /*from ww w .  j  a  va 2 s . c  o  m*/
 * @param length
 *          the length
 * @return the abstract optimizer test
 */
public ClassNodeBuilder initArray(final int... length) {
    if (isInterface) {
        return this;
    }
    final InsnList list = new InsnList();
    list.add(new VarInsnNode(Opcodes.ALOAD, 0));
    final AbstractInsnNode node;
    if (length.length == 1) {
        final Type elementType = Type.getType(lastField.desc).getElementType();
        list.add(NodeHelper.getInsnNodeFor(Integer.valueOf(length[0])));
        if (elementType.getDescriptor().startsWith("L")) {
            node = new TypeInsnNode(Opcodes.ANEWARRAY, elementType.getInternalName());
        } else {
            node = new IntInsnNode(Opcodes.NEWARRAY, getSort(elementType));
        }
    } else {
        for (final int currentLength : length) {
            list.add(NodeHelper.getInsnNodeFor(Integer.valueOf(currentLength)));
        }
        node = new MultiANewArrayInsnNode(lastField.desc, length.length);
    }
    list.add(node);
    list.add(new VarInsnNode(Opcodes.ASTORE, constructorVarIndex));
    list.add(new VarInsnNode(Opcodes.ALOAD, constructorVarIndex));
    lastConstructorVarIndex = constructorVarIndex;
    constructorVarIndex++;
    list.add(new FieldInsnNode(Opcodes.PUTFIELD, classNode.name, lastField.name, lastField.desc));
    addToConstructor(list);
    return this;
}

From source file:de.tuberlin.uebb.jbop.optimizer.ClassNodeBuilder.java

License:Open Source License

/**
 * Adds the array to the last created method.
 * /*from   w w  w .ja v a2s. c  o m*/
 * @param desc
 *          the desc
 * @param length
 *          the length
 * @return the class node builder
 */
public ClassNodeBuilder addArray(final String desc, final int... length) {
    if (isInterface) {
        return this;
    }
    final Type elementType = Type.getType(desc).getElementType();
    if (length.length == 1) {

        addInsn(NodeHelper.getInsnNodeFor(Integer.valueOf(length[0])));
        if (elementType.getDescriptor().startsWith("L")) {
            addInsn(new TypeInsnNode(Opcodes.ANEWARRAY, elementType.getInternalName()));
        } else {
            addInsn(new IntInsnNode(Opcodes.NEWARRAY, getSort(elementType)));
        }
    } else {
        for (final int currentLength : length) {
            addInsn(NodeHelper.getInsnNodeFor(Integer.valueOf(currentLength)));
        }
        addInsn(new MultiANewArrayInsnNode(desc, length.length));
    }
    addInsn(new VarInsnNode(Opcodes.ASTORE, methodVarIndex));
    lastMethodVarIndex = methodVarIndex;
    lastVarElementType = elementType;
    methodVarIndex++;
    return this;
}

From source file:edu.mit.streamjit.util.bytecode.MethodUnresolver.java

License:Open Source License

private void emit(NewArrayInst i, InsnList insns) {
    ArrayType t = i.getType();/*from   w  w w  .  j  ava  2  s.  com*/
    if (t.getDimensions() == 1) {
        load(i.getOperand(0), insns);
        RegularType ct = t.getComponentType();
        if (ct instanceof PrimitiveType) {
            if (ct.equals(booleanType))
                insns.add(new IntInsnNode(Opcodes.NEWARRAY, Opcodes.T_BOOLEAN));
            else if (ct.equals(byteType))
                insns.add(new IntInsnNode(Opcodes.NEWARRAY, Opcodes.T_BYTE));
            else if (ct.equals(charType))
                insns.add(new IntInsnNode(Opcodes.NEWARRAY, Opcodes.T_CHAR));
            else if (ct.equals(shortType))
                insns.add(new IntInsnNode(Opcodes.NEWARRAY, Opcodes.T_SHORT));
            else if (ct.equals(intType))
                insns.add(new IntInsnNode(Opcodes.NEWARRAY, Opcodes.T_INT));
            else if (ct.equals(longType))
                insns.add(new IntInsnNode(Opcodes.NEWARRAY, Opcodes.T_LONG));
            else if (ct.equals(floatType))
                insns.add(new IntInsnNode(Opcodes.NEWARRAY, Opcodes.T_FLOAT));
            else if (ct.equals(doubleType))
                insns.add(new IntInsnNode(Opcodes.NEWARRAY, Opcodes.T_DOUBLE));
        } else {
            insns.add(new TypeInsnNode(Opcodes.ANEWARRAY, internalName(ct.getKlass())));
        }
    } else {
        for (Value v : i.operands())
            load(v, insns);
        insns.add(new MultiANewArrayInsnNode(t.getDescriptor(), i.getNumOperands()));
    }
    store(i, insns);
}

From source file:me.qmx.jitescript.CodeBlock.java

License:Apache License

public CodeBlock multianewarray(String arg0, int dims) {
    this.instructionList.add(new MultiANewArrayInsnNode(arg0, dims));
    return this;
}

From source file:me.qmx.jitescript.CodeBlock.java

License:Apache License

public CodeBlock visitMultiANewArrayInsn(String arg0, int arg1) {
    this.instructionList.add(new MultiANewArrayInsnNode(arg0, arg1));
    return this;
}

From source file:net.sourceforge.cobertura.instrument.HistoryMethodAdapter.java

License:GNU General Public License

@Override
public void visitMultiANewArrayInsn(String arg0, int arg1) {
    super.visitMultiANewArrayInsn(arg0, arg1);
    appendToBacklog(new MultiANewArrayInsnNode(arg0, arg1));
}

From source file:org.jacoco.core.internal.instr.DuplicateFrameEliminatorTest.java

License:Open Source License

@Test
public void testMultiANewArrayInsn() {
    testInstructionBetweenFrames(new MultiANewArrayInsnNode("java/lang/String", 4));
}

From source file:org.jephyr.easyflow.instrument.AnalyzingMethodNode.java

License:Open Source License

@Override
public final void visitMultiANewArrayInsn(String desc, int dims) {
    MultiANewArrayInsnNode node = new MultiANewArrayInsnNode(desc, dims);
    instructions.add(node);//from   w w w  . j  av  a  2s  .  co m
    addFrame(node);
}