Package edu.mit.csail.sdg.alloy4

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


        this.root = root;
        this.bitwidth = bitwidth;
        this.maxseq = maxseq;
        this.callbacks = new HashMap<Func,SimCallback>();
        if (bitwidth==32) { max=Integer.MAX_VALUE; min=Integer.MIN_VALUE; } else { max=(1<<(bitwidth-1))-1; min=(0-max)-1; }
        if (maxseq < 0)   throw new ErrorSyntax("The maximum sequence length cannot be negative.");
        if (maxseq > max) throw new ErrorSyntax("With integer bitwidth of "+bitwidth+", you cannot have sequence length longer than "+max);
        shiftmask = (1 << (32 - Integer.numberOfLeadingZeros(bitwidth-1))) - 1;
    }
View Full Code Here


        final int n = f.count();
        final Object candidate = n==0 ? cacheForConstants.get(f) : null;
        if (candidate!=null) return candidate;
        final Expr body = f.getBody();
        if (body.type().arity()<0 || body.type().arity()!=f.returnDecl.type().arity()) throw new ErrorType(body.span(), "Function return value not fully resolved.");
        for(Func ff:current_function) if (ff==f) throw new ErrorSyntax(x.span(), ""+f+" cannot call itself recursively!");
        Env<ExprVar,Object> newenv = new Env<ExprVar,Object>();
        List<SimTupleset> list = new ArrayList<SimTupleset>(x.args.size());
        for(int i=0; i<n; i++) { SimTupleset ts = cset(x.args.get(i)); newenv.put(f.get(i), ts);  list.add(ts); }
        final SimCallback cb = callbacks.get(f);
        if (cb!=null) {
View Full Code Here

           allsigs.add(s);
           choices.add(s);
           for(Field f:s.getFields()) choices.add(f);
       }
       // find <instance>..</instance>
       if (!xml.is("alloy")) throw new ErrorSyntax("The XML file's root node must be <alloy> or <instance>.");
       XMLNode inst = null;
       for(XMLNode sub: xml) if (sub.is("instance")) { inst=sub; break; }
       if (inst==null) throw new ErrorSyntax("The XML file must contain an <instance> element.");
       // set up the basic values of the A4Solution object
       final int bitwidth = Integer.parseInt(inst.getAttribute("bitwidth"));
       final int maxseq = Integer.parseInt(inst.getAttribute("maxseq"));
       final int max = (1<<(bitwidth-1))-1, min = 0-(1<<(bitwidth-1));
       if (bitwidth>=1 && bitwidth<=30) for(int i=min; i<=max; i++) { atoms.add(Integer.toString(i)); }
View Full Code Here

        this.isPred = (returnDecl==null);
        if (returnDecl==null) returnDecl = ExprConstant.FALSE;
        if (returnDecl.mult==0 && returnDecl.type.arity()==1) returnDecl = ExprUnary.Op.ONEOF.make(null, returnDecl);
        this.returnDecl = returnDecl;
        this.body = body;
        if (body.mult!=0) throw new ErrorSyntax(body.span(), "Multiplicity expression not allowed here.");
        this.decls = ConstList.make(decls);
        for(int n=count(), i=0; i<n; i++)
          for(int j=i+1; j<n; j++)
            if (get(i)==get(j))
              throw new ErrorSyntax(get(j).span(),
                "The same variable cannot appear more than once in a predicate/function's parameter list.");
        for(Decl d: this.decls) if (d.expr!=null && d.expr.hasCall())
           throw new ErrorSyntax(d.expr.span(), "Parameter declaration cannot contain predicate/function calls.");
        if (returnDecl.hasCall())
           throw new ErrorSyntax(returnDecl.span(), "Return type declaration cannot contain predicate/function calls.");
    }
View Full Code Here

            if (newBody.type.arity() != returnDecl.type.arity())
               throw new ErrorType(newBody.span(),
               "Function return type is "+returnDecl.type+",\nso the body must be a relation with arity "
               +returnDecl.type.arity()+".\nSo the body's type cannot be: "+newBody.type);
        }
        if (newBody.mult!=0) throw new ErrorSyntax(newBody.span(), "Multiplicity expression not allowed here.");
        this.body = newBody;
    }
View Full Code Here

        }
    }

    /** Construct a new simulation context with the given bitwidth and the given maximum sequence length. */
    public SimInstance(Module root, int bitwidth, int maxseq) throws Err {
        if (bitwidth<1 || bitwidth>32) throw new ErrorType("Bitwidth must be between 1 and 32.");
        this.root = root;
        this.bitwidth = bitwidth;
        this.maxseq = maxseq;
        this.callbacks = new HashMap<Func,SimCallback>();
        if (bitwidth==32) { max=Integer.MAX_VALUE; min=Integer.MIN_VALUE; } else { max=(1<<(bitwidth-1))-1; min=(0-max)-1; }
View Full Code Here

    /** Initializes the given sig to be associated with the given unary value; should only be called at the beginning.
     * <p> The resulting instance may or may not satisfy all facts, and should be checked for consistency.
     */
    public void init(Sig sig, SimTupleset value) throws Err {
        if (value==null) { sfs.remove(sig); return; }
        if (value.arity()>1) throw new ErrorType("Evaluator encountered an error: sig "+sig.label+" arity must not be " + value.arity());
        if (sig.builtin) throw new ErrorAPI("Evaluator cannot prebind the builtin sig \"" + sig.label + "\"");
        sfs.put(sig, value);
        cacheUNIV = null;
        cacheSTRING = null;
        cacheForConstants.clear();
View Full Code Here

    /** Initializes the given field to be associated with the given unary value; should only be called at the beginning.
     * <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

    /** Initializes the given var to be associated with the given unary value; should only be called at the beginning.
     * <p> The resulting instance may or may not satisfy all facts, and should be checked for consistency.
     */
    public void init(ExprVar var, SimTupleset value) throws Err {
        if (value==null) { sfs.remove(var); return; }
        if (!value.empty() && value.arity()!=var.type().arity()) throw new ErrorType("Evaluator encountered an error: skolem "+var.label+" arity must not be " + value.arity());
        sfs.put(var, value);
        cacheUNIV = null;
        cacheSTRING = null;
        cacheForConstants.clear();
    }
View Full Code Here

        final Func f = x.fun;
        final int n = f.count();
        final Object candidate = n==0 ? cacheForConstants.get(f) : null;
        if (candidate!=null) return candidate;
        final Expr body = f.getBody();
        if (body.type().arity()<0 || body.type().arity()!=f.returnDecl.type().arity()) throw new ErrorType(body.span(), "Function return value not fully resolved.");
        for(Func ff:current_function) if (ff==f) throw new ErrorSyntax(x.span(), ""+f+" cannot call itself recursively!");
        Env<ExprVar,Object> newenv = new Env<ExprVar,Object>();
        List<SimTupleset> list = new ArrayList<SimTupleset>(x.args.size());
        for(int i=0; i<n; i++) { SimTupleset ts = cset(x.args.get(i)); newenv.put(f.get(i), ts);  list.add(ts); }
        final SimCallback cb = callbacks.get(f);
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.