1 package gnu.expr; 2 3 9 10 public class PushApply extends ExpWalker 11 { 12 public static void pushApply (Expression exp) 13 { 14 PushApply walker = new PushApply(); 15 walker.walk(exp); 16 } 17 18 protected Expression walkApplyExp(ApplyExp exp) 19 { 20 Expression func = exp.func; 21 if (func instanceof LetExp 22 && ! (func instanceof FluidLetExp)) { 24 LetExp let = (LetExp) func; 26 Expression body = let.body; 27 let.body = exp; 28 exp.func = body; 29 return let.walk(this); 30 } 31 if (func instanceof BeginExp) { 33 BeginExp begin = (BeginExp) func; 35 Expression[] stmts = begin.exps; 36 int last_index = begin.exps.length - 1; 37 exp.func = stmts[last_index]; 38 stmts[last_index] = exp; 39 return begin.walk(this); 40 } 41 exp.walkChildren(this); 42 return exp; 43 } 44 } 45 | Popular Tags |