示例#1
0
        public void Accept(CIL_Call call)
        {
            Text += "\t lw $a0, " + CurrentScope.VarInStack[call.This] + "($fp) \n" +
                    "\t sw $a0, -12($sp) \n";

            int i = -16;

            foreach (var arg in call.Args)
            {
                if (int.TryParse(arg, out int n))
                {
                    Text += "\t li $a0, " + n + "\n" +
                            "\t sw $a0, " + i + "($sp) \n";
                }
                else
                {
                    Text += "\t lw $a0, " + CurrentScope.VarInStack[arg] + "($fp) \n" +
                            "\t sw $a0, " + i + "($sp) \n";
                }

                i -= 4;
            }

            var indx = VT[call.Name];

            Text += "\t lw $a0, " + CurrentScope.VarInStack[call.This] + "($fp) \n" + // carga la instancia de la clase
                    "\t lw $a1, 8($a0) \n" +                                          // carga la referencia a la vt de la clase
                    "\t lw $a2, " + (4 * indx) + "($a1) \n" +                         // carga la referencia al metodo que quiere llamar
                    "\t jal $a2 \n" +
                    "\t sw $v0, " + CurrentScope.VarInStack[call.Dest] + "($fp) \n";
        }
示例#2
0
        public void Accept(CIL_Call call)
        {
            int i = -12;

            foreach (var arg in call.Args)
            {
                if (int.TryParse(arg, out int n))
                {
                    Text += "\t li $a0, " + n + "\n" +
                            "\t sw $a0, " + i + "($sp) \n";
                }
                else
                {
                    Text += "\t lw $a0, " + CurrentScope.VarInStack[arg] + "($fp) \n" +
                            "\t sw $a0, " + i + "($sp) \n";
                }

                i -= 4;
            }

            Text += "\t jal " + call.Name + "\n" +
                    "\t sw $v0, " + CurrentScope.VarInStack[call.Dest] + "($fp) \n";
        }