Beispiel #1
0
        private void WriteFunctionCallExp(FunctionCallExpression functioncall, StringBuilder programBuilder)
        {
            foreach (var id in registerFile.listofFunctions)
            {
                if (id == functioncall.Id)
                {
                    recursive = true; break;
                }
            }
            if (recursive == false)
            {

                for (int i = 0; i < functioncall.Parameters.Exprlist.Count; i++)
                {
                    WriteExpr(functioncall.Parameters.Exprlist[i], registerFile, programBuilder);
                }
                programBuilder.AppendLine("\t pop ebp");
            }
            else
            {
                foreach (var param in functioncall.Parameters.Exprlist)
                {
                    WriteExpr(param, registerFile, programBuilder);
                }
            }
        }
Beispiel #2
0
 private void WriteFunctionDataHeader(FunctionCallExpression function, StringBuilder programBuilder)
 {
     int count = 0;
     programBuilder.AppendLine(".data");
     foreach (var parameters in function.Parameters.Exprlist)
     {
         programBuilder.AppendFormat("num{0}: .word  {1}", count, parameters.ToString());
         count += 1;
         programBuilder.AppendLine();
     }
 }
        private void WriteFunctionCallExp(FunctionCallExpression functioncall, StringBuilder programBuilder)
        {
            foreach (var id in registerFile.listofFunctions)
            {
                if (id == functioncall.Id)
                {
                    recursive = true; break;
                }
            }
            if (recursive == false)
            {
                WriteFunctionDataHeader(functioncall, headerBuilder);
                for (int i = 0; i < functioncall.Parameters.Exprlist.Count; i++)
                {
                    var register = registerFile.FirstAvailableArgument();
                    programBuilder.AppendFormat("\tlw {0}, num{1}", register, i.ToString());
                    programBuilder.AppendLine();
                    registerFile.savedArguments.Add(register, null);
                    param = true;
                }
                registerFile.FreeAllArgument();
                programBuilder.AppendFormat("\tjal {0}", GenerateLabel(functioncall.Id, functioncall.Parameters.Exprlist));
                programBuilder.AppendLine();
            }
            else
            {
                foreach (var param in functioncall.Parameters.Exprlist)
                {
                    WriteExpr(param, registerFile, programBuilder);
                }

            }
        }