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


Java CID.SHORT属性代码示例

本文整理汇总了Java中com.sun.squawk.vm.CID.SHORT属性的典型用法代码示例。如果您正苦于以下问题:Java CID.SHORT属性的具体用法?Java CID.SHORT怎么用?Java CID.SHORT使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在com.sun.squawk.vm.CID的用法示例。


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

示例1: getLocalTypeFor

/**
 * Gets the type of a local variable that is used to store a value of a
 * given class. This method partitions all classes into one of the
 * following categories:
 * <p><blockquote><pre>
 *
 *     Local Variable Type  |  Types
 *     ---------------------+-------
 *     INT                  | boolean, byte, short, int
 *     FLOAT                | float
 *     LONG                 | long
 *     DOUBLE               | double
 *     ADDRESS              | Address
 *     UWORD                | UWord
 *     OFFSET               | Offset
 *     REFERENCE            | types in java.lang.Object hierarchy
 *
 * </pre></blockquote><p>
 *
 * @param   type   the type of a value that will be stored in a local variable
 * @return  the local variable type for storing values of type <code>type</code>
 */
public static Klass getLocalTypeFor(Klass type) {
    switch (type.getSystemID()) {
        case CID.BOOLEAN:
        case CID.BYTE:
        case CID.SHORT:
        case CID.CHAR:
        case CID.INT: {
            return Klass.INT;
        }
        case CID.FLOAT:
        case CID.LONG:
        case CID.DOUBLE: {
            return type;
        }
        case CID.UWORD:
        case CID.OFFSET:
        case CID.ADDRESS: {
            return type;
        }
        default: {
            Assert.that(Klass.REFERENCE.isAssignableFrom(type));
            return Klass.REFERENCE;
        }
    }
}
 
开发者ID:tomatsu,项目名称:squawk,代码行数:47,代码来源:Frame.java

示例2: getFieldConstantValue

/**
 * Gets the object corresponding to the ConstantValue attribute for a field
 * if it has one.
 *
 * @param   fieldType the type of the field currently being loaded
 * @param   constantValueIndex the index of the ConstantValue attribute
 * @return  the value of the ConstantValue attribute or null if there is
 *                    no such attribute
 */
private Object getFieldConstantValue(Klass fieldType, int constantValueIndex) {
    if (constantValueIndex != 0) {
        /*
         * Verify that the initial value is of the right klass for the field
         */
        switch (fieldType.getSystemID()) {
            case CID.LONG:    return pool.getEntry(constantValueIndex, ConstantPool.CONSTANT_Long);
            case CID.FLOAT:   return pool.getEntry(constantValueIndex, ConstantPool.CONSTANT_Float);
            case CID.DOUBLE:  return pool.getEntry(constantValueIndex, ConstantPool.CONSTANT_Double);
            case CID.INT:     // fall through ...
            case CID.SHORT:   // fall through ...
            case CID.CHAR:    // fall through ...
            case CID.BYTE:    // fall through ...
            case CID.BOOLEAN: return pool.getEntry(constantValueIndex, ConstantPool.CONSTANT_Integer);
            case CID.STRING:  return pool.getEntry(constantValueIndex, ConstantPool.CONSTANT_String);
            default:          throw cfr.formatError("invalid ConstantValue attribute value");
        }
    } else {
        return null;
    }
}
 
开发者ID:tomatsu,项目名称:squawk,代码行数:30,代码来源:ClassFileLoader.java

示例3: getPrimitiveConstantValue

/**
     * Gets the constant value of a primitive static field.
     *
     * @return the constant value of this primitive static field
     */
    public long getPrimitiveConstantValue() {
        Assert.that(Modifier.hasConstant(modifiers));
        pos = signatureStart;
        int id = getSignatureType(readTypeID()).getSystemID();
        int dataSize = (signatureCount - 1);
        Assert.that(dataSize > 0);
        long value = 0;
        for (int bite = 0; bite != dataSize; ++bite) {
            int shift = bite * 8;
            long b = nextByte() & 0xFF;
            value |= (b << shift);
        }
        switch (id) {
            case CID.BOOLEAN:
            case CID.BYTE:    return (byte)value;
            case CID.CHAR:    return (char)value;
            case CID.SHORT:   return (short)value;
/*if[FLOATS]*/
            case CID.FLOAT:
/*end[FLOATS]*/
            case CID.INT:     return (int)value;
/*if[FLOATS]*/
            case CID.DOUBLE:
/*end[FLOATS]*/
            case CID.LONG:  return value;
            default:
                Assert.shouldNotReachHere(
/*if[DEBUG_CODE_ENABLED]*/
                                            "id = " + id
/*end[DEBUG_CODE_ENABLED]*/
                        );
                return 0;
        }
    }
 
开发者ID:tomatsu,项目名称:squawk,代码行数:39,代码来源:SymbolParser.java

示例4: getPrimitiveConstantValue

/**
     * Gets the constant value of a primitive static field.
     *
     * @return the constant value of this primitive static field
     */
    public long getPrimitiveConstantValue() {
        if (false) Assert.that(Modifier.hasConstant(modifiers));
        pos = signatureStart;
        int id = getSignatureType(readTypeID()).getSystemID();
        int dataSize = (signatureCount - 1);
        if (false) Assert.that(dataSize > 0);
        long value = 0;
        for (int bite = 0; bite != dataSize; ++bite) {
            int shift = bite * 8;
            long b = nextByte() & 0xFF;
            value |= (b << shift);
        }
        switch (id) {
            case CID.BOOLEAN:
            case CID.BYTE:    return (byte)value;
            case CID.CHAR:    return (char)value;
            case CID.SHORT:   return (short)value;

            case CID.FLOAT:

            case CID.INT:     return (int)value;

            case CID.DOUBLE:

            case CID.LONG:  return value;
            default:
                if (Assert.SHOULD_NOT_REACH_HERE_ALWAYS_ENABLED) Assert.shouldNotReachHere(

//                                            "id = " + id

                        );
                return 0;
        }
    }
 
开发者ID:sics-sse,项目名称:moped,代码行数:39,代码来源:SymbolParser.java

示例5: opc_getstatic

/**
     * Processes an instruction that pushes the value of a static field to
     * the operand stack.
     *
     * @param field  the referenced field
     */
    private void opc_getstatic(Field field) {
        if (field.hasConstant()) {
            if (VM.getCurrentIsolate().getLeafSuite().contains(field.getDefiningClass())) {
                // Class structure can be modified so set the flag indicating that it
                // should reify its constant fields when it is initialized.
            	// Assume that a class defined in another suite is NOT modifiable.
                field.getDefiningClass().updateModifiers(Modifier.COMPLETE_RUNTIME_STATICS);
            } else {
                // The Class object is read-only so replace 'getstatic' with
                // the appropriate load constant instruction
                if (field.getType().isPrimitive()) {
                    long value = field.getPrimitiveConstantValue();
                    switch (field.getType().getSystemID()) {
                        case CID.BYTE:
                        case CID.BOOLEAN:
                        case CID.SHORT:
                        case CID.CHAR:
                        case CID.INT: {
                            append(new ConstantInt(new Integer((int)value)));
                            return;
                        }
                        case CID.LONG:  {
                            append(new ConstantLong(new Long(value)));
                            return;
                        }
/*if[FLOATS]*/
                        case CID.FLOAT: {
                            append(new ConstantFloat(new Float(Float.intBitsToFloat((int)value))));
                            return;
                        }
                        case CID.DOUBLE: {
                            append(new ConstantDouble(new Double(Double.longBitsToDouble(value))));
                            return;
                        }
/*else[FLOATS]*/
//                          case CID.FLOAT:
//                          case CID.DOUBLE:
//                              Assert.shouldNotReachHere("floats not supported");
/*end[FLOATS]*/
                        default:
                            throw Assert.shouldNotReachHere();
                    }
                } else {
                    append(new ConstantObject(Klass.STRING, field.getStringConstantValue()));
                    return;
                }
            }
        }

        // java   getstatic stack ops: ... -> value (stack usage: 1)
        // squawk getstatic stack ops: ... -> value, or class_object -> value  (stack usage: 1)
        // so should not change max stack.

        GetStatic instruction = new GetStatic(field);
        append(instruction);
    }
 
开发者ID:tomatsu,项目名称:squawk,代码行数:62,代码来源:IRBuilder.java

示例6: opc_getstatic

/**
     * Processes an instruction that pushes the value of a static field to
     * the operand stack.
     *
     * @param field  the referenced field
     */
    private void opc_getstatic(Field field) {
        if (field.hasConstant()) {
            if (VM.getCurrentIsolate().getLeafSuite().contains(field.getDefiningClass())) {
                // Class structure can be modified so set the flag indicating that it
                // should reify its constant fields when it is initialized.
            	// Assume that a class defined in another suite is NOT modifiable.
                field.getDefiningClass().updateModifiers(Modifier.COMPLETE_RUNTIME_STATICS);
            } else {
                // The Class object is read-only so replace 'getstatic' with
                // the appropriate load constant instruction
                if (field.getType().isPrimitive()) {
                    long value = field.getPrimitiveConstantValue();
                    switch (field.getType().getSystemID()) {
                        case CID.BYTE:
                        case CID.BOOLEAN:
                        case CID.SHORT:
                        case CID.CHAR:
                        case CID.INT: {
                            append(new ConstantInt(new Integer((int)value)));
                            return;
                        }
                        case CID.LONG:  {
                            append(new ConstantLong(new Long(value)));
                            return;
                        }

                        case CID.FLOAT: {
                            append(new ConstantFloat(new Float(Float.intBitsToFloat((int)value))));
                            return;
                        }
                        case CID.DOUBLE: {
                            append(new ConstantDouble(new Double(Double.longBitsToDouble(value))));
                            return;
                        }

////                          case CID.FLOAT:
////                          case CID.DOUBLE:
////                              Assert.shouldNotReachHere("floats not supported");

                        default:
                            throw Assert.shouldNotReachHere();
                    }
                } else {
                    append(new ConstantObject(Klass.STRING, field.getStringConstantValue()));
                    return;
                }
            }
        }

        // java   getstatic stack ops: ... -> value (stack usage: 1)
        // squawk getstatic stack ops: ... -> value, or class_object -> value  (stack usage: 1)
        // so should not change max stack.

        GetStatic instruction = new GetStatic(field);
        append(instruction);
    }
 
开发者ID:sics-sse,项目名称:moped,代码行数:62,代码来源:IRBuilder.java


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