当前位置: 首页>>代码示例>>Java>>正文


Java LdcInsnNode类代码示例

本文整理汇总了Java中jdk.internal.org.objectweb.asm.tree.LdcInsnNode的典型用法代码示例。如果您正苦于以下问题:Java LdcInsnNode类的具体用法?Java LdcInsnNode怎么用?Java LdcInsnNode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


LdcInsnNode类属于jdk.internal.org.objectweb.asm.tree包,在下文中一共展示了LdcInsnNode类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: newOperation

import jdk.internal.org.objectweb.asm.tree.LdcInsnNode; //导入依赖的package包/类
@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);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:23,代码来源:SourceInterpreter.java

示例2: analyse

import jdk.internal.org.objectweb.asm.tree.LdcInsnNode; //导入依赖的package包/类
@Override
protected String analyse(ClassNode node) {
    System.out.println("[ Actor ]\n^ " + node.name + " extends " + node.superName);
    node.interfaces.add("org/beatbot/injection/interfaces/IActor");
    List<List<AbstractInsnNode>> results = Assembly.findAll(node, Mask.GETFIELD.describe("I"),Mask.LDC.distance(1), Mask.IMUL.distance(1), Mask.LDC.distance(1),Mask.INVOKESTATIC.distance(1));
    if(results != null)
    {
        for(List<AbstractInsnNode> insns : results)
        {
            FieldInsnNode fin = (FieldInsnNode) insns.get(0);
            LdcInsnNode ldc = (LdcInsnNode) insns.get(1);
            //public static void addMethod(ClassNode node, String owner,String fieldName, String fieldDesc, String methodName, String returnType,int multiplier,boolean statc)
            GenericUtils.addMethod(node,fin.owner,fin.name,fin.desc,"getAnimation","()I",(int)ldc.cst,false);
            System.out.println("    * getAnimation() -> " + fin.desc + " " + fin.owner + "." + fin.name+ " * " + ldc.cst);
            break;
        }
    }

    classnames.put("Actor", node.name);
    classnode = node;
    return "Actor";
}
 
开发者ID:Snorflake,项目名称:BeatBot,代码行数:23,代码来源:ActorAnalyzer.java

示例3: newOperation

import jdk.internal.org.objectweb.asm.tree.LdcInsnNode; //导入依赖的package包/类
@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);
}
 
开发者ID:wro4j,项目名称:nashorn-backport,代码行数:23,代码来源:SourceInterpreter.java

示例4: newOperation

import jdk.internal.org.objectweb.asm.tree.LdcInsnNode; //导入依赖的package包/类
@Override
public BasicValue newOperation(final AbstractInsnNode insn)
        throws AnalyzerException {
    switch (insn.getOpcode()) {
    case ACONST_NULL:
        return newValue(Type.getObjectType("null"));
    case ICONST_M1:
    case ICONST_0:
    case ICONST_1:
    case ICONST_2:
    case ICONST_3:
    case ICONST_4:
    case ICONST_5:
        return BasicValue.INT_VALUE;
    case LCONST_0:
    case LCONST_1:
        return BasicValue.LONG_VALUE;
    case FCONST_0:
    case FCONST_1:
    case FCONST_2:
        return BasicValue.FLOAT_VALUE;
    case DCONST_0:
    case DCONST_1:
        return BasicValue.DOUBLE_VALUE;
    case BIPUSH:
    case SIPUSH:
        return BasicValue.INT_VALUE;
    case LDC:
        Object cst = ((LdcInsnNode) insn).cst;
        if (cst instanceof Integer) {
            return BasicValue.INT_VALUE;
        } else if (cst instanceof Float) {
            return BasicValue.FLOAT_VALUE;
        } else if (cst instanceof Long) {
            return BasicValue.LONG_VALUE;
        } else if (cst instanceof Double) {
            return BasicValue.DOUBLE_VALUE;
        } else if (cst instanceof String) {
            return newValue(Type.getObjectType("java/lang/String"));
        } else if (cst instanceof Type) {
            int sort = ((Type) cst).getSort();
            if (sort == Type.OBJECT || sort == Type.ARRAY) {
                return newValue(Type.getObjectType("java/lang/Class"));
            } else if (sort == Type.METHOD) {
                return newValue(Type
                        .getObjectType("java/lang/invoke/MethodType"));
            } else {
                throw new IllegalArgumentException("Illegal LDC constant "
                        + cst);
            }
        } else if (cst instanceof Handle) {
            return newValue(Type
                    .getObjectType("java/lang/invoke/MethodHandle"));
        } else {
            throw new IllegalArgumentException("Illegal LDC constant "
                    + cst);
        }
    case JSR:
        return BasicValue.RETURNADDRESS_VALUE;
    case GETSTATIC:
        return newValue(Type.getType(((FieldInsnNode) insn).desc));
    case NEW:
        return newValue(Type.getObjectType(((TypeInsnNode) insn).desc));
    default:
        throw new Error("Internal error.");
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:68,代码来源:BasicInterpreter.java

示例5: replaceWithClassConstant

import jdk.internal.org.objectweb.asm.tree.LdcInsnNode; //导入依赖的package包/类
public static Data replaceWithClassConstant(ClassNode cn, MethodNode m,
        TypeResolver cch)
        throws Exception {
    Iterator<AbstractInsnNode> it = m.instructions.iterator();
    LdcInsnNode insNode = null;
    Map<LdcInsnNode, LdcInsnNode> replacement = new IdentityHashMap<>();
    Data data = new Data();
    while (it.hasNext()) {
        AbstractInsnNode n = it.next();
        if (n instanceof LdcInsnNode) {
            LdcInsnNode ldc = (LdcInsnNode) n;
            if (ldc.cst instanceof String) {
                insNode = ldc;
            }
        } else {
            if (n instanceof MethodInsnNode && insNode != null) {
                MethodInsnNode met = (MethodInsnNode) n;
                if (met.name.equals("forName")
                        && met.owner.equals("java/lang/Class")
                        && met.desc.equals("(Ljava/lang/String;)Ljava/lang/Class;")) {
                    // Can we load the type?
                    Type type = null;
                    String binaryName = insNode.cst.toString().replaceAll("\\.", "/");
                    String unaryClassName = binaryName;
                    int arrayIndex = binaryName.lastIndexOf("[");
                    if (arrayIndex >= 0) {
                        int objIndex = unaryClassName.indexOf("L");
                        if (objIndex >= 0) {
                            unaryClassName = unaryClassName.substring(objIndex + 1);
                            unaryClassName = unaryClassName.substring(0,
                                    unaryClassName.length() - 1);
                        } else {
                            //primitive, this is just fine.
                            type = Type.getObjectType(binaryName);
                        }
                    }
                    if (type == null) {
                        if (cch.resolve(cn, m, unaryClassName) != null) {
                            type = Type.getObjectType(binaryName);
                        }
                    }
                    if (type != null) {
                        replacement.put(insNode, new LdcInsnNode(type));
                        it.remove();
                        data.removedInstructions += 1;
                    }
                } else {
                    insNode = null;
                }
                // Virtual node, not taken into account
            } else if (!(n instanceof LabelNode) && !(n instanceof LineNumberNode)) {
                insNode = null;
            }
        }
    }
    for (Map.Entry<LdcInsnNode, LdcInsnNode> entry : replacement.entrySet()) {
        m.instructions.set(entry.getKey(), entry.getValue());
    }
    if (!replacement.isEmpty()) {
        String[] types = {"java/lang/ClassNotFoundException"};
        data.removedInstructions += deleteExceptionHandlers(cch, data, cn, m, types);

    }
    return data;
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:66,代码来源:ReflectionOptimizer.java

示例6: newOperation

import jdk.internal.org.objectweb.asm.tree.LdcInsnNode; //导入依赖的package包/类
@Override
public BasicValue newOperation(final AbstractInsnNode insn)
        throws AnalyzerException
{
    switch (insn.getOpcode()) {
        case ACONST_NULL:
            return newValue(Type.getObjectType("null"));
        case ICONST_M1:
        case ICONST_0:
        case ICONST_1:
        case ICONST_2:
        case ICONST_3:
        case ICONST_4:
        case ICONST_5:
            return BasicValue.INT_VALUE;
        case LCONST_0:
        case LCONST_1:
            return BasicValue.LONG_VALUE;
        case FCONST_0:
        case FCONST_1:
        case FCONST_2:
            return BasicValue.FLOAT_VALUE;
        case DCONST_0:
        case DCONST_1:
            return BasicValue.DOUBLE_VALUE;
        case BIPUSH:
        case SIPUSH:
            return BasicValue.INT_VALUE;
        case LDC:
            Object cst = ((LdcInsnNode) insn).cst;
            if (cst instanceof Integer) {
                return BasicValue.INT_VALUE;
            } else if (cst instanceof Float) {
                return BasicValue.FLOAT_VALUE;
            } else if (cst instanceof Long) {
                return BasicValue.LONG_VALUE;
            } else if (cst instanceof Double) {
                return BasicValue.DOUBLE_VALUE;
            } else if (cst instanceof String) {
                return newValue(Type.getObjectType("java/lang/String"));
            } else if (cst instanceof Type) {
                int sort = ((Type) cst).getSort();
                if (sort == Type.OBJECT || sort == Type.ARRAY) {
                    return newValue(Type.getObjectType("java/lang/Class"));
                } else if (sort == Type.METHOD) {
                    return newValue(Type.getObjectType("java/lang/invoke/MethodType"));
                } else {
                    throw new IllegalArgumentException("Illegal LDC constant " + cst);
                }
            } else if (cst instanceof Handle) {
                return newValue(Type.getObjectType("java/lang/invoke/MethodHandle"));
            } else {
                throw new IllegalArgumentException("Illegal LDC constant " + cst);
            }
        case JSR:
            return BasicValue.RETURNADDRESS_VALUE;
        case GETSTATIC:
            return newValue(Type.getType(((FieldInsnNode) insn).desc));
        case NEW:
            return newValue(Type.getObjectType(((TypeInsnNode) insn).desc));
        default:
            throw new Error("Internal error.");
    }
}
 
开发者ID:wro4j,项目名称:nashorn-backport,代码行数:65,代码来源:BasicInterpreter.java


注:本文中的jdk.internal.org.objectweb.asm.tree.LdcInsnNode类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。