本文整理汇总了Java中org.apache.bcel.generic.Type.LONG属性的典型用法代码示例。如果您正苦于以下问题:Java Type.LONG属性的具体用法?Java Type.LONG怎么用?Java Type.LONG使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.bcel.generic.Type
的用法示例。
在下文中一共展示了Type.LONG属性的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: add
/**
* Adds information about the local variable in slot 'slot'. Automatically
* adds information for slot+1 if 't' is Type.LONG or Type.DOUBLE.
* @throws LocalVariableInfoInconsistentException if the new information conflicts
* with already gathered information.
*/
public void add(int slot, String name, int startpc, int length, Type t) throws LocalVariableInfoInconsistentException{
// The add operation on LocalVariableInfo may throw the '...Inconsistent...' exception, we don't throw it explicitely here.
if (slot < 0 || slot >= localVariableInfos.length){
throw new AssertionViolatedException("Slot number for local variable information out of range.");
}
localVariableInfos[slot].add(name, startpc, length, t);
if (t == Type.LONG) localVariableInfos[slot+1].add(name, startpc, length, LONG_Upper.theInstance());
if (t == Type.DOUBLE) localVariableInfos[slot+1].add(name, startpc, length, DOUBLE_Upper.theInstance());
}
示例5: getFreeIndexToStart
/**
* Method getFreeIndexToStart.
* Returns the index to openConnection allocating the subsequent stack variables
*
* @param classes the classes
* @return int the index
*/
protected int getFreeIndexToStart(Class[] classes) {
int index = 0;
for (int i = 0; i < classes.length; i++) {
if (getBCELType(classes[i]) == Type.DOUBLE || getBCELType(classes[i]) == Type.LONG) {
index += 2;
}
index += 1;
}
return index;
}
示例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: LongClass
LongClass()
{
super("Integer", Type.LONG, Long.TYPE, "readLong");
}
示例8: createInterfaceMethodArgs
/**
* Create interface method's args.
*
* @param numberOfArguments the number of arguments.
* @param il an instruction list
* @param variableIndex a varible index.
* @param paramTypes parameter types
* @param generatedClassName the generated class name.
*/
private void createInterfaceMethodArgs(int numberOfArguments, InstructionList il, int variableIndex, Class[] paramTypes, String generatedClassName) {
Type previousType = null;
int loadIndex = 0;
for (int i = 0; i < numberOfArguments; i++) {
// assigning the obj ref's
il.append(InstructionFactory.createLoad(Type.OBJECT, variableIndex - 1));
il.append(new PUSH(constantsPool, i));
String className = paramTypes[i].getName();
//adjust for any previous wider datatype (double/long)
if (previousType != null && (previousType == Type.DOUBLE || previousType == Type.LONG)) {
++loadIndex;
}
if (paramTypes[i].isPrimitive()) {
il.append(factory.createNew(getJavaWrapperClass(className)));
il.append(InstructionConstants.DUP);
il.append(InstructionFactory.createLoad(getBCELPrimitiveType(className), ++loadIndex));
il.append(factory.createInvoke(getJavaWrapperClass(className), "<init>", Type.VOID, new Type[]{getBCELPrimitiveType(className)}, Constants.INVOKESPECIAL));
il.append(InstructionConstants.AASTORE);
} else {
//create the static fields for enabling .class calls
String encodedFieldName;
if (paramTypes[i].isArray()) {
int index = className.lastIndexOf('[');
if (className.charAt(index + 1) == 'L') {
encodedFieldName = "array$" + className.substring(1 + index, className.length() - 1).replace('.', '$');
} else {
encodedFieldName = "array$" + className.substring(1 + index, className.length());
}
} else {
encodedFieldName = "class$" + className.replace('.', '$');
}
addField(encodedFieldName);
// ******** TODO assign the obj reference
il.append(InstructionFactory.createLoad(Type.OBJECT, variableIndex - 1));
il.append(new PUSH(constantsPool, i));
il.append(InstructionFactory.createLoad(Type.OBJECT, ++loadIndex));
il.append(InstructionConstants.AASTORE);
// *********TODO assign the class ref's
il.append(InstructionFactory.createLoad(Type.OBJECT, variableIndex));
il.append(new PUSH(constantsPool, i));
il.append(factory.createFieldAccess(generatedClassName, encodedFieldName, new ObjectType("java.lang.Class"), Constants.GETSTATIC));
BranchInstruction ifnull = InstructionFactory.createBranchInstruction(Constants.IFNULL, null);
il.append(ifnull);
il.append(factory.createFieldAccess(generatedClassName, encodedFieldName, new ObjectType("java.lang.Class"), Constants.GETSTATIC));
BranchInstruction goHeadToStoreRef = InstructionFactory.createBranchInstruction(Constants.GOTO, null);
il.append(goHeadToStoreRef);
InstructionHandle ifnullStartHere = il.append(new PUSH(constantsPool, className));
ifnull.setTarget(ifnullStartHere);
il.append(factory.createInvoke(generatedClassName, "class$", new ObjectType("java.lang.Class"), new Type[]{Type.STRING}, Constants.INVOKESTATIC));
il.append(InstructionConstants.DUP);
il.append(factory.createFieldAccess(generatedClassName, encodedFieldName, new ObjectType("java.lang.Class"), Constants.PUTSTATIC));
InstructionHandle storeClassRef = il.append(InstructionConstants.AASTORE);
goHeadToStoreRef.setTarget(storeClassRef);
}
previousType = getBCELPrimitiveType(className);
}
}
示例9: 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();
}