Package edu.mit.csail.sdg.alloy4compiler.ast

Examples of edu.mit.csail.sdg.alloy4compiler.ast.Expr.type()


         Expr newBody = cx.check(ff.getBody());
         if (ff.isPred) newBody = newBody.resolve_as_formula(warns); else newBody = newBody.resolve_as_set(warns);
         errors = errors.make(newBody.errors);
         if (!newBody.errors.isEmpty()) continue;
         try { ff.setBody(newBody); } catch(Err er) {errors = errors.make(er); continue;}
         if (warns!=null && ff.returnDecl.type().hasTuple() && newBody.type().hasTuple() && !newBody.type().intersects(ff.returnDecl.type()))
            warns.add(new ErrorWarning(newBody.span(),
                  "Function return value is disjoint from its return type.\n"
                  +"Function body has type "+newBody.type() + "\n" + "but the return type is "+ff.returnDecl.type()));
         //else if (warns!=null && Version.experimental && !newBody.type.isSubtypeOf(ff.returnDecl.type))
         //  warns.add(new ErrorWarning(newBody.span(),
View Full Code Here


         Expr newBody = cx.check(ff.getBody());
         if (ff.isPred) newBody = newBody.resolve_as_formula(warns); else newBody = newBody.resolve_as_set(warns);
         errors = errors.make(newBody.errors);
         if (!newBody.errors.isEmpty()) continue;
         try { ff.setBody(newBody); } catch(Err er) {errors = errors.make(er); continue;}
         if (warns!=null && ff.returnDecl.type().hasTuple() && newBody.type().hasTuple() && !newBody.type().intersects(ff.returnDecl.type()))
            warns.add(new ErrorWarning(newBody.span(),
                  "Function return value is disjoint from its return type.\n"
                  +"Function body has type "+newBody.type() + "\n" + "but the return type is "+ff.returnDecl.type()));
         //else if (warns!=null && Version.experimental && !newBody.type.isSubtypeOf(ff.returnDecl.type))
         //  warns.add(new ErrorWarning(newBody.span(),
View Full Code Here

         if (!newBody.errors.isEmpty()) continue;
         try { ff.setBody(newBody); } catch(Err er) {errors = errors.make(er); continue;}
         if (warns!=null && ff.returnDecl.type().hasTuple() && newBody.type().hasTuple() && !newBody.type().intersects(ff.returnDecl.type()))
            warns.add(new ErrorWarning(newBody.span(),
                  "Function return value is disjoint from its return type.\n"
                  +"Function body has type "+newBody.type() + "\n" + "but the return type is "+ff.returnDecl.type()));
         //else if (warns!=null && Version.experimental && !newBody.type.isSubtypeOf(ff.returnDecl.type))
         //  warns.add(new ErrorWarning(newBody.span(),
         //      "Function may return a tuple not in its declared return type.\n"
         //      +"The Alloy Analyzer's analysis may be unsound\n"
         //      +"if it returns a tuple outside its declared return type.\n"
View Full Code Here

         //  warns.add(new ErrorWarning(newBody.span(),
         //      "Function may return a tuple not in its declared return type.\n"
         //      +"The Alloy Analyzer's analysis may be unsound\n"
         //      +"if it returns a tuple outside its declared return type.\n"
         //      +"Function body has type "+newBody.type+"\nbut the return type is "+ff.returnDecl.type));
         rep.typecheck(ff.toString()+", BODY:"+newBody.type()+"\n");
      }
      return errors;
   }

   /** Return an unmodifiable list of all functions in this module. */
 
View Full Code Here

      for(Map.Entry<String,Expr> e: asserts.entrySet()) {
         Expr expr = e.getValue();
         expr = cx.check(expr).resolve_as_formula(warns);
         if (expr.errors.isEmpty()) {
            e.setValue(expr);
            rep.typecheck("Assertion " + e.getKey() + ": " + expr.type()+"\n");
         } else errors = errors.make(expr.errors);
      }
      return errors;
   }
View Full Code Here

         String name = facts.get(i).a;
         Expr expr = facts.get(i).b;
         expr = cx.check(expr).resolve_as_formula(warns);
         if (expr.errors.isEmpty()) {
            facts.set(i, new Pair<String,Expr>(name, expr));
            rep.typecheck("Fact " + name + ": " + expr.type()+"\n");
         } else errors = errors.make(expr.errors);
      }
      for(Sig s: sigs.values()) {
         Expr f = res.old2appendedfacts.get(res.new2old.get(s));
         if (f == null) continue;
View Full Code Here

         } else {
            cx.put("this", s);
            formula = cx.check(f).resolve_as_formula(warns);
         }
         cx.remove("this");
         if (formula.errors.size()>0) errors = errors.make(formula.errors); else { s.addFact(formula);  rep.typecheck("Fact "+s+"$fact: " + formula.type()+"\n")}
      }
      return errors;
   }

   /** Return an unmodifiable list of all facts in this module. */
 
View Full Code Here

    @Override public Object visit(ExprCall x) throws Err {
        final Func f = x.fun;
        final Object candidate = f.count()==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.");
        final int n = f.count();
        int maxRecursion = unrolls;
        for(Func ff:current_function) if (ff==f) {
            if (maxRecursion<0) {
                throw new ErrorSyntax(x.span(), ""+f+" cannot call itself recursively!");
View Full Code Here

    @Override public Object visit(ExprCall x) throws Err {
        final Func f = x.fun;
        final Object candidate = f.count()==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.");
        final int n = f.count();
        int maxRecursion = unrolls;
        for(Func ff:current_function) if (ff==f) {
            if (maxRecursion<0) {
                throw new ErrorSyntax(x.span(), ""+f+" cannot call itself recursively!");
View Full Code Here

      }
      if (op == ExprQt.Op.ONE || op == ExprQt.Op.LONE) {
         boolean ok = true;
         for(int i=0; i<xvars.size(); i++) {
            Expr v = addOne(xvars.get(i).expr).deNOP();
            if (v.type().arity()!=1 || v.mult()!=ExprUnary.Op.ONEOF) { ok=false; break; }
         }
         if (op==ExprQt.Op.ONE && ok) return ((Expression) visit_qt(ExprQt.Op.COMPREHENSION, xvars, sub)).one();
         if (op==ExprQt.Op.LONE && ok) return ((Expression) visit_qt(ExprQt.Op.COMPREHENSION, xvars, sub)).lone();
      }
      if (op == ExprQt.Op.ONE) {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.