Esempio n. 1
0
        public override void gen(int begin, int after)
        {
            CurrentGenerator.Goto(after);
            foreach (var item in Params.ParamList)
            {
                if (item is OptParam)
                {
                    CurrentGenerator.OptParam(item as OptParam, (item as OptParam).DefaultValue, item.ParamType);
                }
                else
                {
                    CurrentGenerator.Param(item, item.ParamType);
                }
            }

            int label  = CurrentGenerator.AllocLabel();
            int label2 = CurrentGenerator.AllocLabel();

            ExitLabel = label2;
            CurrentGenerator.Label(label);
            CurrentGenerator.LabelFunc(this);
            Stmt.gen(begin, after);
            CurrentGenerator.LabelFuncEnd(this);
            CurrentGenerator.Label(ExitLabel);
            //CurrentGenerator.Return(null);
        }
Esempio n. 2
0
        public override Expr reduce()
        {
            foreach (var item in FunParams)
            {
                CurrentGenerator.Param(item);
            }
            Temp t = new Temp(Func.Params.ReturnType);

            CurrentGenerator.Temp(t);
            CurrentGenerator.Call(t, Func);
            CurrentGenerator.CallEnd();
            return(t);
        }
Esempio n. 3
0
 public override void gen(int begin, int after)
 {
     if (Caller.FunParams.Count() > 0)
     {
         foreach (var item in Caller.FunParams)
         {
             if (item.Param is FuncCall)
             {
                 Temp t = new Temp(Caller.Func.Params.ReturnType);
                 CurrentGenerator.Temp(t);
                 emitfunSet(item.Param, t);
                 CurrentGenerator.Param(t);
             }
             else
             {
                 CurrentGenerator.Param(item);
             }
         }
     }
     CurrentGenerator.Label(CurrentGenerator.AllocLabel());
     CurrentGenerator.Call(Caller);
     CurrentGenerator.CallEnd();
 }
Esempio n. 4
0
        //public int newlabel()
        //{
        //    return CurrentGenerator.AllocLabel();
        //}

        //public void emitLabel(int i)
        //{
        //    CurrentGenerator.Label("L" + i.ToString());

        //}

        //public void emit(string s)
        //{
        //    CurrentIO.EmitLine(s);
        //}

        //public void emitSrc(string s)
        //{
        //    CurrentIO.EmitSource(s);
        //}

        public void emitfunSet(Expr exp, Expr toVar)
        {
            FuncCall c = exp as FuncCall;

            if (c.FunParams?.Count() > 0)
            {
                foreach (PassParam item in c.FunParams)
                {
                    if (item.Param is FuncCall)
                    {
                        Temp t = new Temp(toVar.Type);
                        CurrentGenerator.Temp(t);
                        emitfunSet(item.Param, t);
                        CurrentGenerator.Param(t);
                    }
                    else
                    {
                        CurrentGenerator.Param(item);
                    }
                }
            }
            CurrentGenerator.Call(toVar, c.Func);
            CurrentGenerator.CallEnd();
        }