public void extractFuncts(List functors, List functees, Exp orig) { List vars = body.freeVars(); if (vars.size() == 1) { Var v = (Var) vars.get(0); Exp functee = new Funct(v, body.copy()); Var v2 = new Var(functee.type()); Appl a = new Appl(v2, v); Exp e = body; body = a; Exp functorbody = orig.copy(); body = e; Exp functor = new Funct(v2, functorbody); functors.add(functor); functees.add(functee); } body.extractFuncts(functors, functees, orig); }
public void extractFuncts(List functors, List functees, Exp orig) { for (int i = 0; i < exps.size(); i++) { Exp e = exps.get(i); e.extractFuncts(functors, functees, orig); List vars = e.freeVars(); if (vars.size() == 1) { Var v = (Var) vars.get(0); Exp functee = new Funct(v, e.copy()); Var v2 = new Var(functee.type()); Appl a = new Appl(v2, v); exps.set(i, a); Exp functorbody = orig.copy(); exps.set(i, e); Exp functor = new Funct(v2, functorbody); functors.add(functor); functees.add(functee); } } }
public boolean wellTyped() { Iterator<Exp> i = exps.iterator(); Exp e; while (i.hasNext()) { e = i.next(); if (e == null || !e.wellTyped()) { // System.out.println("not well typed:"+e); return false; } // only allow sets of Integers if (!PType.I.matches(e.type())) { System.out.println("not type T:" + e); return false; } // System.out.println("well typed: "+e); } // System.out.println("conj well typed"); return true; }