// ** This class was generated with DemFGen (vers:09/27/2009) package gen; import edu.neu.ccs.demeterf.lib.*; import edu.neu.ccs.demeterf.*; import edu.neu.ccs.demeterf.lib.*; /** Representation of Ifz */ public class Ifz extends Exp{ protected final Exp cnd; protected final Exp thn; protected final Exp els; /** Construct a(n) Ifz Instance */ public Ifz(Exp cnd, Exp thn, Exp els){ this.cnd = cnd; this.thn = thn; this.els = els; } /** Is the given object Equal to this Ifz? */ public boolean equals(Object o){ if(!(o instanceof Ifz))return false; if(o == this)return true; Ifz oo = (Ifz)o; return (((Object)cnd).equals(oo.cnd))&&(((Object)thn).equals(oo.thn))&&(((Object)els).equals(oo.els)); } /** Parse an instance of Ifz from the given String */ public static Ifz parse(String inpt) throws ParseException{ return new TheParser(new java.io.StringReader(inpt)).parse_Ifz(); } /** Parse an instance of Ifz from the given Stream */ public static Ifz parse(java.io.InputStream inpt) throws ParseException{ return new TheParser(inpt).parse_Ifz(); } /** Parse an instance of Ifz from the given Reader */ public static Ifz parse(java.io.Reader inpt) throws ParseException{ return new TheParser(inpt).parse_Ifz(); } /** Field Class for Ifz.cnd */ public static class cnd extends edu.neu.ccs.demeterf.control.Fields.any{} /** Field Class for Ifz.thn */ public static class thn extends edu.neu.ccs.demeterf.control.Fields.any{} /** Field Class for Ifz.els */ public static class els extends edu.neu.ccs.demeterf.control.Fields.any{} public int eval(Env ev){ return cnd.eval(ev)==0?thn.eval(ev):els.eval(ev); } static int lnum = 0; synchronized ident fresh(String s){ return new ident(s+"_"+lnum++); } public List compile(List env){ ident le = fresh("else"), ld = fresh("done"); return cnd.compile(env) .append(new IfNZ(le)) .append(thn.compile(env)) .append(new Jmp(ld)) .append(new Label(le)).append(els.compile(env)) .append(new Label(ld)); } public X accept(Vis v){ return v.visit(this); } public Exp simplify(){ Exp c = cnd.simplify(), t = thn.simplify(), e = els.simplify(); if(c.isNum()){ if(c.isZero())return t; else return e; } return new Ifz(c,t,e); } public int maxEnv(){ return Math.max(cnd.maxEnv(), Math.max(thn.maxEnv(), els.maxEnv())); } /** DGP method from Class Print */ public String print(){ return gen.Print.PrintM(this); } /** Getter for field Ifz.els */ public Exp getEls(){ return els; } /** Getter for field Ifz.thn */ public Exp getThn(){ return thn; } /** Getter for field Ifz.cnd */ public Exp getCnd(){ return cnd; } }