本文整理汇总了C#中Reko.Core.Block类的典型用法代码示例。如果您正苦于以下问题:C# Block类的具体用法?C# Block怎么用?C# Block使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Block类属于Reko.Core命名空间,在下文中一共展示了Block类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateBlockFlow
private BlockFlow CreateBlockFlow(Block block, Frame frame)
{
return new BlockFlow(
block,
prog.Architecture.CreateRegisterBitset(),
new SymbolicEvaluationContext(prog.Architecture, frame));
}
示例2: CreateBlockFlow
private BlockFlow CreateBlockFlow(Block block, Frame frame)
{
return new BlockFlow(
block,
new HashSet<RegisterStorage>(),
new SymbolicEvaluationContext(program.Architecture, frame));
}
示例3: FixInboundEdges
public void FixInboundEdges(Block blockToPromote)
{
// Get all blocks that are from "outside" blocks.
var inboundBlocks = blockToPromote.Pred.Where(p => p.Procedure != ProcNew).ToArray();
foreach (var inb in inboundBlocks)
{
if (inb.Statements.Count > 0)
{
var lastAddress = GetAddressOfLastInstruction(inb);
var callRetThunkBlock = Scanner.CreateCallRetThunk(lastAddress, inb.Procedure, ProcNew);
ReplaceSuccessorsWith(inb, blockToPromote, callRetThunkBlock);
callRetThunkBlock.Pred.Add(inb);
}
else
{
inb.Statements.Add(0, new CallInstruction(
new ProcedureConstant(Program.Platform.PointerType, ProcNew),
new CallSite(ProcNew.Signature.ReturnAddressOnStack, 0)));
Program.CallGraph.AddEdge(inb.Statements.Last, ProcNew);
inb.Statements.Add(0, new ReturnInstruction());
inb.Procedure.ControlGraph.AddEdge(inb, inb.Procedure.ExitBlock);
}
}
foreach (var p in inboundBlocks)
{
blockToPromote.Pred.Remove(p);
}
}
示例4: Setup
public void Setup()
{
mr = new MockRepository();
program = new Program();
proc = new Procedure("testProc", new Frame(PrimitiveType.Word32));
block = proc.AddBlock("l00100000");
trace = new RtlTrace(0x00100000);
r0 = new Identifier("r0", PrimitiveType.Word32, new RegisterStorage("r0", 0, 0, PrimitiveType.Word32));
r1 = new Identifier("r1", PrimitiveType.Word32, new RegisterStorage("r1", 1, 0, PrimitiveType.Word32));
r2 = new Identifier("r2", PrimitiveType.Word32, new RegisterStorage("r2", 2, 0, PrimitiveType.Word32));
sp = new Identifier("sp", PrimitiveType.Word32, new RegisterStorage("sp", 15, 0, PrimitiveType.Word32));
grf = proc.Frame.EnsureFlagGroup(Registers.eflags, 3, "SCZ", PrimitiveType.Byte);
var sc = new ServiceContainer();
var listener = mr.Stub<DecompilerEventListener>();
scanner = mr.StrictMock<IScanner>();
arch = mr.Stub<IProcessorArchitecture>();
program.Architecture = arch;
program.SegmentMap = new SegmentMap(
Address.Ptr32(0x00100000),
new ImageSegment(
".text",
new MemoryArea(Address.Ptr32(0x00100000), new byte[0x20000]),
AccessMode.ReadExecute));
arch.Replay();
program.Platform = new DefaultPlatform(null, arch);
arch.BackToRecord();
arch.Stub(s => s.StackRegister).Return((RegisterStorage)sp.Storage);
arch.Stub(s => s.PointerType).Return(PrimitiveType.Pointer32);
scanner.Stub(s => s.Services).Return(sc);
sc.AddService<DecompilerEventListener>(listener);
}
示例5: EndsInBranch
private bool EndsInBranch(Block block)
{
if (block.Succ.Count != 2)
return false;
if (block.Statements.Count < 1)
return false;
return block.Statements.Last.Instruction is Branch;
}
示例6: ReplaceJumpWithBranch
private void ReplaceJumpWithBranch(Block b1, Block b2)
{
Branch br = b2.Statements.Last.Instruction as Branch;
proc.ControlGraph.RemoveEdge(b1, b2);
b1.Statements.Add(b2.Statements.Last.LinearAddress, new Branch(br.Condition, b2.Succ[1]));
proc.ControlGraph.AddEdge(b1, b2.Succ[0]);
proc.ControlGraph.AddEdge(b1, b2.Succ[1]);
}
示例7: InsertAssignmentNewId
public Identifier InsertAssignmentNewId(Identifier idOld, Block b, int i)
{
Statement stm = new Statement(0, null, b);
SsaIdentifier sidNew = ssaIds.Add((Identifier)ssaIds[idOld].OriginalIdentifier, stm, idOld, false);
stm.Instruction = new Assignment(sidNew.Identifier, idOld);
b.Statements.Insert(i, stm);
return sidNew.Identifier;
}
示例8: InsertPhiStatement
/// <summary>
/// Creates a phi statement with slots for each predecessor block, then
/// inserts the phi statement as the first statement of the block.
/// </summary>
/// <param name="b">Block into which the phi statement is inserted</param>
/// <param name="v">Destination variable for the phi assignment</param>
/// <returns>The inserted phi Assignment</returns>
private Instruction InsertPhiStatement(Block b, Identifier v)
{
var stm = new Statement(
0,
new PhiAssignment(v, b.Pred.Count),
b);
b.Statements.Insert(0, stm);
return stm.Instruction;
}
示例9: Analyze
public void Analyze(Block b)
{
curBlock = b;
foreach (var stm in b.Statements)
{
if (flow[b].TerminatesProcess)
return;
stm.Instruction.Accept(this);
}
}
示例10: IndexOfInsertedCopy
public int IndexOfInsertedCopy(Block b)
{
int i = b.Statements.Count;
if (i > 0)
{
if (b.Statements[i-1].Instruction.IsControlFlow)
--i;
}
return i;
}
示例11: IsLiveAtCopyPoint
public bool IsLiveAtCopyPoint(Identifier id, Block b)
{
if (b.Statements.Count == 0)
return sla.IsLiveOut(id, b);
int i = IndexOfInsertedCopy(b);
if (i >= b.Statements.Count)
return sla.IsLiveOut(id, b.Statements[i-1]);
else
return sla.IsLiveIn(id, b.Statements[i]);
}
示例12: CreateBlockFlow
private BlockFlow CreateBlockFlow(Block block, Frame frame)
{
var bflow = new BlockFlow(
block,
prog.Architecture.CreateRegisterBitset(),
new SymbolicEvaluationContext(
prog.Architecture,
frame));
flow[block] = bflow;
return bflow;
}
示例13: EarInsertFrameReference
public void EarInsertFrameReference()
{
Procedure proc = new Procedure("foo", new Frame(PrimitiveType.Word32));
Block b = new Block(proc, "foo_1");
proc.ControlGraph.AddEdge(proc.EntryBlock, b);
proc.ControlGraph.AddEdge(b, proc.ExitBlock);
EscapedAccessRewriter ear = new EscapedAccessRewriter(proc);
ear.InsertFramePointerAssignment(new Mocks.FakeArchitecture());
Block x = proc.EntryBlock.Succ[0];
Assert.AreEqual(1, x.Statements.Count);
Assert.AreEqual("fp = &foo_frame", x.Statements[0].Instruction.ToString());
}
示例14: Coalesce
public static void Coalesce(Block block, Block next)
{
foreach (Statement stm in next.Statements)
{
block.Statements.Add(stm);
}
block.Succ = new List<Block>(next.Succ);
ReplaceJumpsFrom(next, block);
next.Pred.Clear();
next.Statements.Clear();
next.Succ.Clear();
}
示例15: ReplaceJumpsFrom
public static bool ReplaceJumpsFrom(Block block, Block next)
{
bool change = false;
foreach (Block s in block.Succ)
{
for (int i = 0; i < s.Pred.Count; ++i)
{
if (s.Pred[i] == block)
{
s.Pred[i] = next;
change = true;
}
}
}
return change;
}