Package edu.mit.csail.sdg.alloy4

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


  }

  public static long run(String theory) {
    VizGUI viz = null;
    int i = 0;
    A4Reporter rep = new A4Reporter() {
      @Override
      public void warning(ErrorWarning msg) {
        System.out.print("Relevance Warning:\n"
            + (msg.toString().trim()) + "\n\n");
        System.out.flush();
View Full Code Here


  }


 
  protected A4Reporter createA4Reporter() {
    return new A4Reporter() {
      @Override
      public void warning(ErrorWarning msg) {
        System.out.print("Relevance Warning:\n"
            + (msg.toString().trim()) + "\n\n");
        System.out.flush();
View Full Code Here

  @Override
  protected void initializeAlloyAnalyzer() {
    // Alloy4 sends diagnostic messages and progress reports to the
    // A4Reporter.
    A4Reporter rep = createA4Reporter();

    try {

      javaMetamodel = CompUtil.parseEverything_fromFile(rep, null,
          alloyTheory);
View Full Code Here

                      return;
                   }
                }
            }
            if (msg instanceof Err) {
                Err ex = (Err)msg;
                String text = "fatal";
                boolean fatal = false;
                if (ex instanceof ErrorSyntax) text="syntax"; else if (ex instanceof ErrorType) text="type"; else fatal=true;
                if (ex.pos==Pos.UNKNOWN)
                    span.logBold("A "+text+" error has occurred:  ");
                else
                    span.logLink("A "+text+" error has occurred:  ", "POS: "+ex.pos.x+" "+ex.pos.y+" "+ex.pos.x2+" "+ex.pos.y2+" "+ex.pos.filename);
                if (verbosity>2) {
                    span.log("(see the "); span.logLink("stacktrace", "MSG: "+ex.dump()); span.log(")\n");
                } else {
                    span.log("\n");
                }
                span.logIndented(ex.msg.trim());
                span.log("\n");
                if (fatal && latestVersion>Version.buildNumber())
                    span.logBold(
                       "\nNote: You are running Alloy build#"+Version.buildNumber()+
                       ",\nbut the most recent is Alloy build#"+latestVersion+
                       ":\n( version "+latestName+" )\nPlease try to upgrade to the newest version,"+
                       "\nas the problem may have been fixed already.\n");
                span.flush();
                if (!fatal) gui.doVisualize("POS: "+ex.pos.x+" "+ex.pos.y+" "+ex.pos.x2+" "+ex.pos.y2+" "+ex.pos.filename);
                return;
            }
            if (msg instanceof Throwable) { Throwable ex = (Throwable)msg; span.logBold(ex.toString().trim()+"\n"); span.flush(); return; }
            if (!(msg instanceof Object[])) return;
            Object[] array = (Object[]) msg;
            if (array[0].equals("pop")) { span.setLength(len2); String x=(String)(array[1]); if (viz!=null && x.length()>0) OurDialog.alert(x); }
            if (array[0].equals("declare")) { gui.doSetLatest((String)(array[1])); }
            if (array[0].equals("S2")) { len3=len2=span.getLength(); span.logBold(""+array[1]); }
View Full Code Here

     * <p> The resulting instance may or may not satisfy all facts, and should be checked for consistency.
     */
    public void init(Field field, SimTupleset value) throws Err {
        if (value==null) { sfs.remove(field); return; }
        if (!value.empty() && value.arity()!=field.type().arity()) throw new ErrorType("Evaluator encountered an error: field "+field.label+" arity must not be " + value.arity());
        if (field.defined) throw new ErrorAPI("Evaluator cannot prebind the value of a defined field.");
        sfs.put(field, value);
        cacheUNIV = null;
        cacheSTRING = null;
        cacheForConstants.clear();
    }
View Full Code Here

    /** Returns an arbitrary atom from an arbitrary tuple.
     * @throws - ErrorAPI if this tupleset is empty
     */
    public SimAtom getAtom() throws ErrorAPI {
        if (tuples.size()>0) return tuples.get(0).get(0);
        if (min>=max) throw new ErrorAPI("This tupleset is empty");
        return SimAtom.make(min);
    }
View Full Code Here

    /** Returns an arbitrary tuple.
     * @throws - ErrorAPI if this tupleset is empty
     */
    public SimTuple getTuple() throws ErrorAPI {
        if (tuples.size()>0) return tuples.get(0);
        if (min>=max) throw new ErrorAPI("This tupleset is empty");
        SimAtom a = SimAtom.make(min);
        if (next) return SimTuple.make(a, SimAtom.make(min+1)); else return SimTuple.make(a);
    }
View Full Code Here

        }
    };

    /** Converts an A4TupleSet into a SimTupleset object. */
    private static SimTupleset convert(Object object) throws Err {
        if (!(object instanceof A4TupleSet)) throw new ErrorFatal("Unexpected type error: expecting an A4TupleSet.");
        A4TupleSet s = (A4TupleSet)object;
        if (s.size()==0) return SimTupleset.EMPTY;
        List<SimTuple> list = new ArrayList<SimTuple>(s.size());
        int arity = s.arity();
        for(A4Tuple t: s) {
View Full Code Here

     */
    public boolean cform(Expr x) throws Err {
        if (!x.errors.isEmpty()) throw x.errors.pick();
        Object y = visitThis(x);
        if (y instanceof Boolean) return Boolean.TRUE.equals(y);
        throw new ErrorFatal(x.span(), "This should have been a formula.\nInstead it is "+y);
    }
View Full Code Here

     */
    public int cint(Expr x) throws Err {
        if (!x.errors.isEmpty()) throw x.errors.pick();
        Object y = visitThis(x);
        if (y instanceof Integer) return trunc((Integer)y);
        throw new ErrorFatal(x.span(), "This should have been an integer expression.\nInstead it is "+y);
    }
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.