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

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


                    that.addError("missing type arguments to: '" + method.getName(unit) + "'");
                }
            }
        }
        else if (result instanceof Value) {
            Value value = (Value) result;
            if (that.getTypeArgumentList() != null) {
                that.addError("does not accept type arguments: '" + result.getName(unit) + "'");
            }
            else {
                ProducedTypedReference pr = value.getProducedTypedReference(outerType,
                        Collections.<ProducedType>emptyList());
                that.setTarget(pr);
                that.setTypeModel(unit.getValueMetatype(pr));
            }
        }
View Full Code Here


        }
    }
   
    @Override
    public void visit(Tree.ObjectDefinition that) {
        Value value = that.getDeclarationModel();
        Class anonymousClass =
                (Class) value.getType().getDeclaration();
        validateMemberRefinement(that, anonymousClass);
        super.visit(that);
        //an object definition is always concrete
        List<Type> orderedTypes =
                sortDAGAndBuildMetadata(value.getTypeDeclaration(), that);
        checkForFormalsNotImplemented(that,
                orderedTypes, anonymousClass);
        checkForDoubleMemberInheritanceNotOverridden(that,
                orderedTypes, anonymousClass);
        checkForDoubleMemberInheritanceWoCommonAncestor(that,
View Full Code Here

                orderedTypes, anonymousClass);
    }

    @Override
    public void visit(Tree.ObjectArgument that) {
        Value value = that.getDeclarationModel();
        Class anonymousClass =
                (Class) value.getType().getDeclaration();
        validateMemberRefinement(that, anonymousClass);
        super.visit(that);
        //an object definition is always concrete
        List<Type> orderedTypes =
                sortDAGAndBuildMetadata(value.getTypeDeclaration(), that);
        checkForFormalsNotImplemented(that,
                orderedTypes, anonymousClass);
        checkForDoubleMemberInheritanceNotOverridden(that,
                orderedTypes, anonymousClass);
        checkForDoubleMemberInheritanceWoCommonAncestor(that,
View Full Code Here

        localNames = oldLocalNames;
    }

    @Override
    public void visit(Tree.AttributeDeclaration that) {
        Value model = that.getDeclarationModel();
        /*
         * we need a prefix to local type qualifiers for values in toplevel attributes
         * so that we can make a difference between qualifiers for:
         *
         * Anything() toplevel1 = void(){ class Local(){} }
         * Anything() toplevel2 = void(){ class Local(){} }
         *
         * Since both local types have the same name and the same package container at runtime,
         * and there's no proper ordering in a package, so we use 1toplevel1$ as a prefix. It
         * starts with a number because there's heuristics in the runtime model that local types
         * must start with a number.
         */
        if(model != null && model.isToplevel()){
            Map<String,Integer> oldLocalNames = localNames;
            String oldPrefix = prefix;
            localNames = new HashMap<String,Integer>();
            prefix = "1"+model.getName()+"$";

            super.visit(that);
       
            localNames = oldLocalNames;
            prefix = oldPrefix;
View Full Code Here

                declare();
            }
                Tree.SpecifierExpression se = that.getSpecifierExpression();
        boolean lazy = se instanceof Tree.LazySpecifierExpression;
              if (declaration instanceof Value) {
                Value value = (Value) declaration;
                  if (!value.isVariable() &&
                          lazy!=value.isTransient()) {
                  // check that all assignments to a non-variable, in
                    // different paths of execution, all use the same
                    // kind of specifier, all =>, or all =
                    // TODO: sometimes this error appears only because
                    //       of a later line which illegally reassigns
                  se.addError("value must be specified using => lazy specifier: '" +
                          member.getName() + "'");
                  }
                  if (lazy) {
                      if (value.isVariable()) {
                          se.addError("variable value may not be specified using => lazy specifier: '" +
                                  member.getName() + "'");
                      }
                      else if (value.isLate()) {
                          se.addError("late reference may not be specified using => lazy specifier: '" +
                                  member.getName() + "'");
                      }
                  }
              }
View Full Code Here

   
    @Override
    public void visit(Tree.AnyAttribute that) {
        super.visit(that);
        if (that.getType() instanceof Tree.SequencedType) {
            Value v = (Value) that.getDeclarationModel();
            Parameter p = v.getInitializerParameter();
            if (p==null) {
                that.getType().addError("value is not a parameter, so may not be variadic: '" +
                        v.getName() + "'");
            }
            else {
                p.setSequenced(true);
            }
        }
View Full Code Here

       
    }

    private void checkMember(Tree.Declaration that, Declaration dec) {
        if (dec instanceof Setter) {
            Value getter = ((Setter) dec).getGetter();
            dec.setRefinedDeclaration(getter.getRefinedDeclaration());
            return;
        }
        ClassOrInterface type = (ClassOrInterface) dec.getContainer();
        if (dec.isFormal() && type instanceof Class) {
            Class c = (Class) type;
View Full Code Here

        }
        else if (sv.isVariable()) {
            that.addError("inherited attribute may not be assigned in initializer and is variable so may not be refined by non-variable: " +
                    message(sv));
        }
        Value v = new Value();
        v.setName(sv.getName());
        v.setShared(true);
        v.setActual(true);
        v.getAnnotations().add(new Annotation("shared"));
        v.getAnnotations().add(new Annotation("actual"));
        v.setRefinedDeclaration(sv.getRefinedDeclaration());
        v.setUnit(that.getUnit());
        v.setContainer(c);
        v.setScope(c);
        v.setShortcutRefinement(true);
        setVisibleScope(v);
        c.addMember(v);
        that.setRefinement(true);
        that.setDeclaration(v);
        that.setRefined(sv);
        that.getUnit().addDeclaration(v);
        v.setType(new LazyProducedType(that.getUnit()) {
            @Override
            public Map<TypeParameter, ProducedType> initTypeArguments() {
                return rv.getType().getTypeArguments();
            }
            @Override
View Full Code Here

                //TODO: meaningful errors when parameters don't line up
                //      currently this is handled elsewhere, but we can
                //      probably do it better right here
                if (tpl==null || tpl.getParameters().size()<=j) {
                    Parameter vp = new Parameter();
                    Value v = new Value();
                    vp.setModel(v);
                    v.setInitializerParameter(vp);
                    vp.setSequenced(p.isSequenced());
                    vp.setAtLeastOne(p.isAtLeastOne());
                    vp.setDefaulted(p.isDefaulted());
                    vp.setName(p.getName());
                    v.setName(p.getName());
                    vp.setDeclaration(m);
                    v.setContainer(m);
                    v.setScope(m);
                    l.getParameters().add(vp);
                    v.setType(new LazyProducedType(that.getUnit()) {
                        @Override
                        public Map<TypeParameter, ProducedType> initTypeArguments() {
                            return rm.getTypedParameter(p).getFullType()
                                    .getTypeArguments();
                        }
View Full Code Here

            if (names.length>1) {
                that.setQualified(new ArrayList<Declaration>(names.length-1));
            }
            for (int i=1; i<names.length; i++) {
                if (base instanceof Value) {
                    Value value = (Value) base;
                    if (!value.isParameter()
                            && !value.isTransient()
                            && value.getTypeDeclaration() != null
                            && value.getTypeDeclaration().isAnonymous()) {
                        base = value.getTypeDeclaration();
                    }
                }
                if (base instanceof TypeDeclaration || base instanceof Functional) {
                    Declaration qualified = base.getMember(names[i], null, false);
                    if (qualified==null) {
View Full Code Here

TOP

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

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.