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

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


                    that.getPrimary().visit(gen);
                }
                if (that.getPrimary() instanceof Tree.MemberOrTypeExpression) {
                    Tree.MemberOrTypeExpression mte = (Tree.MemberOrTypeExpression) that.getPrimary();
                    if (mte.getDeclaration() instanceof Functional) {
                        Functional f = (Functional) mte.getDeclaration();
                        Tree.TypeArguments targs = null;
                        if (that.getPrimary() instanceof Tree.StaticMemberOrTypeExpression) {
                            targs = ((Tree.StaticMemberOrTypeExpression)that.getPrimary()).getTypeArguments();
                        }
                        applyNamedArguments(argList, f, argVarNames, gen.getSuperMemberScope(mte)!=null, targs);
View Full Code Here


            }
            ProducedReference arg = getProducedReference(smte);
            if (!smte.getStaticMethodReferencePrimary() &&
                    dec instanceof Functional &&
                    param!=null) {
                Functional fun = (Functional) dec;
                List<ParameterList> apls = fun.getParameterLists();
                Declaration pdec = param.getDeclaration();
                if (pdec instanceof Functional) {
                    Functional pfun = (Functional) pdec;
                    List<ParameterList> ppls = pfun.getParameterLists();
                    if (apls.isEmpty() || ppls.isEmpty()) {
                        return null; //TODO: to give a nicer error
                    }
                    else {
                        List<ProducedType> inferredTypes =
View Full Code Here

        }
    }

    private void inferParameterTypesFromCallableParameter(ProducedReference pr,
            Parameter param, Tree.FunctionArgument anon) {
        Functional f = (Functional) param.getModel();
        List<ParameterList> fpls = f.getParameterLists();
        List<Tree.ParameterList> apls = anon.getParameterLists();
        if (!fpls.isEmpty() && !apls.isEmpty()) {
            List<Parameter> fps = fpls.get(0).getParameters();
            List<Tree.Parameter> aps = apls.get(0).getParameters();
            for (int j=0; j<fps.size() && j<aps.size(); j++) {
View Full Code Here

    }
   
    private List<ProducedType> getInferedTypeArguments(Tree.InvocationExpression that,
            Declaration dec) {
        if (dec instanceof Functional) {
            Functional fun = (Functional) dec;
            List<ProducedType> typeArgs = new ArrayList<ProducedType>();
            if (!fun.getParameterLists().isEmpty()) {
                ParameterList parameters = fun.getParameterLists().get(0);
                for (TypeParameter tp: fun.getTypeParameters()) {
                    ProducedType it = inferTypeArgument(that,
                            that.getPrimary().getTypeModel(),
                            tp, parameters);
                    if (it.containsUnknowns()) {
                        that.addError("could not infer type argument from given arguments: type parameter '" +
View Full Code Here

   
    private void visitDirectInvocation(Tree.InvocationExpression that) {
        Tree.Term p = unwrapExpressionUntilTerm(that.getPrimary());
        Tree.MemberOrTypeExpression mte = (Tree.MemberOrTypeExpression) p;
        ProducedReference prf = mte.getTarget();
        Functional dec = (Functional) mte.getDeclaration();
        if (dec!=null) {
            if (!(p instanceof Tree.ExtendedTypeExpression)) {
                if (dec instanceof Class && ((Class) dec).isAbstract()) {
                    that.addError("abstract class may not be instantiated: '" +
                            dec.getName(unit) + "'");
                }
            }
            if (that.getNamedArgumentList()!=null &&
                    dec.isAbstraction()) {
                //TODO: this is not really right - it's the fact
                //      that we're calling Java and don't have
                //      meaningful parameter names that is the
                //      real problem, not the overload
                that.addError("overloaded declarations may not be called using named arguments: '" +
                        dec.getName(unit) + "'");
            }
            //that.setTypeModel(prf.getType());
            ProducedType ct = p.getTypeModel();
            if (ct!=null && !ct.getTypeArgumentList().isEmpty()) {
                //pull the return type out of the Callable
                that.setTypeModel(ct.getTypeArgumentList().get(0));
            }
            if (that.getNamedArgumentList() != null) {
                List<ParameterList> parameterLists = dec.getParameterLists();
                if (!parameterLists.isEmpty()
                        && !parameterLists.get(0).isNamedParametersSupported()) {
                    that.addError("named invocations of Java methods not supported");
                }
            }
            if (dec.isAbstraction()) {
                //nothing to check the argument types against
                //that.addError("no matching overloaded declaration");
            }
            else {
                //typecheck arguments using the parameter list
View Full Code Here

        close("span");
        if( isConstantValue(d) ) {
            writeConstantValue((Value) d);
        }
        if( d instanceof Functional ) {
            Functional f = (Functional) d;
            writeTypeParameters(f.getTypeParameters());
            writeParameterList(f);
            writeTypeParametersConstraints(f.getTypeParameters());
        }
        if (d instanceof Value) {
            Setter setter = ((Value) d).getSetter();
            if (setter != null && Util.getAnnotation(setter.getAnnotations(), "doc") != null) {
                tool.warningSetterDoc(d.getQualifiedNameString(), d);
View Full Code Here

                        || (decl.getContainer() instanceof Method 
                            && ((Method)decl.getContainer()).isParameter()
                            && Strategy.createMethod((Method)decl.getContainer())))) {// or is a class functional parameter
            // Parameters in a refined method are not considered refinements themselves
            // so we have to look up the corresponding parameter in the container's refined declaration
            Functional func = (Functional)getParameterized((MethodOrValue)decl);
            if(func == null)
                return decl;
            Declaration kk = getTopmostRefinedDeclaration((Declaration)func, methodOverrides);
            // error recovery
            if(kk instanceof Functional == false)
                return decl;
            Functional refinedFunc = (Functional) kk;
            // shortcut if the functional doesn't override anything
            if (Decl.equal((Declaration)refinedFunc, (Declaration)func)) {
                return decl;
            }
            if (func.getParameterLists().size() != refinedFunc.getParameterLists().size()) {
                // invalid input
                return decl;
            }
            for (int ii = 0; ii < func.getParameterLists().size(); ii++) {
                if (func.getParameterLists().get(ii).getParameters().size() != refinedFunc.getParameterLists().get(ii).getParameters().size()) {
                    // invalid input
                    return decl;
                }
                // find the index of the parameter in the declaration
                int index = 0;
                for (Parameter px : func.getParameterLists().get(ii).getParameters()) {
                    if (px.getModel().equals(decl)) {
                        // And return the corresponding parameter from the refined declaration
                        return refinedFunc.getParameterLists().get(ii).getParameters().get(index).getModel();
                    }
                    index++;
                }
                continue;
            }
View Full Code Here

    }
   
    static Parameter findParamForDecl(String attrName, TypedDeclaration decl) {
        Parameter result = null;
        if (decl.getContainer() instanceof Functional) {
            Functional f = (Functional)decl.getContainer();
            result = f.getParameter(attrName);
        }
        return result;
    }
View Full Code Here

            AbstractTransformer gen, Naming.SyntheticName primaryName, Tree.Term primary,
            Declaration primaryDeclaration, ProducedReference producedReference, ProducedType returnType,
            Tree.Term expr, ParameterList parameterList, int parameterCount, boolean tempVars) {
        super(gen, primary, primaryDeclaration, producedReference, returnType, expr);
        this.instanceFieldName = primaryName;
        Functional functional = null;
        if(primary instanceof Tree.MemberOrTypeExpression)
            functional = (Functional) ((Tree.MemberOrTypeExpression) primary).getDeclaration();
        else if(primary instanceof Tree.FunctionArgument)
            functional = ((Tree.FunctionArgument) primary).getDeclarationModel();
        if(functional != null)
            callableParameters = functional.getParameterLists().get(0).getParameters();
        else
            callableParameters = Collections.emptyList();
        functionalParameters = parameterList.getParameters();
        this.parameterCount = parameterCount;
        setUnboxed(expr.getUnboxed());
View Full Code Here

    private Naming.SyntheticName reifiedTypeArgName(int index) {
        return varBaseName.suffixedBy(Suffix.$reified$, index);
    }

    private java.util.List<Parameter> parameterList(Parameter param) {
        Functional functional = (Functional)param.getDeclaration();
        return functional.getParameterLists().get(0).getParameters();
    }
View Full Code Here

TOP

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

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.