Package com.redhat.ceylon.compiler.typechecker.model

Examples of com.redhat.ceylon.compiler.typechecker.model.MethodOrValue


   
    public MethodDefinitionBuilder parameter(Parameter param,
            List<JCAnnotation> userAnnotations, int flags, boolean canWiden) {
        String paramName = param.getName();
        String aliasedName = Naming.getAliasedParameterName(param);
        MethodOrValue mov = CodegenUtil.findMethodOrValueForParam(param);
        int mods = 0;
        if (!Decl.isNonTransientValue(mov) || !mov.isVariable() || mov.isCaptured()) {
            mods |= FINAL;
        }
        TypedDeclaration nonWideningDecl = null;
        ProducedType nonWideningType;
        if (Decl.isValue(mov)) {
View Full Code Here


   
    private static String getAliasedParameterName(MethodOrValue parameter) {
        if (!parameter.isParameter()) {
            throw new BugException();
        }
        MethodOrValue mov = parameter;
        if ((mov instanceof Method && ((Method)mov).isDeferred())
                || (mov instanceof Value && mov.isVariable() && mov.isCaptured())) {
            return suffixName(Suffix.$param$, parameter.getName());
        }
        return quoteIfJavaKeyword(parameter.getName());
    }
View Full Code Here

    static void functionalParameters(StringBuilder sb, ParameterList pl) {
        sb.append('(');
        Iterator<Parameter> parameters = pl.getParameters().iterator();
        while (parameters.hasNext()) {
            Parameter p = parameters.next();
            MethodOrValue pm = p.getModel();
            sb.append(pm.getName());
            if(p.isSequenced()) {
                if (p.isAtLeastOne()) {
                    sb.append('+');
                } else {
                    sb.append('*');
 
View Full Code Here

    private java.util.List<ProducedType> getParameterTypesFromParameterModels() {
        java.util.List<ProducedType> parameterTypes = new ArrayList<ProducedType>(numParams);
        // get them from our declaration
        for(Parameter p : paramLists.getParameters()){
            ProducedType pt;
            MethodOrValue pm = p.getModel();
            if(pm instanceof Method
                    && ((Method)pm).isParameter())
                pt = gen.getTypeForFunctionalParameter((Method) pm);
            else
                pt = p.getType();
View Full Code Here

                    optionalType.setUnderlyingType(type.getUnderlyingType());
                    type = optionalType;
                }
            }
           
            MethodOrValue value = null;
            if (isCeylon && decl instanceof Class){
                // For a functional parameter to a class, we can just lookup the member
                value = (MethodOrValue)((Class)decl).getDirectMember(paramName, null, false);
            }
            if (value == null) {
                // So either decl is not a Class,
                // or the method or value member of decl is not shared
                AnnotationMirror functionalParameterAnnotation = paramMirror.getAnnotation(CEYLON_FUNCTIONAL_PARAMETER_ANNOTATION);
                if (functionalParameterAnnotation != null) {
                    // A functional parameter to a method
                    Method method = loadFunctionalParameter((Declaration)decl, paramName, type, (String)functionalParameterAnnotation.getValue());
                    value = method;
                    parameter.setDeclaredAnything(method.isDeclaredVoid());
                } else {
                    // A value parameter to a method
                    value = new Value();
                    value.setType(type);
                }
               
                value.setContainer((Scope) decl);
                value.setScope((Scope) decl);
                DeclarationVisitor.setVisibleScope(value);
                value.setUnit(((Element)decl).getUnit());
                value.setName(paramName);
            }
            value.setInitializerParameter(parameter);
            parameter.setModel(value);

            if(paramMirror.getAnnotation(CEYLON_SEQUENCED_ANNOTATION) != null
                    || isVariadic)
                parameter.setSequenced(true);
View Full Code Here

        if (lexer.lookingAt(BANG)) {
            lexer.eat();
            declaredVoid = true;
        }
       
        final MethodOrValue result;
        if (lexer.lookingAt(LEFT_PAREN)) {
            // functionParameter()
            result = parseMethod(type, declaredVoid);
        } else {
            if (declaredVoid) {
                throw new ParameterNameParserException("void Value");
            }
            // valueParameter();
            result = parseValue(type);
        }
        result.setName(identifier);
        result.setUnit(unit);
        result.setContainer(container);
        result.setScope(container);
        Parameter p = new Parameter();
        p.setName(identifier);
        p.setSequenced(sequenced);
        p.setAtLeastOne(atLeastOne);
        p.setDeclaredAnything(declaredVoid);
View Full Code Here

                refinedP.setDeclaredAnything(formalP.isDeclaredAnything());
                refinedP.setHidden(formalP.isHidden());
                refinedP.setSequenced(formalP.isSequenced());
                refinedP.setName(formalP.getName());
                final ProducedTypedReference typedParameter = pr.getTypedParameter(formalP);
                MethodOrValue paramModel;
                if (formalP.getModel() instanceof Value) {
                    Value paramValueModel = refineValue((Value)formalP.getModel(), typedParameter, refined, classModel.getUnit());
                    paramValueModel.setInitializerParameter(refinedP);
                    paramModel = paramValueModel;
                } else {
View Full Code Here

                refinedP.setDeclaredAnything(formalP.isDeclaredAnything());
                refinedP.setHidden(formalP.isHidden());
                refinedP.setSequenced(formalP.isSequenced());
                refinedP.setName(formalP.getName());
                final ProducedTypedReference typedParameter = pr.getTypedParameter(formalP);
                MethodOrValue paramModel;
                if (formalP.getModel() instanceof Value) {
                    Value paramValueModel = refineValue((Value)formalP.getModel(), typedParameter, refined, classModel.getUnit());
                    paramValueModel.setInitializerParameter(refinedP);
                    paramModel = paramValueModel;
                } else {
View Full Code Here

        return param.getModel().isVariable() ? 0 : FINAL;
    }
   
    private void makeFieldForParameter(ClassDefinitionBuilder classBuilder,
            Parameter decl) {
        MethodOrValue model = decl.getModel();
        classBuilder.defs(make().VarDef(make().Modifiers(transformClassParameterDeclFlags(decl) | PRIVATE, makeAtIgnore()),
                names().fromString(Naming.quoteFieldName(decl.getName())),
                classGen().transformClassParameterType(decl), null));
       
        classBuilder.init(make().Exec(make().Assign(
View Full Code Here

     * Transforms the type of the given class parameter
     * @param decl
     * @return
     */
    JCExpression transformClassParameterType(Parameter parameter) {
        MethodOrValue decl = parameter.getModel();
        if (!(decl.getContainer() instanceof Class)) {
            throw new BugException("expected parameter of Class");
        }
        JCExpression type;
        MethodOrValue attr = decl;
        if (!Decl.isTransient(attr)) {
            ProducedTypedReference typedRef = getTypedReference(attr);
            ProducedTypedReference nonWideningTypedRef = nonWideningTypeDecl(typedRef);
            ProducedType paramType = nonWideningType(typedRef, nonWideningTypedRef);
            type = makeJavaType(nonWideningTypedRef.getDeclaration(), paramType, 0);
View Full Code Here

TOP

Related Classes of com.redhat.ceylon.compiler.typechecker.model.MethodOrValue

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.