本文整理汇总了Java中org.apache.bcel.generic.Type.INT属性的典型用法代码示例。如果您正苦于以下问题:Java Type.INT属性的具体用法?Java Type.INT怎么用?Java Type.INT使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.bcel.generic.Type
的用法示例。
在下文中一共展示了Type.INT属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: createInstructionPush
private CompoundInstruction createInstructionPush(Element inst) throws IllegalXMLVMException {
String t = inst.getAttributeValue("type");
Type type = parseTypeString(t);
String value = inst.getAttributeValue("value");
if (type == Type.STRING)
return new PUSH(constantPoolGen, value);
else if (type == Type.INT)
return new PUSH(constantPoolGen, Integer.parseInt(value));
else if (type == Type.FLOAT)
return new PUSH(constantPoolGen, Float.parseFloat(value));
else if (type == Type.DOUBLE)
return new PUSH(constantPoolGen, Double.parseDouble(value));
else if (type == Type.LONG)
return new PUSH(constantPoolGen, Long.parseLong(value));
else
throw new IllegalXMLVMException(inst.getName() + " with bad type '" + t + "'");
}
示例3: 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;
}
示例4: mergeTypes
public Type mergeTypes(Type a, Type b) throws DataflowAnalysisException {
byte aType = a.getType(), bType = b.getType();
if (aType == T_TOP) // Top is the identity element
return b;
else if (bType == T_TOP) // Top is the identity element
return a;
else if (aType == T_BOTTOM || bType == T_BOTTOM) // Bottom meet anything is bottom
return BottomType.instance();
else if (isReferenceType(aType) && isReferenceType(bType)) { // Two object types!
// Handle the Null type, which serves as a special "top"
// value for reference types.
if (aType == T_NULL)
return b;
else if (bType == T_NULL)
return a;
ReferenceType aRef = (ReferenceType) a;
ReferenceType bRef = (ReferenceType) b;
return mergeReferenceTypes(aRef, bRef);
} else if (isReferenceType(aType) || isReferenceType(bType)) // Object meet non-object is bottom
return BottomType.instance();
else if (aType == bType) // Same non-object type?
return a;
else if (isIntegerType(aType) && isIntegerType(bType)) // Two different integer types - use T_INT
return Type.INT;
else // Default - types are incompatible
return BottomType.instance();
}
示例5: 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));
}
}
示例6: 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;
}
示例7: mergeTypes
public Type mergeTypes(Type a, Type b) throws DataflowAnalysisException {
byte aType = a.getType(), bType = b.getType();
if (aType == T_TOP) // Top is the identity element
return b;
else if (bType == T_TOP) // Top is the identity element
return a;
else if (aType == T_BOTTOM || bType == T_BOTTOM) // Bottom meet anything
// is bottom
return BottomType.instance();
else if (isReferenceType(aType) && isReferenceType(bType)) { // Two
// object
// types!
// Handle the Null type, which serves as a special "top"
// value for reference types.
if (aType == T_NULL)
return b;
else if (bType == T_NULL)
return a;
ReferenceType aRef = (ReferenceType) a;
ReferenceType bRef = (ReferenceType) b;
return mergeReferenceTypes(aRef, bRef);
} else if (isReferenceType(aType) || isReferenceType(bType)) // Object
// meet
// non-object
// is
// bottom
return BottomType.instance();
else if (aType == bType) // Same non-object type?
return a;
else if (isIntegerType(aType) && isIntegerType(bType)) // Two different
// integer types
// - use T_INT
return Type.INT;
else
// Default - types are incompatible
return BottomType.instance();
}
示例8: setUp
@Override
protected void setUp() throws Exception {
super.setUp();
typeSerializable = ObjectTypeFactory.getInstance("java.io.Serializable");
typeClonable = ObjectTypeFactory.getInstance("java.lang.Cloneable");
typeObject = ObjectTypeFactory.getInstance("java.lang.Object");
typeInteger = ObjectTypeFactory.getInstance("java.lang.Integer");
typeString = ObjectTypeFactory.getInstance("java.lang.String");
typeComparable = ObjectTypeFactory.getInstance("java.lang.Comparable");
typeList = ObjectTypeFactory.getInstance("java.util.List");
typeCollection = ObjectTypeFactory.getInstance("java.util.Collection");
typeHashSet = ObjectTypeFactory.getInstance("java.util.HashSet");
typeArrayClonable = new ArrayType(typeClonable, 1);
typeArrayComparable = new ArrayType(typeComparable, 1);
typeArrayObject = new ArrayType(typeObject, 1);
typeArrayInteger = new ArrayType(typeInteger, 1);
typeArrayString = new ArrayType(typeString, 1);
typeArrayArrayObject = new ArrayType(typeObject, 2);
typeArrayArraySerializable = new ArrayType(typeSerializable, 2);
typeArrayArrayString = new ArrayType(typeString, 2);
typeArrayInt = new ArrayType(Type.INT, 1);
typeArrayArrayInt = new ArrayType(Type.INT, 2);
typeArrayArrayArrayInt = new ArrayType(Type.INT, 3);
typeArrayChar = new ArrayType(Type.CHAR, 1);
typeArrayArrayChar = new ArrayType(Type.CHAR, 2);
typeArrayArrayArrayChar = new ArrayType(Type.CHAR, 3);
typeDynamicString = new FindRefComparison.DynamicStringType();
typeStaticString = new FindRefComparison.StaticStringType();
typeParameterString = new FindRefComparison.ParameterStringType();
}
示例9: generateMethods
private void generateMethods(RootClass k, ConstantPoolGen cp, InstructionList il, InstructionFactory factory, ClassGen cg, String className)
{
RootMember[] members = k.getMembers();
for (int i = 0; i < members.length; i++)
{
BasicMember member = (BasicMember) members[i];
TLeaf leaf = (TLeaf) lMap.get(member);
if (leaf == null) continue;
String leafClassName = leaf.getClass().getName();
Type type = member.getJavaType();
Type arrayType = new ArrayType(type, 1);
MethodGen mg = new MethodGen(ACC_PUBLIC, type, new Type[] { Type.INT }, new String[]
{
"index"
}, nameMangler.mangleMember(member.getName()), className, il, cp);
il.append(InstructionConstants.ALOAD_0);
il.append(factory.createGetField(className, member.getName(), arrayType));
il.append(InstructionFactory.DUP);
BranchHandle bh = il.append(new IFNONNULL(null));
il.append(InstructionFactory.POP);
il.append(factory.createGetStatic(className, member.getName() + "Leaf", new ObjectType(leafClassName)));
il.append(InstructionConstants.ALOAD_0);
il.append(factory.createGetField("org.dianahep.root4j.core.Clones2", "hollowIndex", Type.LONG));
// BasicRootClass varClass = (BasicRootClass) member.getType();
il.append(factory.createInvoke(leafClassName, "setPosition", new ObjectType("org.dianahep.root4j.core.RootInput"), new Type[]
{
Type.LONG
}, INVOKEVIRTUAL));
il.append(InstructionConstants.ALOAD_0);
il.append(factory.createGetField("org.dianahep.root4j.core.Clones2", "size", Type.INT));
il.append((Instruction) factory.createNewArray(type, (short) 1));
il.append(InstructionConstants.DUP_X1);
il.append(factory.createInvoke("org.dianahep.root4j.core.RootInput", "readFixedArray", Type.VOID, new Type[]
{
arrayType
}, INVOKEINTERFACE));
il.append(InstructionConstants.DUP);
il.append(InstructionConstants.ALOAD_0);
il.append(InstructionConstants.SWAP);
il.append(factory.createPutField(className, member.getName(), arrayType));
bh.setTarget(il.append(InstructionConstants.ILOAD_1));
il.append(InstructionFactory.createArrayLoad(type));
il.append(InstructionFactory.createReturn(type));
mg.setMaxStack();
mg.setMaxLocals();
cg.addMethod(mg.getMethod());
il.dispose();
}
}
示例10: build
public JavaClass build(GenericRootClass klass)
{
optimize = (klass.getStreamerInfo().getBits() & (1 << 12)) == 0;
String className = nameMangler.mangleFullClassName(getStem(),klass.getClassName());
String clonesClassName = nameMangler.mangleFullClassName("org.dianahep.root4j.clones2",klass.getClassName());
ClassGen cg = new ClassGen(className, "org/dianahep/root4j/core/Clone2", "<generated>", ACC_PUBLIC | ACC_SUPER, new String[]
{
nameMangler.mangleInterfaceName(klass.getClassName())
});
ConstantPoolGen cp = cg.getConstantPool();
InstructionList il = new InstructionList();
InstructionFactory factory = new InstructionFactory(cg);
cg.addEmptyConstructor(ACC_PUBLIC);
// Build the complete list of superclasses
List sup = new ArrayList();
RootClass[] superClasses = klass.getSuperClasses();
iterativelyAdd(sup, superClasses);
sup.add(klass);
// Create the fields
cg.addField(new FieldGen(ACC_PRIVATE, Type.INT, "index", cp).getField());
cg.addField(new FieldGen(ACC_PRIVATE, new ObjectType(clonesClassName), "clones", cp).getField());
//Generate the setData method
MethodGen mg = new MethodGen(ACC_PUBLIC, Type.VOID, new Type[]
{
Type.INT, new ObjectType("org.dianahep.root4j.core.Clones2")
}, new String[] { "index", "clones" }, "setData", className, il, cp);
il.append(InstructionConstants.ALOAD_0);
il.append(InstructionConstants.ILOAD_1);
il.append(factory.createPutField(className, "index", Type.INT));
il.append(InstructionConstants.ALOAD_0);
il.append(InstructionConstants.ALOAD_2);
il.append(factory.createCast(new ObjectType("org.dianahep.root4j.core.Clones2"), new ObjectType(clonesClassName)));
il.append(factory.createPutField(className, "clones", new ObjectType(clonesClassName)));
il.append(InstructionConstants.RETURN);
mg.setMaxStack();
mg.setMaxLocals();
cg.addMethod(mg.getMethod());
il.dispose();
// Generate the accessor methods
for (Iterator i = sup.iterator(); i.hasNext();)
generateMethods((RootClass) i.next(), cp, il, factory, cg, className, clonesClassName);
return cg.getJavaClass();
}
示例11: build
public JavaClass build(GenericRootClass klass)
{
optimize = (klass.getStreamerInfo().getBits() & (1 << 12)) == 0;
//System.out.println("bits=" + Integer.toHexString(klass.getStreamerInfo().getBits()) + " optimize=" + optimize);
String className = nameMangler.mangleFullClassName(getStem(),klass.getClassName());
ClassGen cg = new ClassGen(className, "org/dianahep/root4j/core/Clones", "<generated>", ACC_PUBLIC | ACC_SUPER, null);
ConstantPoolGen cp = cg.getConstantPool();
InstructionList il = new InstructionList();
InstructionFactory factory = new InstructionFactory(cg);
cg.addEmptyConstructor(ACC_PUBLIC);
// Build the complete list of superclasses
List sup = new ArrayList();
RootClass[] superClasses = klass.getSuperClasses();
iterativelyAdd(sup, superClasses);
sup.add(klass);
// Generate the fields
for (Iterator i = sup.iterator(); i.hasNext();)
generateFields((RootClass) i.next(), cp, cg);
// Generate the streamer method
MethodGen mg = new MethodGen(ACC_PUBLIC, Type.VOID, new Type[]
{
new ObjectType("org/dianahep/root4j/core/RootInput"), Type.INT
}, new String[] { "in", "nClones" }, "read", className, il, cp);
mg.addException("java/io/IOException");
for (Iterator i = sup.iterator(); i.hasNext();)
generateStreamer((RootClass) i.next(), cp, il, factory, className);
il.append(new RETURN());
mg.setMaxStack();
mg.setMaxLocals();
cg.addMethod(mg.getMethod());
il.dispose();
return cg.getJavaClass();
}
示例12: IntegerClass
IntegerClass()
{
super("Integer", Type.INT, Integer.TYPE, "readInt");
}
示例13: build
public JavaClass build(GenericRootClass klass)
{
optimize = (klass.getStreamerInfo().getBits() & (1 << 12)) == 0;
String className = nameMangler.mangleFullClassName(getStem(),klass.getClassName());
String clonesClassName = nameMangler.mangleFullClassName("org.dianahep.root4j.clones",klass.getClassName());
ClassGen cg = new ClassGen(className, "org/dianahep/root4j/core/Clone", "<generated>", ACC_PUBLIC | ACC_SUPER, new String[]
{
nameMangler.mangleInterfaceName(klass.getClassName())
});
ConstantPoolGen cp = cg.getConstantPool();
InstructionList il = new InstructionList();
InstructionFactory factory = new InstructionFactory(cg);
cg.addEmptyConstructor(ACC_PUBLIC);
// Build the complete list of superclasses
List sup = new ArrayList();
RootClass[] superClasses = klass.getSuperClasses();
iterativelyAdd(sup, superClasses);
sup.add(klass);
// Create the fields
cg.addField(new FieldGen(ACC_PRIVATE, Type.INT, "index", cp).getField());
cg.addField(new FieldGen(ACC_PRIVATE, new ObjectType(clonesClassName), "clones", cp).getField());
//Generate the setData method
MethodGen mg = new MethodGen(ACC_PUBLIC, Type.VOID, new Type[]
{
Type.INT, new ObjectType("org.dianahep.root4j.core.Clones")
}, new String[] { "index", "clones" }, "setData", className, il, cp);
il.append(InstructionConstants.ALOAD_0);
il.append(InstructionConstants.ILOAD_1);
il.append(factory.createPutField(className, "index", Type.INT));
il.append(InstructionConstants.ALOAD_0);
il.append(InstructionConstants.ALOAD_2);
il.append(factory.createCast(new ObjectType("org.dianahep.root4j.core.Clones"), new ObjectType(clonesClassName)));
il.append(factory.createPutField(className, "clones", new ObjectType(clonesClassName)));
il.append(InstructionConstants.RETURN);
mg.setMaxStack();
mg.setMaxLocals();
cg.addMethod(mg.getMethod());
il.dispose();
// Generate the accessor methods
for (Iterator i = sup.iterator(); i.hasNext();)
generateMethods((RootClass) i.next(), cp, il, factory, cg, className, clonesClassName);
return cg.getJavaClass();
}
示例14: 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();
}
}
}
示例15: 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();
}