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