public string ToAssembly() { StringBuilder asmb = new StringBuilder(); int lb1 = Parser.labelcounter++; int lb2 = Parser.labelcounter++; asmb.AppendLine(":" + lb1); //Checker asmb.AppendLine("ldloc " + from); asmb.Append(to.ToAssembly()); asmb.AppendLine("cls"); asmb.AppendLine("jn " + lb2); //Increment asmb.AppendLine("ldloc " + from); asmb.Append(by.ToAssembly()); asmb.AppendLine("add"); asmb.AppendLine("stloc " + from); //Body foreach (ISTMT s in body) { asmb.Append(s.ToAssembly()); } asmb.AppendLine("jmp " + lb1); asmb.AppendLine(":" + lb2); return asmb.ToString(); }
public string ToAssembly() { StringBuilder sb = new StringBuilder(); int lb1 = Parser.labelcounter++; int lb2 = Parser.labelcounter++; sb.Append(eval.ToAssembly()); sb.AppendLine("jn " + lb1.ToString()); foreach (ISTMT s in truebody) { sb.Append(s.ToAssembly()); } sb.AppendLine("jmp " + lb2.ToString()); sb.AppendLine(":" + lb1.ToString()); if (falsebody != null) { foreach (ISTMT s in falsebody) { sb.Append(s.ToAssembly()); } } sb.AppendLine(":" + lb2.ToString()); return sb.ToString(); }
public string ToAssembly() { StringBuilder sb = new StringBuilder(); sb.Append(value.ToAssembly()); sb.AppendLine("ret"); return sb.ToString(); }
public string ToAssembly() { StringBuilder asm = new StringBuilder(); asm.Append(value.ToAssembly()); asm.AppendLine("stloc " + name); return asm.ToString(); }
public string ToAssembly() { StringBuilder asmb = new StringBuilder(); int lbl1 = Parser.labelcounter++; int lbl2 = Parser.labelcounter++; asmb.AppendLine(":" + lbl1); asmb.Append(expr.ToAssembly()); asmb.AppendLine("jn " + lbl2); foreach (ISTMT s in body) { asmb.Append(s.ToAssembly()); } asmb.AppendLine("jmp " + lbl1); asmb.AppendLine(":" + lbl2); return asmb.ToString(); }
public string ToAssembly() { StringBuilder sb = new StringBuilder(); sb.Append(first.ToAssembly()); sb.Append(last.ToAssembly()); if (op == '<') { sb.AppendLine("cls"); } else if (op == '=') { sb.AppendLine("cmp"); } else if (op == '>') { sb.AppendLine("cgt"); } return sb.ToString(); }