本文整理汇总了Java中org.apache.bcel.generic.Type.BYTE属性的典型用法代码示例。如果您正苦于以下问题:Java Type.BYTE属性的具体用法?Java Type.BYTE怎么用?Java Type.BYTE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.bcel.generic.Type
的用法示例。
在下文中一共展示了Type.BYTE属性的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getNativeValue
/**
* Returns a string representation of a given object native value.
*
* @param type - a Class object that wraps a data type.
* @param value - an object that wraps a value of a primitive data type.
* @return a string that represents a native data type.
*/
public static String getNativeValue(Type type, ConstantValue value) {
StringBuffer result = new StringBuffer();
if (type == Type.INT) {
result.append(value.toString()).append('L');
} else if (type == Type.BYTE) {
result.append(value.toString()).append('L');
} else if (type == Type.LONG) {
result.append(value.toString()).append("LL");
} else if (type == Type.FLOAT) {
result.append(value.toString()).append('f');
} else if (type == Type.DOUBLE) {
result.append(value.toString());
} else if (type == Type.SHORT) {
result.append(value.toString()).append('L');
} else if (type == Type.CHAR) {
result.append(value.toString()).append('L');
} else if (type == Type.BOOLEAN) {
result.append(value.toString()).append('L');
}
return result.toString();
}
示例2: getTypeForPrimitive
protected Type getTypeForPrimitive(Class<?> type) {
if (type == boolean.class) {
return Type.BOOLEAN;
} else if (type == byte.class) {
return Type.BYTE;
} else if (type == char.class) {
return Type.CHAR;
} else if (type == short.class) {
return Type.SHORT;
} else if (type == int.class) {
return Type.INT;
} else if (type == long.class) {
return Type.LONG;
} else if (type == float.class) {
return Type.FLOAT;
} else if (type == double.class) {
return Type.DOUBLE;
} else if (type == void.class) {
return Type.VOID;
}
return null;
}
示例3: set
/**
* Sets a new Type for the given local variable slot.
*/
public void set(int i, Type type){
if (type == Type.BYTE || type == Type.SHORT || type == Type.BOOLEAN || type == Type.CHAR){
throw new AssertionViolatedException("LocalVariables do not know about '"+type+"'. Use Type.INT instead.");
}
locals[i] = type;
}
示例4: generateReadCode
public void generateReadCode(InstructionList il, InstructionFactory factory, ConstantPoolGen cp, String className)
{
if (pointer)
{
((GenericRootClass) varClass).generateReadPointerCode(il, factory, cp);
}
else if (dim == 0)
{
varClass.generateReadCode(il, factory, cp);
}
else if (varCounter == null)
{
((IntrinsicRootClass) varClass).generateReadArrayCode(il, factory, cp, 1, new int[]{index});
}
else
{
BasicMember varMember = getMember(varCounter);
if (varMember == null) throw new RuntimeException("Cannot find variable counter "+varCounter);
Type varMemberType = varMember.getJavaType();
il.append(InstructionConstants.ALOAD_0);
il.append(factory.createInvoke(className, nameMangler.mangleMember(varCounter), varMemberType, Type.NO_ARGS, INVOKESPECIAL));
if (varMemberType != Type.INT && varMemberType != Type.BYTE && varMemberType != Type.CHAR && varMemberType != Type.SHORT)
il.append(factory.createCast(varMemberType, Type.INT));
BasicType type = (BasicType) varClass.getJavaType();
il.append(new NEWARRAY(type));
il.append(InstructionConstants.DUP_X1);
Type[] arrayArgType = new Type[] { new ArrayType(type, 1) };
il.append(factory.createInvoke("org.dianahep.root4j.core.RootInput", "readFixedArray", Type.VOID, arrayArgType, INVOKEINTERFACE));
}
if (varClass.getConvertMethod() != null)
{
il.append(factory.createInvoke("org.dianahep.root4j.interfaces." + varClass.getClassName(), varClass.getConvertMethod(), varClass.getJavaTypeForMethod(), Type.NO_ARGS, INVOKEINTERFACE));
}
}
示例5: getBCELPrimitiveType
/**
* Method getBCELPrimitiveType.
* Returns the BCEL Type given the Class Name
*
* @param javaDataType the java data type
* @return Type the BCEL type
*/
protected Type getBCELPrimitiveType(String javaDataType) {
switch (javaDataType.charAt(0)) {
case 'b':
if (javaDataType.charAt(1) == 'o') {
return Type.BOOLEAN;
} else {
return Type.BYTE;
}
case 'c':
case 'C':
return Type.CHAR;
case 's':
case 'S':
return Type.SHORT;
case 'i':
case 'I':
return Type.INT;
case 'l':
case 'L':
return Type.LONG;
case 'f':
case 'F':
return Type.FLOAT;
case 'd':
case 'D':
return Type.DOUBLE;
//boolean array appears in this format
case 'Z':
return Type.BOOLEAN;
case 'B':
return Type.BYTE;
case 'v':
case 'V':
return Type.VOID;
}
return null;
}
示例6: ByteClass
ByteClass()
{
super("Byte", Type.BYTE, Byte.TYPE, "readByte");
}
示例7: generateMethods
private static void generateMethods(RootClass k, ConstantPoolGen cp, InstructionList il, InstructionFactory factory, ClassGen cg, String className, Class implementedInterface)
{
RootMember[] members = k.getMembers();
for (int i = 0; i < members.length; i++)
{
Type type = ((BasicMember) members[i]).getJavaType();
Type returnType = type;
try
{
if (implementedInterface != null) returnType = Type.getType(implementedInterface.getMethod(nameMangler.mangleMember(members[i].getName()),(Class[]) null).getReturnType());
if (!returnType.equals(type) && debugRoot)
{
System.err.println("Warning: Interface type mismatch "+implementedInterface.getName()+"."+nameMangler.mangleMember(members[i].getName())+" "+returnType+" "+type);
}
}
catch (NoSuchMethodException x)
{
}
if (cg.containsMethod(nameMangler.mangleMember(members[i].getName()), "()" + returnType.getSignature()) == null)
{
MethodGen mg = new MethodGen(ACC_PUBLIC, returnType, null, null, nameMangler.mangleMember(members[i].getName()), null, il, cp);
if (members[i].getType() == null) // Dummy object
{
il.append(new PUSH(cp, "<<Unreadable>>"));
}
else
{
il.append(InstructionConstants.ALOAD_0);
il.append(factory.createGetField(className, members[i].getName(), type));
}
if (!returnType.equals(type) && !(returnType == Type.INT && (type == Type.BYTE || type == Type.CHAR || type == Type.SHORT)))
il.append(factory.createCast(type,returnType));
il.append(InstructionFactory.createReturn(returnType));
mg.setMaxStack();
mg.setMaxLocals();
cg.addMethod(mg.getMethod());
il.dispose();
}
}
}
示例8: getJNIType
/**
* Returns a JNI-style representation of the given data type passed
* as a Class object.
*
* @param type - a Class object that wraps a data type.
* @return a string that represents a JNI-style data type.
*/
public static String getJNIType(Type type) {
StringBuffer result = new StringBuffer();
String suffix = "";
if (type instanceof ArrayType) {
suffix = "Array";
type = ((ArrayType) type).getElementType();
}
if (type instanceof ObjectType) {
String objectType = "jobject";
// The suffix length is 0 only if the given type is not an array.
if (suffix.length() == 0) {
if (type.equals(Type.STRING)) {
objectType = "jstring";
} else if (type.equals(Type.THROWABLE)) {
objectType = "jthrowable";
} else if (((ObjectType) type).getClassName()
.equals("java.lang.Class")) {
objectType = "jclass";
}
}
result.append(objectType);
} else if (type == Type.INT) {
result.append("jint");
} else if (type == Type.BYTE) {
result.append("jbyte");
} else if (type == Type.LONG) {
result.append("jlong");
} else if (type == Type.FLOAT) {
result.append("jfloat");
} else if (type == Type.DOUBLE) {
result.append("jdouble");
} else if (type == Type.SHORT) {
result.append("jshort");
} else if (type == Type.CHAR) {
result.append("jchar");
} else if (type == Type.BOOLEAN) {
result.append("jboolean");
} else if (type == Type.VOID) {
result.append("void");
}
return result.append(suffix).toString();
}