Ejemplo n.º 1
0
 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));
 }
Ejemplo n.º 2
0
            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)));
            }
Ejemplo n.º 3
0
 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)));
             }
         }
     }
 }
Ejemplo n.º 4
0
 public override Tree.Stm Build(Tree.ExpList kids)
 {
     return(new Tree.MOVE(Dst, Src.Build(kids)));
 }
Ejemplo n.º 5
0
 public StmExpList(Tree.Stm s, Tree.ExpList e)
 {
     Stm = s; Exps = e;
 }
Ejemplo n.º 6
0
 public override Tree.Stm Build(Tree.ExpList kids)
 {
     return(new Tree.EXP(Call.Build(kids)));
 }
Ejemplo n.º 7
0
 public StmExpList(Tree.Stm s, Tree.ExpList e)
 {
     Stm = s; Exps = e;
 }