本文整理汇总了Java中org.codehaus.groovy.ast.ClassHelper.long_TYPE方法的典型用法代码示例。如果您正苦于以下问题:Java ClassHelper.long_TYPE方法的具体用法?Java ClassHelper.long_TYPE怎么用?Java ClassHelper.long_TYPE使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.codehaus.groovy.ast.ClassHelper
的用法示例。
在下文中一共展示了ClassHelper.long_TYPE方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doReturn
import org.codehaus.groovy.ast.ClassHelper; //导入方法依赖的package包/类
public static void doReturn(MethodVisitor mv, ClassNode returnType) {
if (returnType == ClassHelper.double_TYPE) {
mv.visitInsn(DRETURN);
} else if (returnType == ClassHelper.float_TYPE) {
mv.visitInsn(FRETURN);
} else if (returnType == ClassHelper.long_TYPE) {
mv.visitInsn(LRETURN);
} else if (
returnType == ClassHelper.boolean_TYPE
|| returnType == ClassHelper.char_TYPE
|| returnType == ClassHelper.byte_TYPE
|| returnType == ClassHelper.int_TYPE
|| returnType == ClassHelper.short_TYPE) {
//byte,short,boolean,int are all IRETURN
mv.visitInsn(IRETURN);
} else if (returnType == ClassHelper.VOID_TYPE) {
mv.visitInsn(RETURN);
} else {
mv.visitInsn(ARETURN);
}
}
示例2: load
import org.codehaus.groovy.ast.ClassHelper; //导入方法依赖的package包/类
public static void load(MethodVisitor mv, ClassNode type, int idx) {
if (type == ClassHelper.double_TYPE) {
mv.visitVarInsn(DLOAD, idx);
} else if (type == ClassHelper.float_TYPE) {
mv.visitVarInsn(FLOAD, idx);
} else if (type == ClassHelper.long_TYPE) {
mv.visitVarInsn(LLOAD, idx);
} else if (
type == ClassHelper.boolean_TYPE
|| type == ClassHelper.char_TYPE
|| type == ClassHelper.byte_TYPE
|| type == ClassHelper.int_TYPE
|| type == ClassHelper.short_TYPE) {
mv.visitVarInsn(ILOAD, idx);
} else {
mv.visitVarInsn(ALOAD, idx);
}
}
示例3: convertFromInt
import org.codehaus.groovy.ast.ClassHelper; //导入方法依赖的package包/类
private boolean convertFromInt(ClassNode target) {
int convertCode;
if (target==ClassHelper.char_TYPE){
convertCode = I2C;
} else if (target==ClassHelper.byte_TYPE){
convertCode = I2B;
} else if (target==ClassHelper.short_TYPE){
convertCode = I2S;
} else if (target==ClassHelper.long_TYPE){
convertCode = I2L;
} else if (target==ClassHelper.float_TYPE){
convertCode = I2F;
} else if (target==ClassHelper.double_TYPE){
convertCode = I2D;
} else {
return false;
}
controller.getMethodVisitor().visitInsn(convertCode);
return true;
}
示例4: convertFromDouble
import org.codehaus.groovy.ast.ClassHelper; //导入方法依赖的package包/类
private boolean convertFromDouble(ClassNode target) {
MethodVisitor mv = controller.getMethodVisitor();
if (target==ClassHelper.int_TYPE){
mv.visitInsn(D2I);
return true;
} else if ( target==ClassHelper.char_TYPE ||
target==ClassHelper.byte_TYPE ||
target==ClassHelper.short_TYPE)
{
mv.visitInsn(D2I);
return convertFromInt(target);
} else if (target==ClassHelper.long_TYPE){
mv.visitInsn(D2L);
return true;
} else if (target==ClassHelper.float_TYPE){
mv.visitInsn(D2F);
return true;
}
return false;
}
示例5: convertFromFloat
import org.codehaus.groovy.ast.ClassHelper; //导入方法依赖的package包/类
private boolean convertFromFloat(ClassNode target) {
MethodVisitor mv = controller.getMethodVisitor();
if (target==ClassHelper.int_TYPE){
mv.visitInsn(F2I);
return true;
} else if ( target==ClassHelper.char_TYPE ||
target==ClassHelper.byte_TYPE ||
target==ClassHelper.short_TYPE)
{
mv.visitInsn(F2I);
return convertFromInt(target);
} else if (target==ClassHelper.long_TYPE){
mv.visitInsn(F2L);
return true;
} else if (target==ClassHelper.double_TYPE){
mv.visitInsn(F2D);
return true;
}
return false;
}
示例6: convertPrimitive
import org.codehaus.groovy.ast.ClassHelper; //导入方法依赖的package包/类
private boolean convertPrimitive(ClassNode top, ClassNode target) {
if (top==target) return true;
if (top==ClassHelper.int_TYPE) {
return convertFromInt(target);
} else if ( top==ClassHelper.char_TYPE ||
top==ClassHelper.byte_TYPE ||
top==ClassHelper.short_TYPE)
{
return target == ClassHelper.int_TYPE || convertFromInt(target);
} else if ( top==ClassHelper.float_TYPE) {
return convertFromFloat(target);
} else if ( top==ClassHelper.double_TYPE) {
return convertFromDouble(target);
} else if ( top==ClassHelper.long_TYPE) {
return convertFromLong(target);
}
return false;
}
示例7: suffixForField
import org.codehaus.groovy.ast.ClassHelper; //导入方法依赖的package包/类
private static String suffixForField(FieldNode fNode) {
// use primitives for efficiency
if (fNode.getType() == ClassHelper.int_TYPE) return "Int";
if (fNode.getType() == ClassHelper.boolean_TYPE) return "Boolean";
// currently char isn't found due to a bug, so go with Object
// if (fNode.getType() == ClassHelper.char_TYPE) return "Char";
if (fNode.getType() == ClassHelper.long_TYPE) return "Long";
if (fNode.getType() == ClassHelper.short_TYPE) return "Short";
if (fNode.getType() == ClassHelper.byte_TYPE) return "Byte";
if (fNode.getType() == ClassHelper.float_TYPE) return "Float";
if (fNode.getType() == ClassHelper.double_TYPE) return "Double";
return "Object";
}
示例8: getDefaultValueForPrimitive
import org.codehaus.groovy.ast.ClassHelper; //导入方法依赖的package包/类
public static Expression getDefaultValueForPrimitive(ClassNode type) {
if (type == ClassHelper.int_TYPE) {
return new ConstantExpression(0);
}
if (type == ClassHelper.long_TYPE) {
return new ConstantExpression(0L);
}
if (type == ClassHelper.double_TYPE) {
return new ConstantExpression(0.0);
}
if (type == ClassHelper.float_TYPE) {
return new ConstantExpression(0.0F);
}
if (type == ClassHelper.boolean_TYPE) {
return ConstantExpression.FALSE;
}
if (type == ClassHelper.short_TYPE) {
return new ConstantExpression((short) 0);
}
if (type == ClassHelper.byte_TYPE) {
return new ConstantExpression((byte) 0);
}
if (type == ClassHelper.char_TYPE) {
return new ConstantExpression((char) 0);
}
return null;
}
示例9: convertPrimitiveToBoolean
import org.codehaus.groovy.ast.ClassHelper; //导入方法依赖的package包/类
/**
* Converts a primitive type to boolean.
*
* @param mv method visitor
* @param type primitive type to convert
*/
public static void convertPrimitiveToBoolean(MethodVisitor mv, ClassNode type) {
if (type == ClassHelper.boolean_TYPE) {
return;
}
// Special handling is done for floating point types in order to
// handle checking for 0 or NaN values.
if (type == ClassHelper.double_TYPE) {
convertDoubleToBoolean(mv, type);
return;
} else if (type == ClassHelper.float_TYPE) {
convertFloatToBoolean(mv, type);
return;
}
Label trueLabel = new Label();
Label falseLabel = new Label();
// Convert long to int for IFEQ comparison using LCMP
if (type==ClassHelper.long_TYPE) {
mv.visitInsn(LCONST_0);
mv.visitInsn(LCMP);
}
// This handles byte, short, char and int
mv.visitJumpInsn(IFEQ, falseLabel);
mv.visitInsn(ICONST_1);
mv.visitJumpInsn(GOTO, trueLabel);
mv.visitLabel(falseLabel);
mv.visitInsn(ICONST_0);
mv.visitLabel(trueLabel);
}
示例10: dup
import org.codehaus.groovy.ast.ClassHelper; //导入方法依赖的package包/类
/**
* duplicate top element
*/
public void dup() {
ClassNode type = getTopOperand();
stack.add(type);
MethodVisitor mv = controller.getMethodVisitor();
if (type == ClassHelper.double_TYPE || type == ClassHelper.long_TYPE) {
mv.visitInsn(DUP2);
} else {
mv.visitInsn(DUP);
}
}
示例11: storeVar
import org.codehaus.groovy.ast.ClassHelper; //导入方法依赖的package包/类
public void storeVar(BytecodeVariable variable) {
MethodVisitor mv = controller.getMethodVisitor();
int idx = variable.getIndex();
ClassNode type = variable.getType();
// value is on stack
if (variable.isHolder()) {
doGroovyCast(type);
box();
mv.visitVarInsn(ALOAD, idx);
mv.visitTypeInsn(CHECKCAST, "groovy/lang/Reference");
mv.visitInsn(SWAP);
mv.visitMethodInsn(INVOKEVIRTUAL, "groovy/lang/Reference", "set", "(Ljava/lang/Object;)V", false);
} else {
doGroovyCast(type);
if (type == ClassHelper.double_TYPE) {
mv.visitVarInsn(DSTORE, idx);
} else if (type == ClassHelper.float_TYPE) {
mv.visitVarInsn(FSTORE, idx);
} else if (type == ClassHelper.long_TYPE) {
mv.visitVarInsn(LSTORE, idx);
} else if (
type == ClassHelper.boolean_TYPE
|| type == ClassHelper.char_TYPE
|| type == ClassHelper.byte_TYPE
|| type == ClassHelper.int_TYPE
|| type == ClassHelper.short_TYPE) {
mv.visitVarInsn(ISTORE, idx);
} else {
mv.visitVarInsn(ASTORE, idx);
}
}
// remove RHS value from operand stack
remove(1);
}
示例12: generateMopCalls
import org.codehaus.groovy.ast.ClassHelper; //导入方法依赖的package包/类
/**
* generates a Meta Object Protocol method, that is used to call a non public
* method, or to make a call to super.
*
* @param mopCalls list of methods a mop call method should be generated for
* @param useThis true if "this" should be used for the naming
*/
protected void generateMopCalls(LinkedList<MethodNode> mopCalls, boolean useThis) {
for (MethodNode method : mopCalls) {
String name = getMopMethodName(method, useThis);
Parameter[] parameters = method.getParameters();
String methodDescriptor = BytecodeHelper.getMethodDescriptor(method.getReturnType(), method.getParameters());
MethodVisitor mv = controller.getClassVisitor().visitMethod(ACC_PUBLIC | ACC_SYNTHETIC, name, methodDescriptor, null, null);
controller.setMethodVisitor(mv);
mv.visitVarInsn(ALOAD, 0);
int newRegister = 1;
OperandStack operandStack = controller.getOperandStack();
for (Parameter parameter : parameters) {
ClassNode type = parameter.getType();
operandStack.load(parameter.getType(), newRegister);
// increment to next register, double/long are using two places
newRegister++;
if (type == ClassHelper.double_TYPE || type == ClassHelper.long_TYPE) newRegister++;
}
operandStack.remove(parameters.length);
ClassNode declaringClass = method.getDeclaringClass();
// JDK 8 support for default methods in interfaces
// this should probably be strenghtened when we support the A.super.foo() syntax
int opcode = declaringClass.isInterface()?INVOKEINTERFACE:INVOKESPECIAL;
mv.visitMethodInsn(opcode, BytecodeHelper.getClassInternalName(declaringClass), method.getName(), methodDescriptor, opcode == INVOKEINTERFACE);
BytecodeHelper.doReturn(mv, method.getReturnType());
mv.visitMaxs(0, 0);
mv.visitEnd();
controller.getClassNode().addMethod(name, ACC_PUBLIC | ACC_SYNTHETIC, method.getReturnType(), parameters, null, null);
}
}
示例13: pushInitValue
import org.codehaus.groovy.ast.ClassHelper; //导入方法依赖的package包/类
private static void pushInitValue(ClassNode type, MethodVisitor mv) {
if (ClassHelper.isPrimitiveType(type)) {
if (type== ClassHelper.long_TYPE) {
mv.visitInsn(LCONST_0);
} else if (type== ClassHelper.double_TYPE) {
mv.visitInsn(DCONST_0);
} else if (type== ClassHelper.float_TYPE) {
mv.visitInsn(FCONST_0);
} else {
mv.visitLdcInsn(0);
}
} else {
mv.visitInsn(ACONST_NULL);
}
}
示例14: makeNextVariableID
import org.codehaus.groovy.ast.ClassHelper; //导入方法依赖的package包/类
/**
* Calculates the index of the next free register stores it
* and sets the current variable index to the old value
*/
private void makeNextVariableID(ClassNode type, boolean useReferenceDirectly) {
currentVariableIndex = nextVariableIndex;
if ((type== ClassHelper.long_TYPE || type== ClassHelper.double_TYPE) && !useReferenceDirectly) {
nextVariableIndex++;
}
nextVariableIndex++;
}
示例15: printTypeName
import org.codehaus.groovy.ast.ClassHelper; //导入方法依赖的package包/类
private void printTypeName(PrintWriter out, ClassNode type) {
if (ClassHelper.isPrimitiveType(type)) {
if (type == ClassHelper.boolean_TYPE) {
out.print("boolean");
} else if (type == ClassHelper.char_TYPE) {
out.print("char");
} else if (type == ClassHelper.int_TYPE) {
out.print("int");
} else if (type == ClassHelper.short_TYPE) {
out.print("short");
} else if (type == ClassHelper.long_TYPE) {
out.print("long");
} else if (type == ClassHelper.float_TYPE) {
out.print("float");
} else if (type == ClassHelper.double_TYPE) {
out.print("double");
} else if (type == ClassHelper.byte_TYPE) {
out.print("byte");
} else {
out.print("void");
}
} else {
String name = type.getName();
// check for an alias
ClassNode alias = currentModule.getImportType(name);
if (alias != null) name = alias.getName();
out.print(name.replace('$', '.'));
}
}