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


Java TypeInsnNode类代码示例

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


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

示例1: newOperation

import jdk.internal.org.objectweb.asm.tree.TypeInsnNode; //导入依赖的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

示例2: newOperation

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