Package edu.mit.csail.sdg.alloy4

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


    }

    /** {@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

   /** Convenience method that generates a type warning with "msg" as the message,
    * and includes the left and right bounding types in the message.
    */
   private ErrorWarning warn(String msg) {
      return new ErrorWarning(pos, msg
            +"\nLeft type = " + Type.removesBoolAndInt(left.type)
            +"\nRight type = " + Type.removesBoolAndInt(right.type));
   }
View Full Code Here

   /** Convenience method that generates a type warning with "msg" as the message,
    * and includes the parent's relevance type, as well as the left and right bounding types in the message.
    */
   private ErrorWarning warn(String msg, Type parent) {
      return new ErrorWarning(pos, msg
         + "\nParent's relevant type = " + Type.removesBoolAndInt(parent)
         + "\nLeft type = " + Type.removesBoolAndInt(left.type)
         + "\nRight type = " + Type.removesBoolAndInt(right.type));
   }
View Full Code Here

   //============================================================================================================//

   /** {@inheritDoc} */
   @Override public Expr resolve(Type p, Collection<ErrorWarning> warns) {
      if (errors.size()>0) return this;
      ErrorWarning w=null;
      Type a=left.type, b=right.type;
      switch(op) {
        case MUL: case DIV: case REM: case LT: case LTE: case GT: case GTE: case SHL: case SHR: case SHA:
        case NOT_LTE: case NOT_GTE: case NOT_LT: case NOT_GT: {
           a=(b=Type.INT);
View Full Code Here

    //============================================================================================================//

    /** {@inheritDoc} */
    @Override public Expr resolve(Type p, Collection<ErrorWarning> warns) {
        if (errors.size()>0) return this;
        ErrorWarning w1=null, w2=null;
        Type s=p;
        switch(op) {
          case NOT:
            s=Type.FORMULA;
            break;
          case TRANSPOSE: case RCLOSURE: case CLOSURE:
            if (warns!=null && op!=Op.TRANSPOSE && type.join(type).hasNoTuple())
               w1=new ErrorWarning(pos, this+" is redundant since its domain and range are disjoint: "+sub.type.extract(2));
            s = (op!=Op.TRANSPOSE) ? resolveClosure(p, sub.type) : sub.type.transpose().intersect(p).transpose() ;
            if (warns!=null && s==EMPTY && p.hasTuple())
               w2=new ErrorWarning(sub.span(),
               "The value of this expression does not contribute to the value of the parent.\nParent's relevant type = "
               +p+"\nThis expression's type = "+sub.type.extract(2));
            break;
          case CARDINALITY: case NO: case ONE: case SOME: case LONE:
            s=Type.removesBoolAndInt(sub.type);
            break;
          case CAST2SIGINT:
            s=Type.INT;
            break;
          case CAST2INT:
            s=sub.type.intersect(SIGINT.type);
            if (warns!=null && s.hasNoTuple())
               w1=new ErrorWarning(sub.span(),
               "This expression should contain Int atoms.\nInstead, its possible type(s) are:\n"+sub.type.extract(1));
            break;
        }
        Expr sub = this.sub.resolve(s, warns);
        if (w1!=null) warns.add(w1);
View Full Code Here

                     +"Some warnings can affect the soundness of the analysis.\n"
                     +"To proceed despite the warnings, go to the Options menu.\n");
                }
            }
            if (array[0].equals("warning")) {
                ErrorWarning e = (ErrorWarning)(array[1]);
                if (!warnings.add(e)) return;
                Pos p=e.pos;
                span.logLink("Warning #"+warnings.size(), "POS: "+p.x+" "+p.y+" "+p.x2+" "+p.y2+" "+p.filename);
                span.log("\n"); span.logIndented(e.msg.trim()); span.log("\n\n");
            }
View Full Code Here

        commands=null;
        if (text==null) return null; // If this was called prior to the "text" being fully initialized
        OurSyntaxWidget t = text.get();
        if (Util.onMac()) frame.getRootPane().putClientProperty("windowModified", Boolean.valueOf(t.modified()));
        if (t.isFile()) frame.setTitle(t.getFilename()); else frame.setTitle("Alloy Analyzer "+Version.version());
        toolbar.setBorder(new OurBorder(false, false, text.count()<=1, false));
        int c = t.getCaret();
        int y = t.getLineOfOffset(c)+1;
        int x = c - t.getLineStartOffset(y-1)+1;
        status.setText("<html>&nbsp; Line "+y+", Column "+x
              +(t.modified()?" <b style=\"color:#B43333;\">[modified]</b></html>":"</html>"));
View Full Code Here

TOP

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

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.