本文整理汇总了Java中com.android.dx.rop.type.Type.getBasicType方法的典型用法代码示例。如果您正苦于以下问题:Java Type.getBasicType方法的具体用法?Java Type.getBasicType怎么用?Java Type.getBasicType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.android.dx.rop.type.Type
的用法示例。
在下文中一共展示了Type.getBasicType方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: opNewArray
import com.android.dx.rop.type.Type; //导入方法依赖的package包/类
/**
* Returns the appropriate {@code new-array} rop for the given
* type. The result is a shared instance.
*
* @param arrayType {@code non-null;} array type of array being created
* @return {@code non-null;} an appropriate instance
*/
public static Rop opNewArray(TypeBearer arrayType) {
Type type = arrayType.getType();
Type elementType = type.getComponentType();
switch (elementType.getBasicType()) {
case Type.BT_INT: return NEW_ARRAY_INT;
case Type.BT_LONG: return NEW_ARRAY_LONG;
case Type.BT_FLOAT: return NEW_ARRAY_FLOAT;
case Type.BT_DOUBLE: return NEW_ARRAY_DOUBLE;
case Type.BT_BOOLEAN: return NEW_ARRAY_BOOLEAN;
case Type.BT_BYTE: return NEW_ARRAY_BYTE;
case Type.BT_CHAR: return NEW_ARRAY_CHAR;
case Type.BT_SHORT: return NEW_ARRAY_SHORT;
case Type.BT_OBJECT: {
return new Rop(RegOps.NEW_ARRAY, type, StdTypeList.INT,
Exceptions.LIST_Error_NegativeArraySizeException,
"new-array-object");
}
}
return throwBadType(type);
}
示例2: forBoxedPrimitiveType
import com.android.dx.rop.type.Type; //导入方法依赖的package包/类
/**
* Returns an instance of this class that represents the wrapper
* class corresponding to a given primitive type. For example, if
* given {@link Type#INT}, this method returns the class reference
* {@code java.lang.Integer}.
*
* @param primitiveType {@code non-null;} the primitive type
* @return {@code non-null;} the corresponding wrapper class
*/
public static CstType forBoxedPrimitiveType(Type primitiveType) {
switch (primitiveType.getBasicType()) {
case Type.BT_BOOLEAN: return BOOLEAN;
case Type.BT_BYTE: return BYTE;
case Type.BT_CHAR: return CHARACTER;
case Type.BT_DOUBLE: return DOUBLE;
case Type.BT_FLOAT: return FLOAT;
case Type.BT_INT: return INTEGER;
case Type.BT_LONG: return LONG;
case Type.BT_SHORT: return SHORT;
case Type.BT_VOID: return VOID;
}
throw new IllegalArgumentException("not primitive: " + primitiveType);
}
示例3: zeroFor
import com.android.dx.rop.type.Type; //导入方法依赖的package包/类
/**
* Gets the "zero" (or {@code null}) value for the given type.
*
* @param type {@code non-null;} the type in question
* @return {@code non-null;} its "zero" value
*/
public static Constant zeroFor(Type type) {
switch (type.getBasicType()) {
case Type.BT_BOOLEAN: return CstBoolean.VALUE_FALSE;
case Type.BT_BYTE: return CstByte.VALUE_0;
case Type.BT_CHAR: return CstChar.VALUE_0;
case Type.BT_DOUBLE: return CstDouble.VALUE_0;
case Type.BT_FLOAT: return CstFloat.VALUE_0;
case Type.BT_INT: return CstInteger.VALUE_0;
case Type.BT_LONG: return CstLong.VALUE_0;
case Type.BT_SHORT: return CstShort.VALUE_0;
case Type.BT_OBJECT: return CstKnownNull.THE_ONE;
default: {
throw new UnsupportedOperationException("no zero for type: " +
type.toHuman());
}
}
}
示例4: coerceConstant
import com.android.dx.rop.type.Type; //导入方法依赖的package包/类
/**
* Helper for {@link #processFields}, which translates constants into
* more specific types if necessary.
*
* @param constant {@code non-null;} the constant in question
* @param type {@code non-null;} the desired type
*/
private static TypedConstant coerceConstant(TypedConstant constant,
Type type) {
Type constantType = constant.getType();
if (constantType.equals(type)) {
return constant;
}
switch (type.getBasicType()) {
case Type.BT_BOOLEAN: {
return CstBoolean.make(((CstInteger) constant).getValue());
}
case Type.BT_BYTE: {
return CstByte.make(((CstInteger) constant).getValue());
}
case Type.BT_CHAR: {
return CstChar.make(((CstInteger) constant).getValue());
}
case Type.BT_SHORT: {
return CstShort.make(((CstInteger) constant).getValue());
}
default: {
throw new UnsupportedOperationException("can't coerce " +
constant + " to " + type);
}
}
}