示例#1
0
        public override string GenerateCode()
        {
            MIPS.whileCount++;
            string code      = "";
            string whileName = "while" + MIPS.whileCount.ToString();
            string whileEnd  = "whileEnd" + MIPS.whileCount.ToString();

            code += whileName + ":\n";

            code += Cond.GenerateCode();
            string condEval = MIPS.LastReg();

            code += MIPS.Emit(MIPS.Opcodes.bne, condEval, "1", whileEnd);
            code += Body.GenerateCode();

            code += MIPS.Emit(MIPS.Opcodes.j, whileName);

            code += whileEnd + ":\n";
            return(code);
        }