Package edu.mit.csail.sdg.alloy4

Examples of edu.mit.csail.sdg.alloy4.ErrorType


    }

    /** {@inheritDoc} */
    @Override final<T> T accept(VisitReturn<T> visitor) throws Err {
        if (!errors.isEmpty()) throw errors.pick();
        throw new ErrorType(span(), "This expression failed to be resolved.");
    }
View Full Code Here


    }

    /** Return the relational join between this and that (throws ErrorType if this.arity==1 and that.arity==1) */
    public SimTupleset join(SimTupleset that) throws ErrorType {
       if (empty() || that.empty()) return EMPTY;
       if (arity()==1 && that.arity()==1) throw new ErrorType("Cannot join two unary relations.");
       TempList<SimTuple> ans = new TempList<SimTuple>();
       for(SimTuple a: this) for(SimTuple b: that) if (a.tail()==b.head()) {
          SimTuple c = a.join(b);
          if (!ans.contains(c)) ans.add(c);
       }
View Full Code Here

            ambiguous = ambiguous || x.ambiguous;
            errs = errs.make(x.errors);
            weight = weight + x.weight;
            if (x.mult!=0) errs = errs.make(new ErrorSyntax(x.span(), "Multiplicity expression not allowed here."));
            if (a>0 && x.errors.isEmpty() && !x.type.hasArity(a))
              errs = errs.make(new ErrorType(x.span(), "This should have arity "+a+" but instead its possible type(s) are "+x.type));
            newargs.add(x);
        }
        Type t=Type.FORMULA;
        if (!fun.isPred && errs.size()==0) {
            final Type tt = fun.returnDecl.type;
View Full Code Here

        }
        if (op==Op.TOTALORDER) {
           if (newargs.size()!=3) {
              errs = errs.make(new ErrorSyntax(pos, "The builtin pred/totalOrder[] predicate must be called with exactly three arguments."));
           } else if (errs.isEmpty()) {
              if (!newargs.get(0).type.hasArity(1)) errs = errs.make(new ErrorType(pos, "The first argument to pred/totalOrder must be unary."));
              if (!newargs.get(1).type.hasArity(1)) errs = errs.make(new ErrorType(pos, "The second argument to pred/totalOrder must be unary."));
              if (!newargs.get(2).type.hasArity(2)) errs = errs.make(new ErrorType(pos, "The third argument to pred/totalOrder must be binary."));
           }
        }
        if (op==Op.DISJOINT) {
           if (newargs.size()<2) errs = errs.make(new ErrorSyntax(pos, "The builtin disjoint[] predicate must be called with at least two arguments."));
           if (commonArity==EMPTY) errs = errs.make(new ErrorType(pos, "The builtin predicate disjoint[] cannot be used among expressions of different arities."));
        }
        return new ExprList(pos, closingBracket, op, ambiguous, newargs.makeConst(), weight, errs);
    }
View Full Code Here

     * @throws ErrorType if is_int is true
     * @throws ErrorType if is_bool is true
     */
    public Expr toExpr() throws Err {
        int arity = arity();
        if (is_int || is_bool || arity<1) throw new ErrorType("Cannot convert this type into a bounding expression.");
        Expr ans = null;
        for(ProductType pt:this) {
            Expr pro = null;
            for(int i=0; i<arity; i++) if (pro==null) pro=pt.types[i]; else pro=pro.product(pt.types[i]);
            if (ans==null) ans=pro; else ans = ans.plus(pro);
View Full Code Here

                if (n==0) break; else n--;
                sb.append("  ");
                v.toString(sb, -1);
                sb.append(" (type = ").append(v.type).append(")\n");
            }
            errors = errors.make(new ErrorType(pos, sb.toString()));
        }
        return new ExprBadCall(pos, closingBracket, ambiguous, fun, args, errors, extraPenalty, weight);
    }
View Full Code Here

                }
                if (Type.INT2SIGINT) {
                    if (a.is_int && b.hasArity(1)) { left=left.cast2sigint(); continue; }
                    if (b.is_int && a.hasArity(1)) { right=right.cast2sigint(); continue; }
                }
                errs = errs.make(new ErrorType(cond.span().merge(right.span()).merge(left.span()),
                    "The then-clause and the else-clause must match.\nThe then-clause has type: "
                    + a + "\nand the else-clause has type: " + b));
            }
            break;
        }
View Full Code Here

            errs = errs.make(new ErrorSyntax(sub.span(), "Multiplicity expression not allowed here."));
        if (errs.size()==0 && var.type!=expr.type)
            if (var.type.is_int!=expr.type.is_int
             || var.type.is_bool!=expr.type.is_bool
             || var.type.arity()!=expr.type.arity())
                errs = errs.make(new ErrorType(var.span(), "This variable has type "+var.type+" but is bound to a value of type "+expr.type));
        return new ExprLet(pos, var, expr, sub, errs);
    }
View Full Code Here

     * @param warnings - the list that will receive any warning we generate; can be null if we wish to ignore warnings
     */
    Expr instantiate(Context cx, List<ErrorWarning> warnings) throws Err {
        if (cx.unrolls<=0) {
            Pos p = span();
            return new ExprBad(p, toString(), new ErrorType(p, "Macro substitution too deep; possibly indicating an infinite recursion."));
        }
        if (params.size() != args.size()) return this;
        Context cx2 = new Context(realModule, warnings, cx.unrolls-1);
        for(int n=params.size(), i=0; i<n; i++) {
            Expr tmp = args.get(i);
View Full Code Here

   /** Add a new per-atom fact; this expression is allowed to refer to this.decl.get() */
   public void addFact(Expr fact) throws Err {
      if (fact.ambiguous) fact = fact.resolve_as_formula(null);
      if (!fact.errors.isEmpty()) throw fact.errors.pick();
      if (!fact.type.is_bool) throw new ErrorType(fact.span(), "This expression must be a formula; instead its type is "+fact.type);
      facts.add(fact);
   }
View Full Code Here

TOP

Related Classes of edu.mit.csail.sdg.alloy4.ErrorType

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.