public void Pdg_LoopWithIfElse() { var m = new ProcedureBuilder(); var c = m.Declare(PrimitiveType.Word32, "c"); var f = m.Declare(PrimitiveType.Bool, "f"); m.Label("loopHead"); m.BranchIf(m.Eq(c, 0), "done"); m.BranchIf(f, "then"); m.Label("else"); m.SideEffect(m.Fn("CallElse")); m.Jump("loopHead"); m.Label("then"); m.SideEffect(m.Fn("CallThen")); m.Jump("loopHead"); m.Label("done"); m.Return(); FindPostDominators(m); string sExp = "done (6): idom ProcedureBuilder_exit (7)" + nl + "else (4): idom loopHead (2)" + nl + "l1 (3): idom loopHead (2)" + nl + "loopHead (2): idom done (6)" + nl + "ProcedureBuilder_entry (1): idom loopHead (2)" + nl + "ProcedureBuilder_exit (7): idom " + nl + "then (5): idom loopHead (2)" + nl; Assert.AreEqual(sExp, sw.ToString()); }
public void DeclarationWithExpression() { emitter.EmitStatement(m.Declare(m.Local32("dwLoc14"), m.Word32(1))); Assert.AreEqual(1, stms.Count); AbsynDeclaration decl = (AbsynDeclaration)stms[0]; Assert.IsNotNull(decl.Expression); }
public void ProcStr_NestedWhile() { var r1 = m.Reg32("r1"); var r2 = m.Reg32("r2"); m.Label("head1"); m.BranchIf(m.Ge(r1, 4), "done1"); m.Label("body1"); m.Declare(r2, m.Word32(0)); m.Label("head2"); m.BranchIf(m.Ge(r2, 4), "done2"); m.Label("body2"); m.Store(m.IAdd( m.Word32(0x1232100), m.IAdd( m.IMul(r1, 4), r2)), m.Byte(0)); m.Assign(r2, m.IAdd(r2, 1)); m.Goto("head2"); m.Label("done2"); m.Assign(r1, m.IAdd(r1, 1)); m.Goto("head1"); m.Label("done1"); m.Return(); var sExp = #region Expected @" while (r1 < 0x04) { word32 r2 = 0x00; while (r2 < 0x04) { Mem0[0x01232100 + (r1 * 0x04 + r2):byte] = 0x00; r2 = r2 + 0x01; } r1 = r1 + 0x01; } return; "; #endregion RunTest(sExp, m.Procedure); }