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

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


        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());
View Full Code Here


        }
        if (d.getTypeParameters() != null && !d.getTypeParameters().isEmpty()) {
            out("$$targs$$,");
        }
        out(names.self(d), "){return ");
        TypeDeclaration aliased = ext.getType().getDeclarationModel();
        qualify(that, aliased);
        out(names.name(aliased), "(");
        if (ext.getInvocationExpression().getPositionalArgumentList() != null) {
            ext.getInvocationExpression().getPositionalArgumentList().visit(this);
            if (!ext.getInvocationExpression().getPositionalArgumentList().getPositionalArguments().isEmpty()) {
View Full Code Here

        }
    }

    /** Returns the name of the type or its $init$ function if it's local. */
    String typeFunctionName(final Tree.StaticType type, boolean removeAlias) {
        TypeDeclaration d = type.getTypeModel().getDeclaration();
        if (removeAlias && d.isAlias()) {
            d = d.getExtendedTypeDeclaration();
        }
        boolean inProto = opts.isOptimize()
                && (type.getScope().getContainer() instanceof TypeDeclaration);
        String tfn = memberAccessBase(type, d, false, qualifiedPath(type, d, inProto));
        if (removeAlias && !isImported(type.getUnit().getPackage(), d)) {
View Full Code Here

        if (!isMember && isImported(that == null ? null : that.getUnit().getPackage(), d)) {
            return names.moduleAlias(d.getUnit().getPackage().getModule());
        }
        else if (opts.isOptimize() && !inProto) {
            if (isMember && !(d.isParameter() && !d.isCaptured())) {
                TypeDeclaration id = that.getScope().getInheritingDeclaration(d);
                if (id == null) {
                    //a local declaration of some kind,
                    //perhaps in an outer scope
                    id = (TypeDeclaration) d.getContainer();
                }
                String path = "";
                Scope scope = that.getScope();
                if ((scope != null) && ((that instanceof ClassDeclaration)
                                        || (that instanceof InterfaceDeclaration))) {
                    // class/interface aliases have no own "this"
                    scope = scope.getContainer();
                }
                while (scope != null) {
                    if (scope instanceof TypeDeclaration) {
                        if (path.length() > 0) {
                            path += ".outer$";
                        } else {
                            path += names.self((TypeDeclaration) scope);
                        }
                    } else {
                        path = "";
                    }
                    if (scope == id) {
                        break;
                    }
                    scope = scope.getContainer();
                }
                return path;
            }
        }
        else {
            if (d != null && isMember && (d.isShared() || inProto || (!d.isParameter() && defineAsProperty(d)))) {
                TypeDeclaration id = d instanceof TypeAlias ? (TypeDeclaration)d : that.getScope().getInheritingDeclaration(d);
                if (id==null) {
                    //a shared local declaration
                    return names.self((TypeDeclaration)d.getContainer());
                }
                else {
View Full Code Here

                //Force -0
                out(".negated");
            }
            return;
        }
        final TypeDeclaration d = that.getTerm().getTypeModel().getDeclaration();
        final boolean isint = d.inherits(that.getUnit().getIntegerDeclaration());
        Operators.unaryOp(that, isint?"(-":null, isint?")":".negated", this);
    }
View Full Code Here

        final boolean isint = d.inherits(that.getUnit().getIntegerDeclaration());
        Operators.unaryOp(that, isint?"(-":null, isint?")":".negated", this);
    }

    @Override public void visit(final Tree.PositiveOp that) {
        final TypeDeclaration d = that.getTerm().getTypeModel().getDeclaration();
        final boolean nat = d.inherits(that.getUnit().getIntegerDeclaration());
        //TODO if it's positive we leave it as is?
        Operators.unaryOp(that, nat?"(+":null, nat?")":null, this);
    }
View Full Code Here

        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

        }
    }

    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 {
                gen.out(gen.getClAlias(), "$init$AppliedMemberClass$meta$model()(");
            }
            TypeUtils.outputQualifiedTypename(null, gen.isImported(gen.getCurrentPackage(), td), ltype, gen, false);
            gen.out(",");
            TypeUtils.printTypeArguments(that, that.getTypeModel().getTypeArguments(), gen, false,
                    that.getTypeModel().getVarianceOverrides());
            if (targs != null && !targs.isEmpty()) {
                gen.out(",undefined,");
                TypeUtils.printTypeArguments(that, targs, gen, false,
                        that.getType().getTypeModel().getVarianceOverrides());
            }
            gen.out(")");
        } else if (td instanceof com.redhat.ceylon.compiler.typechecker.model.Interface) {
            if (td.isToplevel()) {
                gen.out(gen.getClAlias(), "$init$AppliedInterface$jsint()(");
            } else {
                gen.out(gen.getClAlias(), "$init$AppliedMemberInterface$meta$model()(");
            }
            TypeUtils.outputQualifiedTypename(null, gen.isImported(gen.getCurrentPackage(), td), ltype, gen, false);
View Full Code Here

    static void callSuperclass(final Tree.ExtendedType extendedType, final Class d, final Node that,
            final List<Declaration> superDecs, final GenerateJsVisitor gen) {
        if (extendedType!=null) {
            Tree.PositionalArgumentList argList = extendedType.getInvocationExpression()
                    .getPositionalArgumentList();
            TypeDeclaration typeDecl = extendedType.getType().getDeclarationModel();
            gen.out(gen.memberAccessBase(extendedType.getType(), typeDecl, false,
                    gen.qualifiedPath(that, typeDecl, false)),
                    (gen.opts.isOptimize() && (gen.getSuperMemberScope(extendedType.getType()) != null))
                    ? ".call(this," : "(");

            gen.getInvoker().generatePositionalArguments(extendedType.getInvocationExpression().getPrimary(),
                    argList, argList.getPositionalArguments(), false, false);
            if (argList.getPositionalArguments().size() > 0) {
                gen.out(",");
            }
            //There may be defaulted args we must pass as undefined
            final List<com.redhat.ceylon.compiler.typechecker.model.Parameter> superParams =
                    d.getExtendedTypeDeclaration().getParameterList().getParameters();
            if (superParams.size() > argList.getPositionalArguments().size()) {
                for (int i = argList.getPositionalArguments().size(); i < superParams.size(); i++) {
                    com.redhat.ceylon.compiler.typechecker.model.Parameter p = superParams.get(i);
                    if (p.isSequenced()) {
                        gen.out(gen.getClAlias(), "getEmpty(),");
                    } else {
                        gen.out("undefined,");
                    }
                }
            }
            //If the supertype has type arguments, add them to the call
            if (typeDecl.getTypeParameters() != null && !typeDecl.getTypeParameters().isEmpty()) {
                extendedType.getType().getTypeArgumentList().getTypeModels();
                TypeUtils.printTypeArguments(that, TypeUtils.matchTypeParametersWithArguments(typeDecl.getTypeParameters(),
                        extendedType.getType().getTypeArgumentList().getTypeModels()), gen, false, null);
                gen.out(",");
            }
            gen.out(gen.getNames().self(d), ")");
            gen.endLine(true);
View Full Code Here

            HashSet<String> myTypeArgs = new HashSet<>();
            for (TypeParameter tp : d.getTypeParameters()) {
                myTypeArgs.add(tp.getName());
            }
            for (Tree.StaticType st: satisfiedTypes.getTypes()) {
                TypeDeclaration typeDecl = st.getTypeModel().getDeclaration();
                gen.qualify(that, typeDecl);
                gen.out(gen.getNames().name((ClassOrInterface)typeDecl), "(");
                if (typeDecl.getTypeParameters() != null && !typeDecl.getTypeParameters().isEmpty()) {
                    TypeUtils.printTypeArguments(that, st.getTypeModel().getTypeArguments(), gen, d.isToplevel(), null);
                    gen.out(",");
                }
                gen.out(gen.getNames().self(d), ")");
                gen.endLine(true);
View Full Code Here

TOP

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

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.