Java 类org.objectweb.asm.tree.LdcInsnNode 实例源码

项目:DirectLeaks-AntiReleak-Remover    文件:InjectorRemover.java   
private static void stringEncryptionTransformer(ClassNode classNode) {
    if (classNode.superName.equals("org/bukkit/plugin/java/JavaPlugin") || classNode.superName.equals("net/md_5/bungee/api/plugin/Plugin")) {
        for (MethodNode methodNode : classNode.methods) {
            InsnList nodes = methodNode.instructions;
            for (int i = 0; i < nodes.size(); i++) {
                AbstractInsnNode instruction = nodes.get(i);
                if (instruction instanceof LdcInsnNode) {
                    if (instruction.getNext() instanceof MethodInsnNode) {
                        LdcInsnNode ldc = (LdcInsnNode) instruction;
                        MethodInsnNode methodinsnnode = (MethodInsnNode) ldc.getNext();
                        if (ldc.cst instanceof String) {
                            if (methodinsnnode.name.equalsIgnoreCase("\u0972") && methodinsnnode.desc.equalsIgnoreCase("(Ljava/lang/String;)Ljava/lang/String;")) {
                                methodNode.instructions.remove(methodinsnnode);
                                ldc.cst = decryptionArray((String)ldc.cst);
                            }
                        }
                    }
                }
            }
        }
    }
}
项目:luna    文件:ConversionMethods.java   
public static InsnList toNumericalValue(String what) {
  Objects.requireNonNull(what);
  InsnList il = new InsnList();

  il.add(new LdcInsnNode(what));
  il.add(new MethodInsnNode(
      INVOKESTATIC,
      Type.getInternalName(Conversions.class),
      "toNumericalValue",
      Type.getMethodDescriptor(
          Type.getType(Number.class),
          Type.getType(Object.class),
          Type.getType(String.class)),
      false));

  return il;
}
项目:DirectLeaks-AntiReleak-Remover    文件:SourceInterpreter.java   
@Override
public SourceValue newOperation(final AbstractInsnNode insn) {
    int size;
    switch (insn.getOpcode()) {
    case LCONST_0:
    case LCONST_1:
    case DCONST_0:
    case DCONST_1:
        size = 2;
        break;
    case LDC:
        Object cst = ((LdcInsnNode) insn).cst;
        size = cst instanceof Long || cst instanceof Double ? 2 : 1;
        break;
    case GETSTATIC:
        size = Type.getType(((FieldInsnNode) insn).desc).getSize();
        break;
    default:
        size = 1;
    }
    return new SourceValue(size, insn);
}
项目:r8    文件:JarSourceCode.java   
private void updateState(LdcInsnNode insn) {
  if (insn.cst instanceof Type) {
    Type type = (Type) insn.cst;
    state.push(type);
  } else if (insn.cst instanceof String) {
    state.push(STRING_TYPE);
  } else if (insn.cst instanceof Long) {
    state.push(Type.LONG_TYPE);
  } else if (insn.cst instanceof Double) {
    state.push(Type.DOUBLE_TYPE);
  } else if (insn.cst instanceof Integer) {
    state.push(Type.INT_TYPE);
  } else {
    assert insn.cst instanceof Float;
    state.push(Type.FLOAT_TYPE);
  }
}
项目:r8    文件:JarSourceCode.java   
private void build(LdcInsnNode insn, IRBuilder builder) {
  if (insn.cst instanceof Type) {
    Type type = (Type) insn.cst;
    int dest = state.push(type);
    builder.addConstClass(dest, application.getTypeFromDescriptor(type.getDescriptor()));
  } else if (insn.cst instanceof String) {
    int dest = state.push(STRING_TYPE);
    builder.addConstString(dest, application.getString((String) insn.cst));
  } else if (insn.cst instanceof Long) {
    int dest = state.push(Type.LONG_TYPE);
    builder.addLongConst(dest, (Long) insn.cst);
  } else if (insn.cst instanceof Double) {
    int dest = state.push(Type.DOUBLE_TYPE);
    builder.addDoubleConst(dest, Double.doubleToRawLongBits((Double) insn.cst));
  } else if (insn.cst instanceof Integer) {
    int dest = state.push(Type.INT_TYPE);
    builder.addIntConst(dest, (Integer) insn.cst);
  } else {
    assert insn.cst instanceof Float;
    int dest = state.push(Type.FLOAT_TYPE);
    builder.addFloatConst(dest, Float.floatToRawIntBits((Float) insn.cst));
  }
}
项目:elasticsearch_my    文件:ESLoggerUsageChecker.java   
@Override
public BasicValue newOperation(AbstractInsnNode insnNode) throws AnalyzerException {
    switch (insnNode.getOpcode()) {
        case ICONST_0: return new IntegerConstantBasicValue(Type.INT_TYPE, 0);
        case ICONST_1: return new IntegerConstantBasicValue(Type.INT_TYPE, 1);
        case ICONST_2: return new IntegerConstantBasicValue(Type.INT_TYPE, 2);
        case ICONST_3: return new IntegerConstantBasicValue(Type.INT_TYPE, 3);
        case ICONST_4: return new IntegerConstantBasicValue(Type.INT_TYPE, 4);
        case ICONST_5: return new IntegerConstantBasicValue(Type.INT_TYPE, 5);
        case BIPUSH:
        case SIPUSH: return new IntegerConstantBasicValue(Type.INT_TYPE, ((IntInsnNode)insnNode).operand);
        case Opcodes.LDC: {
            Object constant = ((LdcInsnNode)insnNode).cst;
            if (constant instanceof Integer) {
                return new IntegerConstantBasicValue(Type.INT_TYPE, (Integer)constant);
            } else {
                return super.newOperation(insnNode);
            }
        }
        default: return super.newOperation(insnNode);
    }
}
项目:Spigot-Nonce-ID-Finder    文件:SourceInterpreter.java   
@Override
public SourceValue newOperation(final AbstractInsnNode insn) {
    int size;
    switch (insn.getOpcode()) {
    case LCONST_0:
    case LCONST_1:
    case DCONST_0:
    case DCONST_1:
        size = 2;
        break;
    case LDC:
        Object cst = ((LdcInsnNode) insn).cst;
        size = cst instanceof Long || cst instanceof Double ? 2 : 1;
        break;
    case GETSTATIC:
        size = Type.getType(((FieldInsnNode) insn).desc).getSize();
        break;
    default:
        size = 1;
    }
    return new SourceValue(size, insn);
}
项目:Spigot-Nonce-ID-Finder    文件:Finder.java   
private static void findID(ClassNode classNode) throws Throwable {
    for (MethodNode methodNode : classNode.methods) {
        Iterator<AbstractInsnNode> insnIterator = methodNode.instructions.iterator();
        while (insnIterator.hasNext()) {
            AbstractInsnNode insnNode = insnIterator.next();
            String str;
            if ((insnNode.getType() == 9)) {
                Object cst = ((LdcInsnNode) insnNode).cst;
                if (cst instanceof String) {
                    str = ((LdcInsnNode) insnNode).cst.toString();
                    Matcher matcher = NONCEID_PATTERN.matcher(str);
                    if (matcher.find()) {
                        possiblenonces.add(str);
                    }
                }
            }
        }
    }
}
项目:GraphiteMappings    文件:TestMappings.java   
@Override
protected void remap() {
    Optional<ClassNode> classNode = findNode(TestMappings.class.getName());
    classNode.ifPresent((cn) -> {
        for (MethodNode method : cn.methods) {
            TypeNameEnforcer returnType = TypeNameEnforcer.getReturnType(method);
            if (returnType.getJvmStandard().equals("java/lang/String")) {
                method.instructions.iterator().forEachRemaining((insnNode) -> {
                    if (insnNode instanceof LdcInsnNode) {
                        LdcInsnNode ldcInsnNode = (LdcInsnNode) insnNode;
                        String payload = (String) ldcInsnNode.cst;
                        if (!payload.equals("oops")) {
                            MethodRef methodRef = createObfMd(method);
                            MethodRef methodRef1 = createRemappedMd("correct", method);
                            getMappings().putMethod(methodRef, methodRef1);
                        }
                    }
                });
            }
        }
    });
}
项目:luna    文件:BytecodeEmitVisitor.java   
@Override
public void visit(LoadConst.Str node) {
  // use byte strings?
  if (context.compilerSettings.byteStrings()) {
    if (context.compilerSettings.constCaching()) {
      il.add(loadCachedConst(node.value()));
    } else {
      il.add(newByteString(node.value()));
    }
  } else {
    // java.lang.String
    il.add(new LdcInsnNode(node.value()));
  }

  il.add(new VarInsnNode(ASTORE, slot(node.dest())));
}
项目:BukkitPlugin-Message-Injector    文件:SourceInterpreter.java   
@Override
public SourceValue newOperation(final AbstractInsnNode insn) {
    int size;
    switch (insn.getOpcode()) {
    case LCONST_0:
    case LCONST_1:
    case DCONST_0:
    case DCONST_1:
        size = 2;
        break;
    case LDC:
        Object cst = ((LdcInsnNode) insn).cst;
        size = cst instanceof Long || cst instanceof Double ? 2 : 1;
        break;
    case GETSTATIC:
        size = Type.getType(((FieldInsnNode) insn).desc).getSize();
        break;
    default:
        size = 1;
    }
    return new SourceValue(size, insn);
}
项目:Simple-JAR-Watermark    文件:SourceInterpreter.java   
@Override
public SourceValue newOperation(final AbstractInsnNode insn) {
    int size;
    switch (insn.getOpcode()) {
    case LCONST_0:
    case LCONST_1:
    case DCONST_0:
    case DCONST_1:
        size = 2;
        break;
    case LDC:
        Object cst = ((LdcInsnNode) insn).cst;
        size = cst instanceof Long || cst instanceof Double ? 2 : 1;
        break;
    case GETSTATIC:
        size = Type.getType(((FieldInsnNode) insn).desc).getSize();
        break;
    default:
        size = 1;
    }
    return new SourceValue(size, insn);
}
项目:Spigot-Attribute-Remover    文件:SourceInterpreter.java   
@Override
public SourceValue newOperation(final AbstractInsnNode insn) {
    int size;
    switch (insn.getOpcode()) {
    case LCONST_0:
    case LCONST_1:
    case DCONST_0:
    case DCONST_1:
        size = 2;
        break;
    case LDC:
        Object cst = ((LdcInsnNode) insn).cst;
        size = cst instanceof Long || cst instanceof Double ? 2 : 1;
        break;
    case GETSTATIC:
        size = Type.getType(((FieldInsnNode) insn).desc).getSize();
        break;
    default:
        size = 1;
    }
    return new SourceValue(size, insn);
}
项目:fastAOP    文件:SourceInterpreter.java   
@Override
public SourceValue newOperation(final AbstractInsnNode insn) {
    int size;
    switch (insn.getOpcode()) {
    case LCONST_0:
    case LCONST_1:
    case DCONST_0:
    case DCONST_1:
        size = 2;
        break;
    case LDC:
        Object cst = ((LdcInsnNode) insn).cst;
        size = cst instanceof Long || cst instanceof Double ? 2 : 1;
        break;
    case GETSTATIC:
        size = Type.getType(((FieldInsnNode) insn).desc).getSize();
        break;
    default:
        size = 1;
    }
    return new SourceValue(size, insn);
}
项目:rembulan    文件:ASMUtils.java   
public static AbstractInsnNode loadInt(int i) {
    switch (i) {
        case -1: return new InsnNode(ICONST_M1);
        case 0:  return new InsnNode(ICONST_0);
        case 1:  return new InsnNode(ICONST_1);
        case 2:  return new InsnNode(ICONST_2);
        case 3:  return new InsnNode(ICONST_3);
        case 4:  return new InsnNode(ICONST_4);
        case 5:  return new InsnNode(ICONST_5);
        default: {
            if (i >= Byte.MIN_VALUE && i <= Byte.MAX_VALUE) return new IntInsnNode(BIPUSH, i);
            else if (i >= Short.MIN_VALUE && i <= Short.MAX_VALUE) return new IntInsnNode(SIPUSH, i);
            else return new LdcInsnNode(i);
        }
    }
}
项目:rembulan    文件:ConversionMethods.java   
public static InsnList toNumericalValue(String what) {
    Objects.requireNonNull(what);
    InsnList il = new InsnList();

    il.add(new LdcInsnNode(what));
    il.add(new MethodInsnNode(
            INVOKESTATIC,
            Type.getInternalName(Conversions.class),
            "toNumericalValue",
            Type.getMethodDescriptor(
                    Type.getType(Number.class),
                    Type.getType(Object.class),
                    Type.getType(String.class)),
            false));

    return il;
}
项目:CCTweaks-Lua    文件:CustomTimeout.java   
@Override
public ClassVisitor patch(String className, ClassVisitor delegate) throws Exception {
    return new FindingVisitor(
        delegate,
        new VarInsnNode(ALOAD, 4),
        new LdcInsnNode(7000L),
        new MethodInsnNode(INVOKEVIRTUAL, "java/lang/Thread", "join", "(J)V", false)
    ) {
        @Override
        public void handle(InsnList nodes, MethodVisitor visitor) {
            visitor.visitVarInsn(ALOAD, 4);
            visitor.visitFieldInsn(GETSTATIC, "org/squiddev/cctweaks/lua/Config$Computer", "computerThreadTimeout", "I");
            visitor.visitInsn(I2L);
            visitor.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Thread", "join", "(J)V", false);
        }
    }.onMethod("run").once().mustFind();
}
项目:CCTweaks-Lua    文件:CustomBios.java   
@Override
public ClassVisitor patch(String className, ClassVisitor delegate) throws Exception {
    return new FindingVisitor(
        delegate,
        new LdcInsnNode("lua/bios.lua")
    ) {
        @Override
        public void handle(InsnList nodes, MethodVisitor visitor) {
            Label finish = new Label(), def = new Label();

            visitor.visitVarInsn(ALOAD, 0);
            visitor.visitFieldInsn(GETFIELD, "dan200/computercraft/core/computer/Computer", "biosPath", "Ljava/lang/String;");
            visitor.visitJumpInsn(IFNULL, def);

            visitor.visitVarInsn(ALOAD, 0);
            visitor.visitFieldInsn(GETFIELD, "dan200/computercraft/core/computer/Computer", "biosPath", "Ljava/lang/String;");
            visitor.visitJumpInsn(GOTO, finish);

            visitor.visitLabel(def);
            visitor.visitLdcInsn("lua/bios.lua");

            visitor.visitLabel(finish);
        }
    }.onMethod("initLua").mustFind();
}
项目:JAADAS    文件:AsmMethodSource.java   
private void convertLdcInsn(LdcInsnNode insn) {
    Object val = insn.cst;
    boolean dword = val instanceof Long || val instanceof Double;
    StackFrame frame = getFrame(insn);
    Operand[] out = frame.out();
    Operand opr;
    if (out == null) {
        Value v = toSootValue(val);
        opr = new Operand(insn, v);
        frame.out(opr);
    } else {
        opr = out[0];
    }
    if (dword)
        pushDual(opr);
    else
        push(opr);
}
项目:RorysMod    文件:InstructionComparator.java   
public static boolean insnEqual(AbstractInsnNode node1, AbstractInsnNode node2) {
    if (node1.getType() != node2.getType()) {
        return false;
    } else if (node1.getOpcode() != node2.getOpcode()) {
        return false;
    }

    switch (node2.getType()) {
        case VAR_INSN:
            return varInsnEqual((VarInsnNode) node1, (VarInsnNode) node2);
        case TYPE_INSN:
            return typeInsnEqual((TypeInsnNode) node1, (TypeInsnNode) node2);
        case FIELD_INSN:
            return fieldInsnEqual((FieldInsnNode) node1, (FieldInsnNode) node2);
        case METHOD_INSN:
            return methodInsnEqual((MethodInsnNode) node1, (MethodInsnNode) node2);
        case LDC_INSN:
            return ldcInsnEqual((LdcInsnNode) node1, (LdcInsnNode) node2);
        case IINC_INSN:
            return iincInsnEqual((IincInsnNode) node1, (IincInsnNode) node2);
        case INT_INSN:
            return intInsnEqual((IntInsnNode) node1, (IntInsnNode) node2);
        default:
            return true;
    }
}
项目:Alchemy    文件:TransformerLdcString.java   
@Override
public byte[] transform(String name, String transformedName, byte[] basicClass) {
    if (!mapping_classes.contains(transformedName))
        return basicClass;
    ClassReader reader = new ClassReader(basicClass);
    ClassWriter writer = new ClassWriter(0);
    ClassNode node = new ClassNode(ASM5);
    reader.accept(node, 0);
    for (MethodNode method : node.methods) {
        int index = 0;
        for (Iterator<AbstractInsnNode> iterator = method.instructions.iterator(); iterator.hasNext();) {
            AbstractInsnNode insn = iterator.next();
            if (insn instanceof LdcInsnNode) {
                LdcInsnNode ldc = (LdcInsnNode) insn;
                if (ldc.cst instanceof String)
                    ldc.cst = map(transformedName, method.name, index++, (String) ldc.cst);
            }
        }
    }
    node.accept(writer);
    return writer.toByteArray();
}
项目:Alchemy    文件:ASMHelper.java   
static AbstractInsnNode getDefaultLdcNode(Type type) {
    switch (type.getSort()) {
        case Type.INT:
            return getIntNode(0);
        case Type.BOOLEAN:
            return new LdcInsnNode(false);
        case Type.BYTE:
            return new LdcInsnNode((byte) 0);
        case Type.SHORT:
            return new LdcInsnNode((short) 0);
        case Type.LONG:
            return new LdcInsnNode(0L);
        case Type.FLOAT:
            return new LdcInsnNode(0F);
        case Type.DOUBLE:
            return new LdcInsnNode(0D);
        case Type.CHAR:
            return new LdcInsnNode((char) 0);
        default:
            return new InsnNode(ACONST_NULL);
    }
}
项目:Alchemy    文件:AlchemyTransformerManager.java   
public static void markClinitCallback(ClassNode node, Runnable... runnables) {
    callback_mapping.get(node.name).addAll(Arrays.asList(runnables));
    for (String i : node.interfaces)
        if (i.equals(CALLBACK_FLAG_DESC))
            return;
    node.interfaces.add(CALLBACK_FLAG_DESC);
    MethodNode clinit = null;
    for (MethodNode method : node.methods)
        if (method.name.equals("<clinit>")) {
            clinit = method;
            break;
        }
    boolean flag = clinit == null;
    if (flag)
        node.methods.add(clinit = new MethodNode(0, "<clinit>", "()V", null, null));
    InsnList list = new InsnList();
    list.add(new LdcInsnNode(node.name));
    list.add(new MethodInsnNode(INVOKESTATIC, "index/alchemy/core/asm/transformer/AlchemyTransformerManager",
            "callback", "(Ljava/lang/String;)V", false));
    if (flag)
        list.add(new InsnNode(RETURN));
    clinit.instructions.insert(list);
}
项目:javify    文件:DataflowInterpreter.java   
public Value newOperation(final AbstractInsnNode insn) {
    int size;
    switch (insn.getOpcode()) {
        case LCONST_0:
        case LCONST_1:
        case DCONST_0:
        case DCONST_1:
            size = 2;
            break;
        case LDC:
            Object cst = ((LdcInsnNode) insn).cst;
            size = cst instanceof Long || cst instanceof Double ? 2 : 1;
            break;
        case GETSTATIC:
            size = Type.getType(((FieldInsnNode) insn).desc).getSize();
            break;
        default:
            size = 1;
    }
    return new DataflowValue(size, insn);
}
项目:pro    文件:ConstInterpreter.java   
@Override
public ConstValue newOperation(AbstractInsnNode insn) {
  switch (insn.getOpcode()) {
  case LCONST_0:
  case LCONST_1:
  case DCONST_0:
  case DCONST_1:
    return ConstValue.TWO_SLOT;
  case LDC:
    Object cst = ((LdcInsnNode) insn).cst;
    if (cst instanceof Type) {  // constant class
      return ConstValue.string(((Type)cst).getInternalName());
    }
    return cst instanceof Long || cst instanceof Double ? ConstValue.TWO_SLOT: ConstValue.ONE_SLOT;
  case GETSTATIC:
    return ConstValue.slot(Type.getType(((FieldInsnNode) insn).desc).getSize());
  default:
    return ConstValue.ONE_SLOT;
  }
}
项目:NeonObf    文件:BasicTypesEncryption.java   
private void addObfuscatedLong(ListIterator<AbstractInsnNode> iterator, long l) {
    boolean negative = l < 0;
    iterator.add(
            new LdcInsnNode
            (
                negative?-l:l
            )
    );
    int val = ((rand.nextInt(10) + 1) * 2) + (negative?1:0);
    for(int i = 0; i < val; i++)
        iterator.add(
                new InsnNode
                (
                    LNEG
                )
        );
}
项目:thesis-disassembler    文件:LdcInsnNodeHandler.java   
@Override
public void handle(AbstractInsnNode node) throws IncorrectNodeException {
    super.handle(node);
    LOG.debug(logNode(node));
    checkType(node, LdcInsnNode.class);
    ExpressionStack stack = mState.getActiveStack();
    DataType type;
    Object constant = ((LdcInsnNode)node).cst;
    if (constant instanceof Integer) {
        type = DataType.INT;
    } else if (constant instanceof Float) {
        type = DataType.FLOAT;
    } else if (constant instanceof Double) {
        type = DataType.DOUBLE;
    } else if (constant instanceof Long) {
        type = DataType.LONG;
    } else if (constant instanceof String) {
        type = DataType.getTypeFromObject("java.lang.String");
    } else {
        constant = DataType.getType((Type) constant); //todo think is this correct?
        type = DataType.getTypeFromObject("java.lang.Class");
    }
    stack.push(new PrimaryExpression(node.getOpcode(), constant, type));
}
项目:testrecorder    文件:WrapArgumentTypes.java   
@Override
public InsnList build(MethodContext context) {
    Type[] argumentTypes = context.getArgumentTypes();

    InsnList insnList = new InsnList();

    insnList.add(new LdcInsnNode(argumentTypes.length));
    insnList.add(new TypeInsnNode(Opcodes.ANEWARRAY, Type.getInternalName(java.lang.reflect.Type.class)));

    for (int i = 0; i < argumentTypes.length; i++) {
        insnList.add(new InsnNode(DUP));
        insnList.add(new LdcInsnNode(i));
        insnList.add(new PushBoxedType(argumentTypes[i]).build(context));
        insnList.add(new InsnNode(AASTORE));
    }
    return insnList;
}
项目:NOVA-Core    文件:InstructionComparator.java   
public static boolean insnEqual(AbstractInsnNode node1, AbstractInsnNode node2) {
    if (node1.getOpcode() != node2.getOpcode()) {
        return false;
    }

    switch (node2.getType()) {
        case VAR_INSN:
            return varInsnEqual((VarInsnNode) node1, (VarInsnNode) node2);
        case TYPE_INSN:
            return typeInsnEqual((TypeInsnNode) node1, (TypeInsnNode) node2);
        case FIELD_INSN:
            return fieldInsnEqual((FieldInsnNode) node1, (FieldInsnNode) node2);
        case METHOD_INSN:
            return methodInsnEqual((MethodInsnNode) node1, (MethodInsnNode) node2);
        case LDC_INSN:
            return ldcInsnEqual((LdcInsnNode) node1, (LdcInsnNode) node2);
        case IINC_INSN:
            return iincInsnEqual((IincInsnNode) node1, (IincInsnNode) node2);
        case INT_INSN:
            return intInsnEqual((IntInsnNode) node1, (IntInsnNode) node2);
        default:
            return true;
    }
}
项目:NOVA-Core    文件:InstructionComparator.java   
public static boolean insnEqual(AbstractInsnNode node1, AbstractInsnNode node2) {
    if (node1.getOpcode() != node2.getOpcode()) {
        return false;
    }

    switch (node2.getType()) {
        case VAR_INSN:
            return varInsnEqual((VarInsnNode) node1, (VarInsnNode) node2);
        case TYPE_INSN:
            return typeInsnEqual((TypeInsnNode) node1, (TypeInsnNode) node2);
        case FIELD_INSN:
            return fieldInsnEqual((FieldInsnNode) node1, (FieldInsnNode) node2);
        case METHOD_INSN:
            return methodInsnEqual((MethodInsnNode) node1, (MethodInsnNode) node2);
        case LDC_INSN:
            return ldcInsnEqual((LdcInsnNode) node1, (LdcInsnNode) node2);
        case IINC_INSN:
            return iincInsnEqual((IincInsnNode) node1, (IincInsnNode) node2);
        case INT_INSN:
            return intInsnEqual((IntInsnNode) node1, (IntInsnNode) node2);
        default:
            return true;
    }
}
项目:GemFireLite    文件:PdxSFieldProcessor.java   
/***
 * 
 * 
 * @param fn
 * @param inst
 * @param dsi
 */
private void writeValue(String owner, FieldNode fn, InsnList inst, PdxSItem dsi)
{
  String desc = new StringBuffer("(Ljava/lang/String;").append(fn.desc)
      .append(")Lcom/gemstone/gemfire/pdx/PdxWriter;").toString();

  inst.add(new VarInsnNode(ALOAD, 1));
  inst.add(new LdcInsnNode(fn.name));
  inst.add(new VarInsnNode(ALOAD, 0));
  inst.add(new FieldInsnNode(GETFIELD, owner, fn.name, fn.desc));

  // add INVOKEVIRTUAL method
  if (PdxConstants.TYPE_BYTECODE_BYTE_B.equals(fn.desc)) // data type ->byte
    inst.add(AsmHelper.newMethodInsnNode(INVOKEVIRTUAL, PdxConstants.TYPE_BYTECODE_BYTE, "byteValue", fn.desc, false));
  else if (PdxConstants.TYPE_BYTECODE_BOOL_Z.equals(fn.desc)) // data type ->
                                                              // boolean
    inst.add(AsmHelper.newMethodInsnNode(INVOKEVIRTUAL, PdxConstants.TYPE_BYTECODE_BOOL, "booleanValue", fn.desc,
        false));

  inst.add(AsmHelper.newMethodInsnNode(INVOKEINTERFACE, PdxConstants.PDX_WRITER_VALUE, dsi.toMethod, desc, true));
  inst.add(new InsnNode(POP));
}
项目:GemFireLite    文件:MapperToolProcessor.java   
private void addMapperKeySimple(ClassNode mapper, FieldNode key)
{
  if (DomainMojoHelper.log().isDebugEnabled())
    DomainMojoHelper.log().debug("Add mapperKey(IDataSource)K method, key field:" + key.name);
  String fullDesc = AsmHelper.toFullName(key.desc);
  MethodNode mn = new MethodNode(ACC_PUBLIC, "mapperKey", "(Lgemlite/core/internal/domain/IDataSource;)" + fullDesc,
      null, null);
  InsnList insn = mn.instructions;
  insn.add(new VarInsnNode(ALOAD, 1));
  insn.add(new LdcInsnNode(key.name));

  Item1 mti = MapperToolRegistry.getDataSItem(key.desc);
  insn.add(AsmHelper.newMethodInsnNode(INVOKEINTERFACE, "gemlite/core/internal/domain/IDataSource", mti.getMethod,
      "(Ljava/lang/String;)" + key.desc, true));
  AsmHelper.addTypeConvert(insn, key.desc);
  insn.add(new InsnNode(ARETURN));
  mapper.methods.add(mn);
  if (DomainMojoHelper.log().isDebugEnabled())
    DomainMojoHelper.log().debug("Add mapperKey(IDataSource)K method, key field:" + key.name);
}
项目:GemFireLite    文件:MapperToolProcessor.java   
private void addKeyValueTypeMethod(ClassNode domain, ClassNode mapper, String keyClassDesc)
{
  keyClassDesc = AsmHelper.toFullName(keyClassDesc);
  MethodNode mn = new MethodNode(ACC_PUBLIC, "getKeyClass", "()Ljava/lang/Class;", "()Ljava/lang/Class<"
      + keyClassDesc + ">;", null);
  InsnList insn = mn.instructions;
  insn.add(new LdcInsnNode(Type.getType(keyClassDesc)));
  insn.add(new InsnNode(ARETURN));
  mapper.methods.add(mn);

  String valueClassDesc = "L" + domain.name + ";";
  mn = new MethodNode(ACC_PUBLIC, "getValueClass", "()Ljava/lang/Class;", "()Ljava/lang/Class<" + valueClassDesc
      + ">;", null);
  insn = mn.instructions;
  insn.add(new LdcInsnNode(Type.getType(valueClassDesc)));
  insn.add(new InsnNode(ARETURN));
  mapper.methods.add(mn);
}
项目:annotation-tools    文件:DataflowInterpreter.java   
public Value newOperation(final AbstractInsnNode insn) {
    int size;
    switch (insn.getOpcode()) {
        case LCONST_0:
        case LCONST_1:
        case DCONST_0:
        case DCONST_1:
            size = 2;
            break;
        case LDC:
            Object cst = ((LdcInsnNode) insn).cst;
            size = cst instanceof Long || cst instanceof Double ? 2 : 1;
            break;
        case GETSTATIC:
            size = Type.getType(((FieldInsnNode) insn).desc).getSize();
            break;
        default:
            size = 1;
    }
    return new DataflowValue(size, insn);
}
项目:jephyr    文件:ContinuationMethodAdapter.java   
private void addInvocationStartedHook(int implVarIndex, LabelNode labelNode) {
    if ((access & ACC_STATIC) == 0) {
        instructions.insertBefore(labelNode, new VarInsnNode(ALOAD, implVarIndex));
        instructions.insertBefore(labelNode, new VarInsnNode(ALOAD, 0));
        instructions.insertBefore(labelNode, new LdcInsnNode(name));
        instructions.insertBefore(labelNode, new LdcInsnNode(desc));
        instructions.insertBefore(labelNode,
                new MethodInsnNode(INVOKEVIRTUAL, "org/jephyr/continuation/easyflow/ContinuationImpl",
                        "invocationStarted", "(Ljava/lang/Object;Ljava/lang/String;Ljava/lang/String;)V", false));
    } else {
        instructions.insertBefore(labelNode, new VarInsnNode(ALOAD, implVarIndex));
        instructions.insertBefore(labelNode, new LdcInsnNode(Type.getType('L' + owner + ';')));
        instructions.insertBefore(labelNode, new LdcInsnNode(name));
        instructions.insertBefore(labelNode, new LdcInsnNode(desc));
        instructions.insertBefore(labelNode,
                new MethodInsnNode(INVOKEVIRTUAL, "org/jephyr/continuation/easyflow/ContinuationImpl",
                        "staticInvocationStarted", "(Ljava/lang/Class;Ljava/lang/String;Ljava/lang/String;)V",
                        false));
    }

    updateMaxStack(4);
}
项目:JReFrameworker    文件:SourceInterpreter.java   
@Override
public SourceValue newOperation(final AbstractInsnNode insn) {
    int size;
    switch (insn.getOpcode()) {
    case LCONST_0:
    case LCONST_1:
    case DCONST_0:
    case DCONST_1:
        size = 2;
        break;
    case LDC:
        Object cst = ((LdcInsnNode) insn).cst;
        size = cst instanceof Long || cst instanceof Double ? 2 : 1;
        break;
    case GETSTATIC:
        size = Type.getType(((FieldInsnNode) insn).desc).getSize();
        break;
    default:
        size = 1;
    }
    return new SourceValue(size, insn);
}
项目:instrumentation    文件:Instrumentator.java   
private void addGetMethodInvocation(InsnList il) {
    il.add(TreeInstructions.getPushInstruction(this.methodArguments.length));
    il.add(new TypeInsnNode(Opcodes.ANEWARRAY, "java/lang/Class"));
    int parameterClassesIndex = getFistAvailablePosition();
    il.add(new VarInsnNode(Opcodes.ASTORE, parameterClassesIndex));
    this.mn.maxLocals++;
    for (int i = 0; i < this.methodArguments.length; i++) {
        il.add(new VarInsnNode(Opcodes.ALOAD, parameterClassesIndex));
        il.add(TreeInstructions.getPushInstruction(i));
        il.add(TreeInstructions.getClassReferenceInstruction(methodArguments[i], cn.version & 0xFFFF));
        il.add(new InsnNode(Opcodes.AASTORE));
    }
    il.add(TreeInstructions.getClassConstantReference(this.classType, cn.version & 0xFFFF));
    il.add(new LdcInsnNode(this.mn.name));
    il.add(new VarInsnNode(Opcodes.ALOAD, parameterClassesIndex));
    il.add(new MethodInsnNode(Opcodes.INVOKESTATIC,
            "org/brutusin/instrumentation/utils/Helper", "getSource",
            "(Ljava/lang/Class;Ljava/lang/String;[Ljava/lang/Class;)Ljava/lang/Object;", false));
}
项目:evosuite    文件:TestRuntimeValuesDeterminer.java   
private InsnList localVarValue(AbstractInsnNode insnNode, int opositeOpcode, String param) {
    int varIdx = -1;
    if (insnNode instanceof VarInsnNode) {
        varIdx = ((VarInsnNode) insnNode).var;
    } else if (insnNode instanceof IincInsnNode) {
        varIdx = ((IincInsnNode) insnNode).var;
    } else {
        throw new RuntimeException("Not implemented for type " + insnNode.getClass());
    }
    InsnList instrumentation = new InsnList();
    MethodNode methodNode = (MethodNode) mv;
    if (methodNode.localVariables.size() <= varIdx) {
        throw new RuntimeException("varInsnNode is pointing outside of local variables!");
    }
    LocalVariableNode localVariableNode = getLocalVariableNode(varIdx, insnNode, methodNode);
    instrumentation.add(new VarInsnNode(opositeOpcode, varIdx));
    instrumentation.add(new LdcInsnNode(localVariableNode.name));
    instrumentation.add(new LdcInsnNode(currentLine));
    instrumentation.add(new MethodInsnNode(Opcodes.INVOKESTATIC,
            "org/evosuite/junit/TestRuntimeValuesDeterminer", "localVarValueChanged", "(" + param
                    + "Ljava/lang/String;I)V"));
    logger.debug("Adding localVarValueChanged for var {} in line {}.", localVariableNode.name, currentLine);
    return instrumentation;
}
项目:evosuite    文件:BooleanTestabilityTransformation.java   
/**
 * Insert a call to the isNull helper function
 * 
 * @param opcode
 * @param position
 * @param list
 */
public void insertPushNull(int opcode, JumpInsnNode position, InsnList list) {
    int branchId = getBranchID(currentMethodNode, position);
    logger.info("Inserting instrumentation for NULL check at branch " + branchId
            + " in method " + currentMethodNode.name);

    MethodInsnNode nullCheck = new MethodInsnNode(Opcodes.INVOKESTATIC,
            Type.getInternalName(BooleanHelper.class), "isNull",
            Type.getMethodDescriptor(Type.INT_TYPE,
                                     new Type[] { Type.getType(Object.class),
                                             Type.INT_TYPE }), false);
    list.insertBefore(position, new InsnNode(Opcodes.DUP));
    list.insertBefore(position, new LdcInsnNode(opcode));
    list.insertBefore(position, nullCheck);
    //list.insertBefore(position,
    //                  new LdcInsnNode(getBranchID(currentMethodNode, position)));
    insertBranchIdPlaceholder(currentMethodNode, position, branchId);
    MethodInsnNode push = new MethodInsnNode(Opcodes.INVOKESTATIC,
            Type.getInternalName(BooleanHelper.class), "pushPredicate",
            Type.getMethodDescriptor(Type.VOID_TYPE, new Type[] { Type.INT_TYPE,
                    Type.INT_TYPE }), false);
    list.insertBefore(position, push);

}
项目:evosuite    文件:BooleanTestabilityTransformation.java   
/**
 * Insert a call to the reference equality check helper function
 * 
 * @param opcode
 * @param position
 * @param list
 */
public void insertPushEquals(int opcode, JumpInsnNode position, InsnList list) {
    MethodInsnNode equalCheck = new MethodInsnNode(Opcodes.INVOKESTATIC,
            Type.getInternalName(BooleanHelper.class), "isEqual",
            Type.getMethodDescriptor(Type.INT_TYPE,
                                     new Type[] { Type.getType(Object.class),
                                             Type.getType(Object.class),
                                             Type.INT_TYPE }), false);
    list.insertBefore(position, new InsnNode(Opcodes.DUP2));
    list.insertBefore(position, new LdcInsnNode(opcode));
    list.insertBefore(position, equalCheck);
    //list.insertBefore(position,
    //                  new LdcInsnNode(getBranchID(currentMethodNode, position)));
    insertBranchIdPlaceholder(currentMethodNode, position);
    MethodInsnNode push = new MethodInsnNode(Opcodes.INVOKESTATIC,
            Type.getInternalName(BooleanHelper.class), "pushPredicate",
            Type.getMethodDescriptor(Type.VOID_TYPE, new Type[] { Type.INT_TYPE,
                    Type.INT_TYPE }), false);
    list.insertBefore(position, push);

}