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

Examples of com.redhat.ceylon.compiler.typechecker.model.ProducedType$Substitution


        out(function, aname, "(");
        if (d.getTypeParameters() != null && !d.getTypeParameters().isEmpty()) {
            out("$$targs$$,");
        }
        out(names.self(d), "){");
        final ProducedType pt = ext.getTypeModel();
        final TypeDeclaration aliased = pt.getDeclaration();
        qualify(that,aliased);
        out(names.name(aliased), "(");
        if (!pt.getTypeArguments().isEmpty()) {
            TypeUtils.printTypeArguments(that, pt.getTypeArguments(), this, true,
                    pt.getVarianceOverrides());
            out(",");
        }
        out(names.self(d), ");}");
        endLine();
        out(aname,".$crtmm$=");
View Full Code Here


    }

    int boxUnboxStart(final Tree.Term fromTerm, boolean toNative) {
        // Box the value
        final boolean fromNative = isNative(fromTerm);
        final ProducedType fromType = fromTerm.getTypeModel();
        final String fromTypeName = Util.isTypeUnknown(fromType) ? "UNKNOWN" : fromType.getProducedTypeQualifiedName();
        if (fromNative != toNative || fromTypeName.startsWith("ceylon.language::Callable<")) {
            if (fromNative) {
                // conversion from native value to Ceylon value
                if (fromTypeName.equals("ceylon.language::Integer")) {
                    out("(");
View Full Code Here

        }
        out(" ");
        if (dynblock > 0 && Util.isTypeUnknown(that.getExpression().getTypeModel())) {
            Scope cont = Util.getRealScope(that.getScope()).getScope();
            if (cont instanceof Declaration) {
                final ProducedType dectype = ((Declaration)cont).getReference().getType();
                if (!Util.isTypeUnknown(dectype)) {
                    TypeUtils.generateDynamicCheck(that.getExpression(), dectype, this, false,
                            that.getExpression().getTypeModel().getTypeArguments());
                    endLine(true);
                    return;
View Full Code Here

    /** Returns true if both Terms' types is either Integer or Boolean. */
    private boolean canUseNativeComparator(final Tree.Term left, final Tree.Term right) {
        if (left == null || right == null || left.getTypeModel() == null || right.getTypeModel() == null) {
            return false;
        }
        final ProducedType lt = left.getTypeModel();
        final ProducedType rt = right.getTypeModel();
        final TypeDeclaration intdecl = left.getUnit().getIntegerDeclaration();
        final TypeDeclaration booldecl = left.getUnit().getBooleanDeclaration();
        return (intdecl.equals(lt.getDeclaration()) && intdecl.equals(rt.getDeclaration()))
                || (booldecl.equals(lt.getDeclaration()) && booldecl.equals(rt.getDeclaration()));
    }
View Full Code Here

            return null;
        }
        final HashMap<TypeParameter, ProducedType> targs = new HashMap<>();
        final Iterator<ProducedType> iter = expr.getTypeArguments().getTypeModels().iterator();
        for (TypeParameter tp : tparams) {
            ProducedType pt = iter.hasNext() ? iter.next() : tp.getDefaultTypeArgument();
            targs.put(tp, pt);
        }
        return targs;
    }
View Full Code Here

        if (node != null) {
            HashSet<PhasedUnit> units = new HashSet<PhasedUnit>();
            HashSet<com.redhat.ceylon.compiler.typechecker.model.Package> packs = new HashSet<>();
            if (node instanceof Tree.QualifiedMemberExpression) {
                final Tree.QualifiedMemberExpression exp = (Tree.QualifiedMemberExpression)node;
                ProducedType type = exp.getPrimary().getTypeModel();
                Map<String, DeclarationWithProximity> c2 = type.getDeclaration().getMatchingMemberDeclarations(
                        node.getUnit(), null, text, 0);
                comps.putAll(c2);
            } else {
                for (PhasedUnits pus : checker.getPhasedUnitsOfDependencies()) {
                    for (PhasedUnit pu : pus.getPhasedUnits()) {
View Full Code Here

    /** Closes a native array and invokes reifyCeylonType (rt$) with the specified type parameters. */
    static void closeSequenceWithReifiedType(final Node that, final Map<TypeParameter,ProducedType> types,
            final GenerateJsVisitor gen) {
        gen.out("].rt$(");
        boolean nonempty=false;
        ProducedType elem = null;
        for (Map.Entry<TypeParameter,ProducedType> e : types.entrySet()) {
            if (e.getKey().getName().equals("Element")) {
                elem = e.getValue();
            } else if (e.getKey().equals(gen.getTypeUtils().iterable.getTypeParameters().get(1))) {
                //If it's Nothing, it's nonempty
View Full Code Here

            gen.out(")");
        }
    }

    static void generateClosedTypeLiteral(final Tree.TypeLiteral that, final GenerateJsVisitor gen) {
        final ProducedType ltype = that.getType().getTypeModel();
        final TypeDeclaration td = ltype.getDeclaration();
        final Map<TypeParameter,ProducedType> targs = that.getType().getTypeModel().getTypeArguments();
        if (td instanceof com.redhat.ceylon.compiler.typechecker.model.Class) {
            if (Util.getContainingClassOrInterface(td.getContainer()) == null) {
                gen.out(gen.getClAlias(), "$init$AppliedClass$meta$model()(");
            } else {
View Full Code Here

        }
    }

    static void generateMemberLiteral(final Tree.MemberLiteral that, final GenerateJsVisitor gen) {
        final com.redhat.ceylon.compiler.typechecker.model.ProducedReference ref = that.getTarget();
        final ProducedType ltype = that.getType() == null ? null : that.getType().getTypeModel();
        final Declaration d = ref.getDeclaration();
        final Class anonClass = d.isMember()&&d.getContainer() instanceof Class && ((Class)d.getContainer()).isAnonymous()?(Class)d.getContainer():null;
        if (that instanceof Tree.FunctionLiteral || d instanceof Method) {
            gen.out(gen.getClAlias(), d.isMember()&&anonClass==null?"AppliedMethod$meta$model(":"AppliedFunction$meta$model(");
            if (ltype == null) {
                if (anonClass != null) {
                    gen.qualify(that, anonClass);
                    gen.out(gen.getNames().objectName(anonClass), ".");
                } else {
                    gen.qualify(that, d);
                }
            } else {
                if (ltype.getDeclaration().isMember()) {
                    outputPathToDeclaration(that, ltype.getDeclaration(), gen);
                } else {
                    gen.qualify(that, ltype.getDeclaration());
                }
                gen.out(gen.getNames().name(ltype.getDeclaration()));
                gen.out(".$$.prototype.");
            }
            if (d instanceof Value) {
                gen.out("$prop$", gen.getNames().getter(d), ",");
            } else {
                gen.out(gen.getNames().name(d),",");
            }
            if (d.isMember()&&anonClass==null) {
                if (that.getTypeArgumentList()!=null) {
                    gen.out("[");
                    boolean first=true;
                    for (ProducedType targ : that.getTypeArgumentList().getTypeModels()) {
                        if (first)first=false;else gen.out(",");
                        gen.out(gen.getClAlias(),"typeLiteral$meta({Type$typeLiteral:");
                        TypeUtils.typeNameOrList(that, targ, gen, false);
                        gen.out("})");
                    }
                    gen.out("]");
                    gen.out(",");
                } else {
                    gen.out("undefined,");
                }
                TypeUtils.printTypeArguments(that, that.getTypeModel().getTypeArguments(), gen, false,
                        that.getTypeModel().getVarianceOverrides());
            } else {
                TypeUtils.printTypeArguments(that, that.getTypeModel().getTypeArguments(), gen, false,
                        that.getTypeModel().getVarianceOverrides());
                if (anonClass != null) {
                    gen.out(",");
                    gen.qualify(that, anonClass);
                    gen.out(gen.getNames().objectName(anonClass));
                }
                if (ref.getTypeArguments() != null && !ref.getTypeArguments().isEmpty()) {
                    if (anonClass == null) {
                        gen.out(",undefined");
                    }
                    gen.out(",");
                    TypeUtils.printTypeArguments(that, ref.getTypeArguments(), gen, false,
                            ref.getType().getVarianceOverrides());
                }
            }
            gen.out(")");
        } else if (that instanceof ValueLiteral || d instanceof Value) {
            Value vd = (Value)d;
            if (vd.isMember() && anonClass==null) {
                gen.out(gen.getClAlias(), "$init$AppliedAttribute$meta$model()('");
                gen.out(d.getName(), "',");
            } else {
                gen.out(gen.getClAlias(), "$init$AppliedValue$jsint()(");
                if (anonClass == null) {
                    gen.out("undefined");
                } else {
                    gen.qualify(that, anonClass);
                    gen.out(gen.getNames().objectName(anonClass));
                }
                gen.out(",");
            }
            if (ltype == null) {
                if (anonClass != null) {
                    gen.qualify(that, anonClass);
                    gen.out(gen.getNames().objectName(anonClass), ".");
                } else {
                    gen.qualify(that, d);
                }
            } else {
                gen.qualify(that, ltype.getDeclaration());
                gen.out(gen.getNames().name(ltype.getDeclaration()));
                gen.out(".$$.prototype.");
            }
            if (d instanceof Value) {
                gen.out("$prop$", gen.getNames().getter(d),",");
            } else {
                gen.out(gen.getNames().name(d),",");
            }
            TypeUtils.printTypeArguments(that, that.getTypeModel().getTypeArguments(), gen, false,
                    that.getTypeModel().getVarianceOverrides());
            gen.out(")");
        } else {
            gen.out(gen.getClAlias(), "/*TODO:closed member literal*/typeLiteral$meta({Type$typeLiteral:");
            gen.out("{t:");
            if (ltype == null) {
                gen.qualify(that, d);
            } else {
                gen.qualify(that, ltype.getDeclaration());
                gen.out(gen.getNames().name(ltype.getDeclaration()));
                gen.out(".$$.prototype.");
            }
            if (d instanceof Value) {
                gen.out("$prop$", gen.getNames().getter(d));
            } else {
                gen.out(gen.getNames().name(d));
            }
            if (ltype != null && ltype.getTypeArguments() != null && !ltype.getTypeArguments().isEmpty()) {
                gen.out(",a:");
                TypeUtils.printTypeArguments(that, ltype.getTypeArguments(), gen, false,
                        ltype.getVarianceOverrides());
            }
            gen.out("}})");
        }
    }
View Full Code Here

    public static class StaticTypeComparator implements Comparator<Tree.StaticType> {

        @Override
        public int compare(StaticType o1, StaticType o2) {
            final ProducedType t1 = o1.getTypeModel();
            final ProducedType t2 = o2.getTypeModel();
            if (t1.isUnknown()) {
                return t2.isUnknown() ? 0 : -1;
            }
            if (t2.isUnknown()) {
                return t1.isUnknown() ? 0 : -1;
            }
            if (t1.isSubtypeOf(t2)) {
                return 1;
            }
            if (t2.isSubtypeOf(t1)) {
                return -1;
            }
            //Check the members
            for (Declaration d : t1.getDeclaration().getMembers()) {
                if (d instanceof TypedDeclaration || d instanceof ClassOrInterface) {
                    Declaration d2 = t2.getDeclaration().getMember(d.getName(), null, false);
                    if (d2 != null) {
                        final Declaration dd2 = Util.getContainingDeclaration(d2);
                        if (dd2 instanceof TypeDeclaration && t1.getDeclaration().inherits((TypeDeclaration)dd2)) {
                            return 1;
                        }
                    }
                }
            }
            for (Declaration d : t2.getDeclaration().getMembers()) {
                if (d instanceof TypedDeclaration || d instanceof ClassOrInterface) {
                    Declaration d2 = t1.getDeclaration().getMember(d.getName(), null, false);
                    if (d2 != null) {
                        final Declaration dd2 = Util.getContainingDeclaration(d2);
                        if (dd2 instanceof TypeDeclaration && t2.getDeclaration().inherits((TypeDeclaration)dd2)) {
                            return -1;
                        }
                    }
                }
            }
View Full Code Here

TOP

Related Classes of com.redhat.ceylon.compiler.typechecker.model.ProducedType$Substitution

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.