本文整理汇总了Java中org.codehaus.groovy.ast.ClassHelper.byte_TYPE方法的典型用法代码示例。如果您正苦于以下问题:Java ClassHelper.byte_TYPE方法的具体用法?Java ClassHelper.byte_TYPE怎么用?Java ClassHelper.byte_TYPE使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.codehaus.groovy.ast.ClassHelper
的用法示例。
在下文中一共展示了ClassHelper.byte_TYPE方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: convertFromLong
import org.codehaus.groovy.ast.ClassHelper; //导入方法依赖的package包/类
private boolean convertFromLong(ClassNode target) {
MethodVisitor mv = controller.getMethodVisitor();
if (target==ClassHelper.int_TYPE){
mv.visitInsn(L2I);
return true;
} else if ( target==ClassHelper.char_TYPE ||
target==ClassHelper.byte_TYPE ||
target==ClassHelper.short_TYPE)
{
mv.visitInsn(L2I);
return convertFromInt(target);
} else if (target==ClassHelper.double_TYPE){
mv.visitInsn(L2D);
return true;
} else if (target==ClassHelper.float_TYPE){
mv.visitInsn(L2F);
return true;
}
return false;
}
示例5: 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;
}
示例6: 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;
}
示例7: 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;
}
示例8: 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";
}
示例9: 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;
}
示例10: 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);
}
示例11: 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('$', '.'));
}
}
示例12: visitArrayExpression
import org.codehaus.groovy.ast.ClassHelper; //导入方法依赖的package包/类
public void visitArrayExpression(ArrayExpression expression) {
MethodVisitor mv = controller.getMethodVisitor();
ClassNode elementType = expression.getElementType();
String arrayTypeName = BytecodeHelper.getClassInternalName(elementType);
List sizeExpression = expression.getSizeExpression();
int size = 0;
int dimensions = 0;
if (sizeExpression != null) {
for (Iterator iter = sizeExpression.iterator(); iter.hasNext();) {
Expression element = (Expression) iter.next();
if (element == ConstantExpression.EMPTY_EXPRESSION) break;
dimensions++;
// let's convert to an int
element.visit(this);
controller.getOperandStack().doGroovyCast(ClassHelper.int_TYPE);
}
controller.getOperandStack().remove(dimensions);
} else {
size = expression.getExpressions().size();
BytecodeHelper.pushConstant(mv, size);
}
int storeIns = AASTORE;
if (sizeExpression != null) {
arrayTypeName = BytecodeHelper.getTypeDescription(expression.getType());
mv.visitMultiANewArrayInsn(arrayTypeName, dimensions);
} else if (ClassHelper.isPrimitiveType(elementType)) {
int primType = 0;
if (elementType == ClassHelper.boolean_TYPE) {
primType = T_BOOLEAN;
storeIns = BASTORE;
} else if (elementType == ClassHelper.char_TYPE) {
primType = T_CHAR;
storeIns = CASTORE;
} else if (elementType == ClassHelper.float_TYPE) {
primType = T_FLOAT;
storeIns = FASTORE;
} else if (elementType == ClassHelper.double_TYPE) {
primType = T_DOUBLE;
storeIns = DASTORE;
} else if (elementType == ClassHelper.byte_TYPE) {
primType = T_BYTE;
storeIns = BASTORE;
} else if (elementType == ClassHelper.short_TYPE) {
primType = T_SHORT;
storeIns = SASTORE;
} else if (elementType == ClassHelper.int_TYPE) {
primType = T_INT;
storeIns = IASTORE;
} else if (elementType == ClassHelper.long_TYPE) {
primType = T_LONG;
storeIns = LASTORE;
}
mv.visitIntInsn(NEWARRAY, primType);
} else {
mv.visitTypeInsn(ANEWARRAY, arrayTypeName);
}
for (int i = 0; i < size; i++) {
mv.visitInsn(DUP);
BytecodeHelper.pushConstant(mv, i);
Expression elementExpression = expression.getExpression(i);
if (elementExpression == null) {
ConstantExpression.NULL.visit(this);
} else {
elementExpression.visit(this);
controller.getOperandStack().doGroovyCast(elementType);
}
mv.visitInsn(storeIns);
controller.getOperandStack().remove(1);
}
controller.getOperandStack().push(expression.getType());
}
示例13: getArrayGetResultType
import org.codehaus.groovy.ast.ClassHelper; //导入方法依赖的package包/类
@Override protected ClassNode getArrayGetResultType() { return ClassHelper.byte_TYPE; }