Ejemplo n.º 1
0
        public override void GenCode(StreamWriter sw)
        {
            int elseLabel = Globals.LastLabel++;

            emit(sw, "L{0}: ", elseLabel);
            doThen.GenCode(sw);
            cond.GenCode(sw);
            emit(sw, "brtrue L{0}" + Environment.NewLine, elseLabel);
        }
Ejemplo n.º 2
0
 public override void GenCode(StreamWriter sw)
 {
     emit(sw, ".method ");
     foreach (Modifier modifier in Modifiers)
     {
         emit(sw, makeLowerCase("{0} ", modifier));
     }
     emit(sw, "{0}(string[] args)" + Environment.NewLine + "{{" + Environment.NewLine, name);
     emit(sw, ".entrypoint" + Environment.NewLine);
     methodBody.GenCode(sw);
     emit(sw, "ret" + Environment.NewLine);
     emit(sw, "}}" + Environment.NewLine);
 }
Ejemplo n.º 3
0
        public override void GenCode(ref string output)
        {
            output += Environment.NewLine + ".method";

            foreach (var modifier in MethodModifiers)
            {
                output += $" {modifier.ToString().ToLower()}";
            }

            MethodHeader.GenCode(ref output);

            if (((MethodDeclarator)(MethodHeader.MethodDeclarator)).Identifier.Name.ToLower() == "main")
            {
                output += Environment.NewLine + ".entrypoint";
            }
            MethodBody.GenCode(ref output);
            output += Environment.NewLine + "ret" + Environment.NewLine + "}";
        }