public Exp TranslateCallExp(Level home, Level dst, Label name, List<Exp> argValue) { Tree.ExpList args = null; for (int i = argValue.Count - 1; i >= 0; --i) { args = new Tree.ExpList(argValue[i].UnEx(), args); } Level lv = home; Expr staticLink = new TEMP(lv.Frame.FP()); while (dst.Parent != lv) { staticLink = lv.StaticLink().Acc.Exp(staticLink); lv = lv.Parent; } if (!name.Name.StartsWith("_")) args = new Tree.ExpList(staticLink, args); return new Ex(new CALL(new NAME(name), args)); }
public Exp TranslateCallExp(Level home, Level dst, Label name, List <Exp> argValue) { Tree.ExpList args = null; for (int i = argValue.Count - 1; i >= 0; --i) { args = new Tree.ExpList(argValue[i].UnEx(), args); } Level lv = home; Expr staticLink = new TEMP(lv.Frame.FP()); while (dst.Parent != lv) { staticLink = lv.StaticLink().Acc.Exp(staticLink); lv = lv.Parent; } if (!name.Name.StartsWith("_")) { args = new Tree.ExpList(staticLink, args); } return(new Ex(new CALL(new NAME(name), args))); }
public static StmExpList Reorder(Tree.ExpList exps) { if (exps == null) { return(NopNull); } else { Tree.Expr a = exps.Head; if (a is Tree.CALL) { Temp.Temp t = new Temp.Temp(); Tree.Expr e = new Tree.ESEQ(new Tree.MOVE(new Tree.TEMP(t), a), new Tree.TEMP(t)); return(Reorder(new Tree.ExpList(e, exps.Tail))); } else { Tree.ESEQ aa = DoExp(a); StmExpList bb = Reorder(exps.Tail); if (Commute(bb.Stm, aa.Exp)) { return(new StmExpList(Seq(aa.Stm, bb.Stm), new Tree.ExpList(aa.Exp, bb.Exps))); } else { Temp.Temp t = new Temp.Temp(); return(new StmExpList( Seq(aa.Stm, Seq(new Tree.MOVE(new Tree.TEMP(t), aa.Exp), bb.Stm)), new Tree.ExpList(new Tree.TEMP(t), bb.Exps))); } } } }
public override Tree.Stm Build(Tree.ExpList kids) { return(new Tree.MOVE(Dst, Src.Build(kids))); }
public StmExpList(Tree.Stm s, Tree.ExpList e) { Stm = s; Exps = e; }
public override Tree.Stm Build(Tree.ExpList kids) { return(new Tree.EXP(Call.Build(kids))); }
public StmExpList(Tree.Stm s, Tree.ExpList e) { Stm = s; Exps = e; }