public static void CompileSLoop(IType body, Environment e, Function p) { var(pa, b) = Util.RequireAtLeast(body, 1, "SLOOP"); IType cond = pa[0]; var lBefore = new IL.Label("sloop:|cond body"); var lAfter = new IL.Label("sloop: cond body|"); p.Add(lBefore); Core.CompileSingleExpr(cond, e, p); p.Add(new IL.ConditionalJumpInstruction(lAfter, e.rax, false)); CompileProgn(b, e, p); p.Add(new IL.UnconditionalJumpInstruction(lBefore)); p.Add(lAfter); }
public static void CompileIf(IType body, Environment e, Function p) { var param = Util.RequireExactly(body, 3, "IF"); IType cond = param[0], good = param[1], bad = param[2]; Core.CompileSingleExpr(cond, e, p); var lBadGood = new IL.Label("if:cond bad|good"); var lGood = new IL.Label("if:cond bad good|"); p.Add(new IL.ConditionalJumpInstruction(lBadGood, e.rax, true)); Core.CompileSingleExpr(bad, e, p); p.Add(new IL.UnconditionalJumpInstruction(lGood)); p.Add(lBadGood); Core.CompileSingleExpr(good, e, p); p.Add(lGood); }
private void GenLabel(IL.Label label) { Gen(new I.Label { ILLabel = label }); }
/// <summary> /// Construct an operand from a value. /// </summary> /// <param name="x">The operand value.</param> public Operand(IL.Label x) : this() { this.Label = x; }