// ** This class was generated with DemFGen (vers:09/27/2009) import gen.*; import edu.neu.ccs.demeterf.*; import edu.neu.ccs.demeterf.lib.*; public class InlineMaxEnv{ private MaxEnv func; public InlineMaxEnv(MaxEnv f){ func = f; } public Integer traverse(Exp _h){ return traverseExp(_h); } public Integer traverseVar(Var _h){ Integer _id = func.combine(_h.getId()); return func.combine((Var)_h,(Integer)_id); } public Integer traverseSub(Sub _h){ return func.combine((Sub)_h); } public Integer traverseOper(Oper _h){ if(_h instanceof Sub) return this.traverseSub((Sub)_h); else throw new RuntimeException("Unknown Oper Variant"); } public Integer traverseNum(Num _h){ Integer _val = func.combine(_h.getVal()); return func.combine((Num)_h,(Integer)_val); } public Integer traverseIfz(Ifz _h){ Integer _cnd = traverseExp(_h.getCnd()); Integer _thn = traverseExp(_h.getThn()); Integer _els = traverseExp(_h.getEls()); return func.combine((Ifz)_h,(Integer)_cnd, (Integer)_thn, (Integer)_els); } public Integer traverseExp(Exp _h){ if(_h instanceof Ifz) return this.traverseIfz((Ifz)_h); if(_h instanceof Def) return this.traverseDef((Def)_h); if(_h instanceof Bin) return this.traverseBin((Bin)_h); if(_h instanceof Var) return this.traverseVar((Var)_h); if(_h instanceof Num) return this.traverseNum((Num)_h); else throw new RuntimeException("Unknown Exp Variant"); } public Integer traverseDef(Def _h){ Integer _id = func.combine(_h.getId()); Integer _e = traverseExp(_h.getE()); Integer _body = traverseExp(_h.getBody()); return func.combine((Def)_h,(int)_id, (int)_e, (int)_body); } public Integer traverseBin(Bin _h){ Integer _op = traverseOper(_h.getOp()); Integer _left = traverseExp(_h.getLeft()); Integer _right = traverseExp(_h.getRight()); return func.combine((Bin)_h,(Integer)_op, (Integer)_left, (Integer)_right); } }