本文整理汇总了C#中Reko.UnitTests.Mocks.ProcedureBuilder.Eq方法的典型用法代码示例。如果您正苦于以下问题:C# ProcedureBuilder.Eq方法的具体用法?C# ProcedureBuilder.Eq怎么用?C# ProcedureBuilder.Eq使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Reko.UnitTests.Mocks.ProcedureBuilder
的用法示例。
在下文中一共展示了ProcedureBuilder.Eq方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildProgram
/// <summary>
/// Mutually recursive functions that jump into each other's bodies.
/// </summary>
/// <returns></returns>
public static Program BuildProgram()
{
var prog = new ProgramBuilder();
var m = new ProcedureBuilder("even");
var r1 = m.Register(1);
m.BranchIf(m.Eq0(r1), "done");
m.Assign(r1, m.ISub(r1, 1));
m.Call("odd", 4);
m.Assign(r1, m.Not(r1));
m.Return();
m.Label("done");
m.Assign(r1, true);
m.Return();
prog.Add(m);
m = new ProcedureBuilder("odd");
r1 = m.Register(1);
m.BranchIf(m.Eq(r1, 1), "done");
m.Assign(r1, m.ISub(r1, 1));
m.Call("event", 4);
m.Assign(r1, m.Not(r1));
m.Return();
m.Label("done");
m.Assign(r1, true);
m.Return();
prog.Add(m);
return prog.BuildProgram();
}
示例2: BuildSimpleLoop
private Procedure BuildSimpleLoop()
{
ProcedureBuilder m = new ProcedureBuilder();
Identifier p = m.Local32("p");
m.Assign(p, 0);
m.Label("loop");
m.BranchIf(m.Eq(p, 0x4000), "done");
m.Store(m.IAdd(p, 0x3000), m.Int32(0));
m.Assign(p, m.IAdd(p, 4));
m.Goto("loop");
m.Label("done");
m.Return();
return m.Procedure;
}
示例3: VpEquality2
public void VpEquality2()
{
// Makes sure that
// y = x - 2
// if (y == 0) ...
// doesn't get munged into
// y = x - 2
// if (x == 2)
ProcedureBuilder m = new ProcedureBuilder();
var ssa = new SsaState(m.Procedure, null);
this.ssaIds = ssa.Identifiers;
Identifier x = Reg32("x");
Identifier y = Reg32("y");
var stmX = m.Assign(x, m.LoadDw(Constant.Word32(0x1000300)));
ssaIds[x].DefStatement = m.Block.Statements.Last;
var stmY = m.Assign(y, m.ISub(x, 2));
ssaIds[y].DefStatement = m.Block.Statements.Last;
var stm = m.BranchIf(m.Eq(y, 0), "test");
Assert.AreEqual("x = Mem0[0x01000300:word32]", stmX.ToString());
Assert.AreEqual("y = x - 0x00000002", stmY.ToString());
Assert.AreEqual("branch y == 0x00000000 test", stm.ToString());
var vp = new ValuePropagator(arch, ssa);
vp.Transform(stm);
Assert.AreEqual("branch x == 0x00000002 test", stm.Instruction.ToString());
}
示例4: Pdg_InfiniteLoop
public void Pdg_InfiniteLoop()
{
ProcedureBuilder m = new ProcedureBuilder();
m.Label("Infinity");
m.BranchIf(m.Eq(m.LoadW(m.Word16(0x1234)), 0), "hop");
m.SideEffect(m.Fn("foo"));
m.Label("hop");
m.BranchIf(m.Eq(m.LoadW(m.Word16(0x5123)), 1), "Infinity");
m.SideEffect(m.Fn("bar"));
m.Jump("Infinity");
m.Return();
FindPostDominators(m);
string sExp =
"hop (4): idom ProcedureBuilder_exit (6)" + nl +
"Infinity (2): idom hop (4)" + nl +
"l1 (3): idom hop (4)" + nl +
"l2 (5): idom ProcedureBuilder_exit (6)" + nl +
"ProcedureBuilder_entry (1): idom Infinity (2)" + nl +
"ProcedureBuilder_exit (6): idom " + nl;
Assert.AreEqual(sExp, sw.ToString());
}
示例5: Pdg_LoopWithIfElse
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());
}