当前位置: 首页>>代码示例>>Java>>正文


Java ClassHelper.VOID_TYPE属性代码示例

本文整理汇总了Java中org.codehaus.groovy.ast.ClassHelper.VOID_TYPE属性的典型用法代码示例。如果您正苦于以下问题:Java ClassHelper.VOID_TYPE属性的具体用法?Java ClassHelper.VOID_TYPE怎么用?Java ClassHelper.VOID_TYPE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.codehaus.groovy.ast.ClassHelper的用法示例。


在下文中一共展示了ClassHelper.VOID_TYPE属性的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: visitReturnType

@Override
public ClassNode visitReturnType(ReturnTypeContext ctx) {
    if (!asBoolean(ctx)) {
        return ClassHelper.OBJECT_TYPE;
    }

    if (asBoolean(ctx.type())) {
        return this.visitType(ctx.type());
    }

    if (asBoolean(ctx.VOID())) {
        return ClassHelper.VOID_TYPE;
    }

    throw createParsingFailedException("Unsupported return type: " + ctx.getText(), ctx);
}
 
开发者ID:apache,项目名称:groovy,代码行数:16,代码来源:AstBuilder.java

示例2: createInitMethod

private static MethodNode createInitMethod(final boolean isStatic, final ClassNode cNode, final ClassNode helper) {
    MethodNode initializer = new MethodNode(
            isStatic?Traits.STATIC_INIT_METHOD:Traits.INIT_METHOD,
            ACC_STATIC | ACC_PUBLIC | ACC_SYNTHETIC,
            ClassHelper.VOID_TYPE,
            new Parameter[]{createSelfParameter(cNode, isStatic)},
            ClassNode.EMPTY_ARRAY,
            new BlockStatement()
    );
    helper.addMethod(initializer);

    // Cannot add static compilation of init method because of GROOVY-7217, see example 2 of test case
    //AnnotationNode an = new AnnotationNode(TraitComposer.COMPILESTATIC_CLASSNODE);
    //initializer.addAnnotation(an);
    //cNode.addTransform(StaticCompileTransformation.class, an);

    return initializer;
}
 
开发者ID:apache,项目名称:groovy,代码行数:18,代码来源:TraitASTTransformation.java

示例3: doReturn

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);
    }

}
 
开发者ID:apache,项目名称:groovy,代码行数:22,代码来源:BytecodeHelper.java

示例4: getPropertyName

private static String getPropertyName(MethodNode m) {
    String name = m.getName();
    if (!(name.startsWith("set") || name.startsWith("get"))) return null;
    String pname = name.substring(3);
    if (pname.length() == 0) return null;
    pname = java.beans.Introspector.decapitalize(pname);

    if (name.startsWith("get") && (m.getReturnType() == ClassHelper.VOID_TYPE || m.getParameters().length != 0)) {
        return null;
    }
    if (name.startsWith("set") && m.getParameters().length != 1) {
        return null;
    }
    return pname;
}
 
开发者ID:apache,项目名称:groovy,代码行数:15,代码来源:VariableScopeVisitor.java

示例5: doCast

public static void doCast(MethodVisitor mv, ClassNode type) {
    if (type == ClassHelper.OBJECT_TYPE) return;
    if (ClassHelper.isPrimitiveType(type) && type != ClassHelper.VOID_TYPE) {
        unbox(mv, type);
    } else {
        mv.visitTypeInsn(
                CHECKCAST,
                type.isArray() ? 
                        BytecodeHelper.getTypeDescription(type) : 
                        BytecodeHelper.getClassInternalName(type.getName()));
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:12,代码来源:BytecodeHelper.java

示例6: box

public ClassNode box() {
    MethodVisitor mv = controller.getMethodVisitor();
    int size = stack.size();
    ClassNode type = stack.get(size-1);
    if (ClassHelper.isPrimitiveType(type) && ClassHelper.VOID_TYPE!=type) {
        ClassNode wrapper = ClassHelper.getWrapper(type);
        BytecodeHelper.doCastToWrappedType(mv, type, wrapper);
        type = wrapper;
    } // else nothing to box
    stack.set(size-1, type);
    return type;
}
 
开发者ID:apache,项目名称:groovy,代码行数:12,代码来源:OperandStack.java

示例7: writeReturn

public void writeReturn(ReturnStatement statement) {
    controller.getAcg().onLineNumber(statement, "visitReturnStatement");
    writeStatementLabel(statement);
    MethodVisitor mv = controller.getMethodVisitor();
    OperandStack operandStack = controller.getOperandStack();
    ClassNode returnType = controller.getReturnType();

    if (returnType == ClassHelper.VOID_TYPE) {
        if (!(statement.isReturningNullOrVoid())) {
            //TODO: move to Verifier
            controller.getAcg().throwException("Cannot use return statement with an expression on a method that returns void");
        }
        controller.getCompileStack().applyBlockRecorder();
        mv.visitInsn(RETURN);
        return;
    }

    Expression expression = statement.getExpression();
    expression.visit(controller.getAcg());

    operandStack.doGroovyCast(returnType);

    if (controller.getCompileStack().hasBlockRecorder()) {
        ClassNode type = operandStack.getTopOperand();
        int returnValueIdx = controller.getCompileStack().defineTemporaryVariable("returnValue", returnType, true);
        controller.getCompileStack().applyBlockRecorder();
        operandStack.load(type, returnValueIdx);
        controller.getCompileStack().removeVar(returnValueIdx);
    }

    BytecodeHelper.doReturn(mv, returnType);
    operandStack.remove(1);
}
 
开发者ID:apache,项目名称:groovy,代码行数:33,代码来源:StatementWriter.java

示例8: createSetterMethod

/**
 * Creates a setter method with the given body.
 *
 * @param declaringClass the class to which we will add the setter
 * @param propertyNode          the field to back the setter
 * @param setterName     the name of the setter
 * @param setterBlock    the statement representing the setter block
 */
protected void createSetterMethod(ClassNode declaringClass, PropertyNode propertyNode, String setterName, Statement setterBlock) {
    MethodNode setter = new MethodNode(
            setterName,
            PropertyNodeUtils.adjustPropertyModifiersForMethod(propertyNode),
            ClassHelper.VOID_TYPE,
            params(param(propertyNode.getType(), "value")),
            ClassNode.EMPTY_ARRAY,
            setterBlock);
    setter.setSynthetic(true);
    // add it to the class
    declaringClass.addMethod(setter);
}
 
开发者ID:apache,项目名称:groovy,代码行数:20,代码来源:BindableASTTransformation.java

示例9: createSetterMethod

/**
 * Creates a setter method with the given body.
 * <p>
 * This differs from normal setters in that we need to add a declared
 * exception java.beans.PropertyVetoException
 *
 * @param declaringClass the class to which we will add the setter
 * @param propertyNode          the field to back the setter
 * @param setterName     the name of the setter
 * @param setterBlock    the statement representing the setter block
 */
protected void createSetterMethod(ClassNode declaringClass, PropertyNode propertyNode, String setterName, Statement setterBlock) {
    ClassNode[] exceptions = {ClassHelper.make(PropertyVetoException.class)};
    MethodNode setter = new MethodNode(
            setterName,
            PropertyNodeUtils.adjustPropertyModifiersForMethod(propertyNode),
            ClassHelper.VOID_TYPE,
            params(param(propertyNode.getType(), "value")),
            exceptions,
            setterBlock);
    setter.setSynthetic(true);
    // add it to the class
    declaringClass.addMethod(setter);
}
 
开发者ID:apache,项目名称:groovy,代码行数:24,代码来源:VetoableASTTransformation.java


注:本文中的org.codehaus.groovy.ast.ClassHelper.VOID_TYPE属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。