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

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


            ProducedTypedReference param = smte.getTargetParameter();
            ProducedType paramType = smte.getParameterType();
            if (paramType==null && param!=null) {
                paramType = param.getFullType();
            }
            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 =
                                new ArrayList<ProducedType>();
                        List<Parameter> apl = apls.get(0).getParameters();
                        List<Parameter> ppl = ppls.get(0).getParameters();
                        for (TypeParameter tp: fun.getTypeParameters()) {
                            List<ProducedType> list =
                                    new ArrayList<ProducedType>();
                            for (int i=0; i<apl.size() && i<ppl.size(); i++) {
                                Parameter ap = apl.get(i);
                                Parameter pp = ppl.get(i);
                                ProducedType type =
                                        param.getTypedParameter(pp).getFullType();
                                ProducedType template =
                                        arg.getTypedParameter(ap).getFullType();
                                ProducedType it =
                                        inferTypeArg(tp, template, type,
                                                true, false,
                                                new ArrayList<TypeParameter>());
                                if (it!=null &&
                                        !it.containsTypeParameters()) {
                                    addToUnionOrIntersection(tp, list, it);
                                }
                            }
                            inferredTypes.add(formUnionOrIntersection(tp, list));
                        }
                        return inferredTypes;
                    }
                }
            }
            if (paramType!=null) {
                if (unit.isSequentialType(paramType)) {
                    paramType = unit.getSequentialElementType(paramType);
                }
                if (unit.isCallableType(paramType)) {
                    ProducedType template;
                    if (smte.getStaticMethodReferencePrimary()) {
                        template = producedType(unit.getTupleDeclaration(),
                                arg.getType(), arg.getType(),
                                unit.getEmptyDeclaration().getType());
                    }
                    else {
                        template = unit.getCallableTuple(arg.getFullType());
                    }
                    ProducedType type =
                            unit.getCallableTuple(paramType);
                    List<ProducedType> inferredTypes =
                            new ArrayList<ProducedType>();
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: '" +
View Full Code Here

    private ProducedType accountForStaticReferenceReceiverType(Tree.QualifiedMemberOrTypeExpression that,
            ProducedType receivingType) {
        if (that.getStaticMethodReference()) {
            Tree.MemberOrTypeExpression primary =
                    (Tree.MemberOrTypeExpression) that.getPrimary();
            ProducedReference target = primary.getTarget();
            return target==null ?
                    new UnknownType(unit).getType() :
                    target.getType();
        }
        else {
            return receivingType;
        }
    }
View Full Code Here

                    (Tree.MemberOrTypeExpression) that.getPrimary();
            if (member.isStaticallyImportable()) {
                return type;
            }
            else {
                ProducedReference target = qmte.getTarget();
                if (target==null) {
                    return new UnknownType(unit).getType();
                }
                else {
                    return getStaticReferenceType(type,
                            target.getType());
                }
            }
        }
        else {
            return type;
View Full Code Here

            CodegenUtil.markTypeErased(that, hasErasure(elementType));
        }
        if(ExpressionTransformer.isSuperOrSuperOf(that.getPrimary())){
            // if the target is an interface whose type arguments have been turned to raw, make this expression
            // as erased
            ProducedReference target = that.getTarget();
            if(target != null
                    && target.getQualifyingType() != null
                    && target.getQualifyingType().getDeclaration() instanceof Interface){
                if(isRaw(target.getQualifyingType())){
                    CodegenUtil.markTypeErased(that);
                }
                // See note in ClassTransformer.makeDelegateToCompanion for a similar test
                else{
                    TypeDeclaration declaration = target.getQualifyingType().getDeclaration();
                    if(needsRawCastForMixinSuperCall(declaration, target.getType()))
                        CodegenUtil.markTypeErased(that);
                }
            }
        }
        if(that.getPrimary().getTypeModel() != null
View Full Code Here

            stmts.append(gen.make().Return(invocation));
           
            return isCallMethod ? makeCallMethod(stmts.toList(), arity) : makeCallTypedMethod(stmts.toList());
        }
        private JCExpression makeInvocation(int arity, boolean isCallMethod) {
            ProducedReference target = getProducedReference();
            TypeDeclaration primaryDeclaration = getTypeModel().getDeclaration();;
            CallableInvocation invocationBuilder = new CallableInvocation (
                    gen,
                    instanceFieldName,
                    forwardCallTo,
View Full Code Here

        private ProducedType getTypeModel() {
            return forwardCallTo.getTypeModel();
        }

        private ProducedReference getProducedReference() {
            ProducedReference target;
            if (forwardCallTo instanceof Tree.MemberOrTypeExpression) {
                target = ((Tree.MemberOrTypeExpression)forwardCallTo).getTarget();
            } else if (forwardCallTo instanceof Tree.FunctionArgument) {
                Method method = ((Tree.FunctionArgument) forwardCallTo).getDeclarationModel();
                target = method.getProducedReference(null, Collections.<ProducedType>emptyList());
View Full Code Here

        callVarName = varBaseName.suffixedBy(Suffix.$callable$);
    }
   
    @Override
    protected void addReifiedArguments(ListBuffer<ExpressionAndType> result) {
        ProducedReference ref = gen.resolveAliasesForReifiedTypeArguments(producedReference);
        if(!gen.supportsReified(ref.getDeclaration()))
            return;
        int tpCount = gen.getTypeParameters(ref).size();
        for(int tpIndex = 0;tpIndex<tpCount;tpIndex++){
            result.append(new ExpressionAndType(reifiedTypeArgName(tpIndex).makeIdent(), gen.makeTypeDescriptorType()));
        }
View Full Code Here

        if (!Strategy.defaultParameterMethodStatic(getPrimaryDeclaration())
                && Strategy.defaultParameterMethodTakesThis(param.getModel())) {
            names.append(varBaseName.suffixedBy(Suffix.$argthis$).makeIdent());
        }
        // put all the required reified type args too
        ProducedReference ref = gen.resolveAliasesForReifiedTypeArguments(producedReference);
        int tpCount = gen.getTypeParameters(ref).size();
        for(int tpIndex = 0;tpIndex<tpCount;tpIndex++){
            names.append(reifiedTypeArgName(tpIndex).makeIdent());
        }
        final int parameterIndex = parameterIndex(param);
View Full Code Here

        JCExpression defaultedParameterInstance;
        // TODO Fix how we figure out the thisType, because it's doesn't
        // handle type parameters correctly
        // we used to use thisType = gen.getThisType(getPrimaryDeclaration());
        final JCExpression thisType;
        ProducedReference target = ((Tree.MemberOrTypeExpression)getPrimary()).getTarget();
        if (getPrimary() instanceof Tree.BaseMemberExpression) {
            if (Decl.withinClassOrInterface(getPrimaryDeclaration())) {
                // a member method
                thisType = gen.makeJavaType(target.getQualifyingType(), JT_NO_PRIMITIVES);
                defaultedParameterInstance = gen.naming.makeThis();
            } else {
                // a local or toplevel function
                thisType = gen.naming.makeName((TypedDeclaration)getPrimaryDeclaration(), Naming.NA_WRAPPER);
                defaultedParameterInstance = gen.naming.makeName((TypedDeclaration)getPrimaryDeclaration(), Naming.NA_MEMBER);
            }
        } else if (getPrimary() instanceof Tree.BaseTypeExpression
                || getPrimary() instanceof Tree.QualifiedTypeExpression) {
            ClassOrInterface declaration = (ClassOrInterface)((Tree.MemberOrTypeExpression) getPrimary()).getDeclaration();
            thisType = gen.makeJavaType(declaration.getType(), JT_COMPANION);
            defaultedParameterInstance = gen.make().NewClass(
                    null,
                    null,
                    gen.makeJavaType(declaration.getType(), JT_COMPANION),
                    List.<JCExpression>nil(), null);
        } else {
            if (isOnValueType()) {
                thisType = gen.makeJavaType(target.getQualifyingType());
            } else {
                thisType = gen.makeJavaType(target.getQualifyingType(), JT_NO_PRIMITIVES);
            }
            defaultedParameterInstance = callVarName.makeIdent();
        }
        JCVariableDecl thisDecl = gen.makeVar(varBaseName.suffixedBy(Suffix.$argthis$),
                thisType,
View Full Code Here

TOP

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

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.