Java Code Examples for proguard.classfile.ClassConstants#INTERNAL_TYPE_LONG

The following examples show how to use proguard.classfile.ClassConstants#INTERNAL_TYPE_LONG . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ValueFactory.java    From java-n-IDE-for-Android with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a new Value of the given type.
 * The type must be a fully specified internal type for primitives, classes,
 * or arrays.
 */
public Value createValue(String type, Clazz referencedClass, boolean mayBeNull)
{
    switch (type.charAt(0))
    {
        case ClassConstants.INTERNAL_TYPE_VOID:    return null;
        case ClassConstants.INTERNAL_TYPE_BOOLEAN:
        case ClassConstants.INTERNAL_TYPE_BYTE:
        case ClassConstants.INTERNAL_TYPE_CHAR:
        case ClassConstants.INTERNAL_TYPE_SHORT:
        case ClassConstants.INTERNAL_TYPE_INT:     return createIntegerValue();
        case ClassConstants.INTERNAL_TYPE_LONG:    return createLongValue();
        case ClassConstants.INTERNAL_TYPE_FLOAT:   return createFloatValue();
        case ClassConstants.INTERNAL_TYPE_DOUBLE:  return createDoubleValue();
        default:                                   return createReferenceValue(ClassUtil.isInternalArrayType(type) ?
                                                                                   type :
                                                                                   ClassUtil.internalClassNameFromClassType(type),
                                                                               referencedClass,
                                                                               mayBeNull);
    }
}
 
Example 2
Source File: ClassUtil.java    From java-n-IDE-for-Android with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the size taken up on the stack by the given internal type.
 * The size is 1, except for long and double types, for which it is 2,
 * and for the void type, for which 0 is returned.
 * @param internalType the internal type,
 *                     e.g. "<code>I</code>".
 * @return the size taken up on the stack,
 *                     e.g. 1.
 */
public static int internalTypeSize(String internalType)
{
    if (internalType.length() == 1)
    {
        char internalPrimitiveType = internalType.charAt(0);
        if      (internalPrimitiveType == ClassConstants.INTERNAL_TYPE_LONG ||
                 internalPrimitiveType == ClassConstants.INTERNAL_TYPE_DOUBLE)
        {
            return 2;
        }
        else if (internalPrimitiveType == ClassConstants.INTERNAL_TYPE_VOID)
        {
            return 0;
        }
    }

    return 1;
}
 
Example 3
Source File: ProgramClassReader.java    From java-n-IDE-for-Android with Apache License 2.0 6 votes vote down vote up
private ElementValue createElementValue()
{
    int u1tag = dataInput.readUnsignedByte();

    switch (u1tag)
    {
        case ClassConstants.INTERNAL_TYPE_BOOLEAN:
        case ClassConstants.INTERNAL_TYPE_BYTE:
        case ClassConstants.INTERNAL_TYPE_CHAR:
        case ClassConstants.INTERNAL_TYPE_SHORT:
        case ClassConstants.INTERNAL_TYPE_INT:
        case ClassConstants.INTERNAL_TYPE_FLOAT:
        case ClassConstants.INTERNAL_TYPE_LONG:
        case ClassConstants.INTERNAL_TYPE_DOUBLE:
        case ClassConstants.ELEMENT_VALUE_STRING_CONSTANT: return new ConstantElementValue(u1tag);

        case ClassConstants.ELEMENT_VALUE_ENUM_CONSTANT:   return new EnumConstantElementValue();
        case ClassConstants.ELEMENT_VALUE_CLASS:           return new ClassElementValue();
        case ClassConstants.ELEMENT_VALUE_ANNOTATION:      return new AnnotationElementValue();
        case ClassConstants.ELEMENT_VALUE_ARRAY:           return new ArrayElementValue();

        default: throw new IllegalArgumentException("Unknown element value tag ["+u1tag+"]");
    }
}
 
Example 4
Source File: ClassUtil.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
/**
 * Returns whether the given internal type is a plain primitive type
 * (not void).
 * @param internalType the internal type,
 *                     e.g. "<code>I</code>".
 * @return <code>true</code> if the given type is a class type,
 *         <code>false</code> otherwise.
 */
public static boolean isInternalPrimitiveType(char internalType)
{
    return internalType == ClassConstants.INTERNAL_TYPE_BOOLEAN ||
           internalType == ClassConstants.INTERNAL_TYPE_BYTE    ||
           internalType == ClassConstants.INTERNAL_TYPE_CHAR    ||
           internalType == ClassConstants.INTERNAL_TYPE_SHORT   ||
           internalType == ClassConstants.INTERNAL_TYPE_INT     ||
           internalType == ClassConstants.INTERNAL_TYPE_FLOAT   ||
           internalType == ClassConstants.INTERNAL_TYPE_LONG    ||
           internalType == ClassConstants.INTERNAL_TYPE_DOUBLE;
}
 
Example 5
Source File: FieldOptimizationInfo.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
private Value initialValue(String type)
{
    switch (type.charAt(0))
    {
        case ClassConstants.INTERNAL_TYPE_BOOLEAN:
        case ClassConstants.INTERNAL_TYPE_BYTE:
        case ClassConstants.INTERNAL_TYPE_CHAR:
        case ClassConstants.INTERNAL_TYPE_SHORT:
        case ClassConstants.INTERNAL_TYPE_INT:
            return VALUE_FACTORY.createIntegerValue(0);

        case ClassConstants.INTERNAL_TYPE_LONG:
            return VALUE_FACTORY.createLongValue(0L);

        case ClassConstants.INTERNAL_TYPE_FLOAT:
            return VALUE_FACTORY.createFloatValue(0.0f);

        case ClassConstants.INTERNAL_TYPE_DOUBLE:
            return VALUE_FACTORY.createDoubleValue(0.0);

        case ClassConstants.INTERNAL_TYPE_CLASS_START:
        case ClassConstants.INTERNAL_TYPE_ARRAY:
            return VALUE_FACTORY.createReferenceValueNull();

        default:
            throw new IllegalArgumentException("Invalid type ["+type+"]");
    }
}
 
Example 6
Source File: InstructionUtil.java    From java-n-IDE-for-Android with Apache License 2.0 4 votes vote down vote up
/**
 * Returns the internal type corresponding to the given 'newarray' type.
 * @param arrayType <code>InstructionConstants.ARRAY_T_BOOLEAN</code>,
 *                  <code>InstructionConstants.ARRAY_T_BYTE</code>,
 *                  <code>InstructionConstants.ARRAY_T_CHAR</code>,
 *                  <code>InstructionConstants.ARRAY_T_SHORT</code>,
 *                  <code>InstructionConstants.ARRAY_T_INT</code>,
 *                  <code>InstructionConstants.ARRAY_T_LONG</code>,
 *                  <code>InstructionConstants.ARRAY_T_FLOAT</code>, or
 *                  <code>InstructionConstants.ARRAY_T_DOUBLE</code>.
 * @return <code>ClassConstants.INTERNAL_TYPE_BOOLEAN</code>,
 *         <code>ClassConstants.INTERNAL_TYPE_BYTE</code>,
 *         <code>ClassConstants.INTERNAL_TYPE_CHAR</code>,
 *         <code>ClassConstants.INTERNAL_TYPE_SHORT</code>,
 *         <code>ClassConstants.INTERNAL_TYPE_INT</code>,
 *         <code>ClassConstants.INTERNAL_TYPE_LONG</code>,
 *         <code>ClassConstants.INTERNAL_TYPE_FLOAT</code>, or
 *         <code>ClassConstants.INTERNAL_TYPE_DOUBLE</code>.
 */
public static char internalTypeFromArrayType(byte arrayType)
{
    switch (arrayType)
    {
        case InstructionConstants.ARRAY_T_BOOLEAN: return ClassConstants.INTERNAL_TYPE_BOOLEAN;
        case InstructionConstants.ARRAY_T_CHAR:    return ClassConstants.INTERNAL_TYPE_CHAR;
        case InstructionConstants.ARRAY_T_FLOAT:   return ClassConstants.INTERNAL_TYPE_FLOAT;
        case InstructionConstants.ARRAY_T_DOUBLE:  return ClassConstants.INTERNAL_TYPE_DOUBLE;
        case InstructionConstants.ARRAY_T_BYTE:    return ClassConstants.INTERNAL_TYPE_BYTE;
        case InstructionConstants.ARRAY_T_SHORT:   return ClassConstants.INTERNAL_TYPE_SHORT;
        case InstructionConstants.ARRAY_T_INT:     return ClassConstants.INTERNAL_TYPE_INT;
        case InstructionConstants.ARRAY_T_LONG:    return ClassConstants.INTERNAL_TYPE_LONG;
        default: throw new IllegalArgumentException("Unknown array type ["+arrayType+"]");
    }
}
 
Example 7
Source File: ClassUtil.java    From java-n-IDE-for-Android with Apache License 2.0 3 votes vote down vote up
/**
 * Returns whether the given internal type is a primitive Category 2 type.
 * @param internalType the internal type,
 *                     e.g. "<code>L</code>".
 * @return <code>true</code> if the given type is a Category 2 type,
 *         <code>false</code> otherwise.
 */
public static boolean isInternalCategory2Type(String internalType)
{
    return internalType.length() == 1 &&
           (internalType.charAt(0) == ClassConstants.INTERNAL_TYPE_LONG ||
            internalType.charAt(0) == ClassConstants.INTERNAL_TYPE_DOUBLE);
}