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

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


        }
    }

    private void capture(Tree.Primary that) {
        if (that instanceof Tree.MemberOrTypeExpression) {
            TypedDeclaration d = (TypedDeclaration) ((Tree.MemberOrTypeExpression) that).getDeclaration();
            if (d==declaration) {
                if (d.isParameter()) {
                    if (!d.getContainer().equals(that.getScope()) || sameScope>0) { //a reference from a default argument
                        //expression of the same parameter
                        //list does not capture a parameter
                        ((MethodOrValue) d).setCaptured(true);
                    }
                } else if (d instanceof Value) {
View Full Code Here


        return true;
    }

    @Override
    public void visit(Tree.SpecifierStatement st) {
        TypedDeclaration d = ((Tree.SpecifierStatement) st).getDeclaration();
        //Just add shared and actual annotations to this declaration
        if (d != null) {
            Annotation ann = new Annotation();
            ann.setName("shared");
            d.getAnnotations().add(ann);
            ann = new Annotation();
            ann.setName("actual");
            d.getAnnotations().add(ann);
            if (d instanceof Method) {
                gen.encodeMethod((Method)d);
            } else if (d instanceof Value) {
                gen.encodeAttributeOrGetter((Value)d);
            } else {
                throw new RuntimeException("JS compiler doesn't know how to encode " +
                        d.getClass().getName() + " into model");
            }
        }
    }
View Full Code Here

                        sequencedType=null;
                    } else if (!first) {
                        gen.out(",");
                    }
                    if (arg instanceof Tree.SpreadArgument) {
                        TypedDeclaration td = pd == null ? null : pd.getModel();
                        int boxType = gen.boxUnboxStart(expr.getTerm(), td);
                        if (boxType == 4) {
                            arg.visit(gen);
                            gen.out(",");
                            describeMethodParameters(expr.getTerm());
View Full Code Here

            }
           
            else if (term instanceof Tree.BaseMemberExpression) {
                Tree.BaseMemberExpression bme =
                        (Tree.BaseMemberExpression) term;
                TypedDeclaration base =
                        resolveBaseMemberExpression(bme, true);
                if (base!=null) {
                    List<ProducedType> typeArgs =
                            inferTypeArguments(that, base, tas, null);
                    visitBaseMemberExpression(bme, base, typeArgs, tas);
                }
            }
           
            else if (term instanceof Tree.QualifiedMemberExpression) {
                Tree.QualifiedMemberExpression qme =
                        (Tree.QualifiedMemberExpression) term;
                TypedDeclaration member =
                        resolveQualifiedMemberExpression(qme, true);
                if (member!=null) {
                    ProducedType qt =
                            qme.getPrimary().getTypeModel().resolveAliases();
                    List<ProducedType> typeArgs =
View Full Code Here

    }
   
    @Override public void visit(Tree.BaseMemberExpression that) {
        super.visit(that);
        boolean notDirectlyInvoked = !that.getDirectlyInvoked();
        TypedDeclaration member =
                resolveBaseMemberExpression(that, notDirectlyInvoked);
        if (member!=null && notDirectlyInvoked) {
            Tree.TypeArguments tal = that.getTypeArguments();
            List<ProducedType> typeArgs;
            if (explicitTypeArguments(member, tal)) {
View Full Code Here

    private TypedDeclaration resolveBaseMemberExpression(
            Tree.BaseMemberExpression that,
            boolean error) {
        String name = name(that.getIdentifier());
        TypedDeclaration member = getTypedDeclaration(that.getScope(),
                name, that.getSignature(), that.getEllipsis(),
                that.getUnit());
        if (member==null) {
            if (!dynamic && error) {
                that.addError("function or value does not exist: '" +
View Full Code Here

    }
   
    @Override public void visit(Tree.QualifiedMemberExpression that) {
        super.visit(that);
        boolean notDirectlyInvoked = !that.getDirectlyInvoked();
        TypedDeclaration member =
                resolveQualifiedMemberExpression(that, notDirectlyInvoked);
        if (member!=null && notDirectlyInvoked) {
            Tree.TypeArguments tal = that.getTypeArguments();
            ProducedType pt =
                    that.getPrimary().getTypeModel()
View Full Code Here

                (!pt.getType().isUnknown() ||
                        that.getMemberOperator() instanceof Tree.SpreadOp);
        boolean nameNonempty = that.getIdentifier()!=null &&
                        !that.getIdentifier().getText().equals("");
        if (nameNonempty && check) {
            TypedDeclaration member;
            String name = name(that.getIdentifier());
            String container;
            boolean ambiguous;
            List<ProducedType> signature = that.getSignature();
            boolean ellipsis = that.getEllipsis();
            if (packageQualified) {
                container = "package '" + unit.getPackage().getNameAsString() + "'";
                Declaration pm = unit.getPackage()
                        .getMember(name, signature, ellipsis);
                if (pm instanceof TypedDeclaration) {
                    member = (TypedDeclaration) pm;
                }
                else {
                    member = null;
                }
                ambiguous = false;
            }
            else {
                pt = pt.resolveAliases(); //needed for aliases like "alias Id<T> => T"
                TypeDeclaration d = getDeclaration(that, pt);
                container = "type '" + d.getName(unit) + "'";
                ClassOrInterface ci =
                        getContainingClassOrInterface(that.getScope());
                if (ci!=null && d.inherits(ci) && !(d instanceof NothingType)) {
                    Declaration direct =
                            ci.getDirectMember(name, signature, ellipsis);
                    if (direct instanceof TypedDeclaration) {
                        member = (TypedDeclaration) direct;
                    }
                    else {
                        member = getTypedMember(d, name, signature, ellipsis, unit);
                    }
                }
                else {
                    member = getTypedMember(d, name, signature, ellipsis, unit);
                }
                ambiguous = member==null &&
                        d.isMemberAmbiguous(name, unit, signature, ellipsis);
            }
            if (member==null) {
                if (error) {
                    if (ambiguous) {
                        that.addError("method or attribute is ambiguous: '" +
                                name + "' for " + container);
                    }
                    else {
                        that.addError("method or attribute does not exist: '" +
                                name + "' in " + container, 100);
                        unit.getUnresolvedReferences().add(that.getIdentifier());
                    }
                }
            }
            else {
                member = (TypedDeclaration) handleAbstraction(member, that);
                that.setDeclaration(member);
                boolean selfReference = isSelfReference(p);
                if (!selfReference && !member.isShared()) {
                    member.setOtherInstanceAccess(true);
                }
                if (error) {
                    checkQualifiedVisibility(that, member, name, container,
                            selfReference);
                    checkSuperMember(that);
View Full Code Here

                // let it go, we already logged an error for the missing type
                return;
              }
              //checkNonlocalType(that.getType(), qtd);
              String container = "type '" + qtd.getName(unit) + "'";
              TypedDeclaration member =
                      getTypedMember(qtd, name, null, false, unit);
              if (member==null) {
                if (qtd.isMemberAmbiguous(name, unit, null, false)) {
                  that.addError("method or attribute is ambiguous: '" +
                      name + "' for " + container);
                }
                else {
                  that.addError("method or attribute does not exist: '" +
                      name + "' in " + container);
                }
              }
              else {
                checkQualifiedVisibility(that, member, name, container, false);
                setMemberMetatype(that, member);
              }
            }
            else {
                TypedDeclaration result =
                        getTypedDeclaration(that.getScope(),
                                name, null, false, unit);
                if (result!=null) {
                    checkBaseVisibility(that, result, name);
                    setMemberMetatype(that, result);
View Full Code Here

        }
    }
       
    @Override public void visit(Tree.TypedDeclaration that) {
        super.visit(that);
        TypedDeclaration dec = that.getDeclarationModel();
    if (!(that instanceof Tree.Variable)) {
            check(that.getType(), dec.isVariable(), dec);
        }
        if (dec.isParameter()) {
          flip();
            boolean topLevel = parameterizedDeclaration==null; //i.e. toplevel parameter in a parameter declaration
            if (topLevel) {
              parameterizedDeclaration = ((MethodOrValue) dec).getInitializerParameter().getDeclaration();
            }
View Full Code Here

TOP

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

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.