Search in sources :

Example 26 with TypeInsnNode

use of org.objectweb.asm.tree.TypeInsnNode in project maple-ir by LLVM-but-worse.

the class TypeInsnNodeSerializer method deserialize.

@Override
public TypeInsnNode deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
    JsonObject jsonObject = (JsonObject) json;
    int opcode = jsonObject.get("opcode").getAsInt();
    String desc = jsonObject.get("desc").getAsString();
    return new TypeInsnNode(opcode, desc);
}
Also used : JsonObject(com.google.gson.JsonObject) TypeInsnNode(org.objectweb.asm.tree.TypeInsnNode)

Example 27 with TypeInsnNode

use of org.objectweb.asm.tree.TypeInsnNode in project drill by apache.

the class ReplacingInterpreter method newOperation.

@Override
public BasicValue newOperation(final AbstractInsnNode insn) throws AnalyzerException {
    if (insn.getOpcode() == Opcodes.NEW) {
        final TypeInsnNode t = (TypeInsnNode) insn;
        // if this is for a holder class, we'll replace it
        final ValueHolderIden iden = HOLDERS.get(t.desc);
        if (iden != null) {
            return ReplacingBasicValue.create(Type.getObjectType(t.desc), iden, index++, valueList);
        }
    }
    return super.newOperation(insn);
}
Also used : TypeInsnNode(org.objectweb.asm.tree.TypeInsnNode)

Example 28 with TypeInsnNode

use of org.objectweb.asm.tree.TypeInsnNode in project bytecode-viewer by Konloch.

the class ASMResourceUtil method renameClassNode.

public static void renameClassNode(final String oldName, final String newName) {
    for (ClassNode c : BytecodeViewer.getLoadedClasses()) {
        for (InnerClassNode oo : c.innerClasses) {
            if (oo.innerName != null && oo.innerName.equals(oldName))
                oo.innerName = newName;
            if (oo.name.equals(oldName))
                oo.name = newName;
            if (oo.outerName != null && oo.outerName.equals(oldName))
                oo.outerName = newName;
        }
        if (c.signature != null)
            c.signature = c.signature.replace(oldName, newName);
        if (c.superName.equals(oldName))
            c.superName = newName;
        for (Object o : c.fields.toArray()) {
            FieldNode f = (FieldNode) o;
            f.desc = f.desc.replace(oldName, newName);
        }
        for (Object o : c.methods.toArray()) {
            MethodNode m = (MethodNode) o;
            if (m.localVariables != null)
                for (LocalVariableNode node : m.localVariables) node.desc = node.desc.replace(oldName, newName);
            if (m.signature != null)
                m.signature = m.signature.replace(oldName, newName);
            for (int i = 0; i < m.exceptions.size(); i++) if (m.exceptions.get(i).equals(oldName))
                m.exceptions.set(i, newName);
            for (AbstractInsnNode i : m.instructions.toArray()) {
                if (i instanceof TypeInsnNode) {
                    TypeInsnNode t = (TypeInsnNode) i;
                    if (t.desc.equals(oldName))
                        t.desc = newName;
                }
                if (i instanceof MethodInsnNode) {
                    MethodInsnNode mi = (MethodInsnNode) i;
                    if (mi.owner.equals(oldName))
                        mi.owner = newName;
                    mi.desc = mi.desc.replace(oldName, newName);
                }
                if (i instanceof FieldInsnNode) {
                    FieldInsnNode fi = (FieldInsnNode) i;
                    if (fi.owner.equals(oldName))
                        fi.owner = newName;
                    fi.desc = fi.desc.replace(oldName, newName);
                }
            }
        }
    }
}
Also used : ClassNode(org.objectweb.asm.tree.ClassNode) InnerClassNode(org.objectweb.asm.tree.InnerClassNode) FieldNode(org.objectweb.asm.tree.FieldNode) MethodNode(org.objectweb.asm.tree.MethodNode) MethodInsnNode(org.objectweb.asm.tree.MethodInsnNode) FieldInsnNode(org.objectweb.asm.tree.FieldInsnNode) TypeInsnNode(org.objectweb.asm.tree.TypeInsnNode) AbstractInsnNode(org.objectweb.asm.tree.AbstractInsnNode) InnerClassNode(org.objectweb.asm.tree.InnerClassNode) LocalVariableNode(org.objectweb.asm.tree.LocalVariableNode)

Example 29 with TypeInsnNode

use of org.objectweb.asm.tree.TypeInsnNode in project jphp by jphp-compiler.

the class ClosureValueCompiler method writePushUses.

protected void writePushUses(Collection<ArgumentStmtToken> parameters) {
    if (parameters.isEmpty()) {
        add(new InsnNode(ACONST_NULL));
        expr.stackPush(Memory.Type.REFERENCE);
        return;
    }
    expr.writePushSmallInt(parameters.size());
    add(new TypeInsnNode(ANEWARRAY, Type.getInternalName(Memory.class)));
    expr.stackPop();
    expr.stackPush(Memory.Type.REFERENCE);
    int i = 0;
    for (ArgumentStmtToken param : parameters) {
        expr.writePushDup();
        expr.writePushSmallInt(i);
        LocalVariable local = method.getLocalVariable(param.getName().getName());
        if (local == null)
            expr.writePushNull();
        else
            expr.writeVarLoad(local);
        if (!param.isReference())
            expr.writePopBoxing(true);
        add(new InsnNode(AASTORE));
        expr.stackPop();
        expr.stackPop();
        expr.stackPop();
        i++;
    }
}
Also used : MethodInsnNode(org.objectweb.asm.tree.MethodInsnNode) TypeInsnNode(org.objectweb.asm.tree.TypeInsnNode) InsnNode(org.objectweb.asm.tree.InsnNode) ArgumentStmtToken(org.develnext.jphp.core.tokenizer.token.stmt.ArgumentStmtToken) LocalVariable(org.develnext.jphp.core.compiler.jvm.misc.LocalVariable) TypeInsnNode(org.objectweb.asm.tree.TypeInsnNode)

Aggregations

TypeInsnNode (org.objectweb.asm.tree.TypeInsnNode)29 MethodInsnNode (org.objectweb.asm.tree.MethodInsnNode)18 FieldInsnNode (org.objectweb.asm.tree.FieldInsnNode)14 VarInsnNode (org.objectweb.asm.tree.VarInsnNode)13 AbstractInsnNode (org.objectweb.asm.tree.AbstractInsnNode)12 InsnNode (org.objectweb.asm.tree.InsnNode)11 JumpInsnNode (org.objectweb.asm.tree.JumpInsnNode)9 IntInsnNode (org.objectweb.asm.tree.IntInsnNode)8 LdcInsnNode (org.objectweb.asm.tree.LdcInsnNode)8 MethodNode (org.objectweb.asm.tree.MethodNode)8 Type (org.objectweb.asm.Type)7 InsnList (org.objectweb.asm.tree.InsnList)7 LabelNode (org.objectweb.asm.tree.LabelNode)7 ClassNode (org.objectweb.asm.tree.ClassNode)5 FieldNode (org.objectweb.asm.tree.FieldNode)4 MultiANewArrayInsnNode (org.objectweb.asm.tree.MultiANewArrayInsnNode)3 JsonObject (com.google.gson.JsonObject)2 ClassWriter (org.objectweb.asm.ClassWriter)2 FrameNode (org.objectweb.asm.tree.FrameNode)2 IincInsnNode (org.objectweb.asm.tree.IincInsnNode)2