本文整理汇总了C#中Reko.Core.Statement类的典型用法代码示例。如果您正苦于以下问题:C# Statement类的具体用法?C# Statement怎么用?C# Statement使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Statement类属于Reko.Core命名空间,在下文中一共展示了Statement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: StatementNavigator
public StatementNavigator(Program program, Statement stm, IServiceProvider services)
{
this.program = program;
this.Statement = stm;
this.services = services;
this.Text = program.SegmentMap.MapLinearAddressToAddress(stm.LinearAddress).ToString();
}
示例2: DisplayStatement
public void DisplayStatement(Program program, Statement stm)
{
var pane = new CombinedCodeViewInteractor();
var windowType = typeof(CombinedCodeViewInteractor).Name;
var proc = stm.Block.Procedure;
var frame = ShowWindow(windowType, proc.Name, proc, pane);
((CombinedCodeViewInteractor)frame.Pane).DisplayStatement(program, stm);
}
示例3: 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;
}
示例4: 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;
}
示例5: Test2
public void Test2()
{
BinaryExpression b = m.IAdd(id, m.UMul(id, 5));
Assignment ass = new Assignment(x, b);
Statement stm = new Statement(0, ass, null);
Add_mul_id_c_id_Rule rule = new Add_mul_id_c_id_Rule(new SsaEvaluationContext(ssaIds));
Assert.IsTrue(rule.Match(b));
ass.Src = rule.Transform();
Assert.AreEqual("x = id *u 0x00000006", ass.ToString());
}
示例6: DisplayStatement
public void DisplayStatement(Program program, Statement stm)
{
this.program = program;
this.proc = stm.Block.Procedure;
this.showProcedures = true;
ProgramChanged();
if (program != null)
{
var addr = program.SegmentMap.MapLinearAddressToAddress(stm.LinearAddress);
SelectedAddress = addr;
}
}
示例7: SsaIdentifier
public SsaIdentifier(Identifier id, Identifier eOrig, Statement stmDef, Expression exprDef, bool isSideEffect)
{
if (id == null)
throw new ArgumentNullException("id");
if (eOrig == null)
throw new ArgumentNullException("eOrig");
this.Identifier = id;
this.OriginalIdentifier = eOrig;
this.DefStatement = stmDef;
this.DefExpression = exprDef;
this.IsSideEffect = isSideEffect;
this.Uses = new List<Statement>();
}
示例8: Test1
public void Test1()
{
BinaryExpression b = m.Shl(m.SMul(id, 3), 2);
Assignment ass = new Assignment(x, b);
Statement stm = new Statement(0, ass, null);
ssaIds[id].Uses.Add(stm);
ssaIds[id].Uses.Add(stm);
var rule = new Shl_mul_e_Rule(null);
Assert.IsTrue(rule.Match(b));
ass.Src = rule.Transform();
Assert.AreEqual("x = id *s 0x0000000C", ass.ToString());
}
示例9: AreConstrained
public bool AreConstrained(Statement def, Statement use)
{
SideEffectFlags defFlags = FindSideEffect(def.Instruction);
int iUse = use.Block.Statements.IndexOf(use);
for (int i = def.Block.Statements.IndexOf(def) + 1; i < def.Block.Statements.Count; ++i)
{
if (i == iUse)
return false;
if (Conflict(defFlags, FindSideEffect(def.Block.Statements[i].Instruction)))
return true;
}
return true;
}
示例10: SetDefStatement
private void SetDefStatement(Statement stm, SsaIdentifier sid)
{
List<SsaIdentifier> sids;
if (defsByStatement.TryGetValue(sid.DefStatement, out sids))
{
sids.Remove(sid);
}
if (!defsByStatement.TryGetValue(stm, out sids))
{
sids = new List<SsaIdentifier>();
defsByStatement.Add(stm, sids);
}
sids.Add(sid);
}
示例11: RewriteCall
/// <summary>
/// Rewrites CALL instructions to function applications.
/// </summary>
/// <remarks>
/// Converts an opcode:
/// <code>
/// call procExpr
/// </code>
/// to one of:
/// <code>
/// ax = procExpr(bindings);
/// procEexpr(bindings);
/// </code>
/// </remarks>
/// <param name="proc">Procedure in which the CALL instruction exists</param>
/// <param name="stm">The particular statement of the call instruction</param>
/// <param name="call">The actuall CALL instruction.</param>
/// <returns>True if the conversion was possible, false if the procedure didn't have
/// a signature yet.</returns>
public bool RewriteCall(Procedure proc, Statement stm, CallInstruction call)
{
var callee = call.Callee as ProcedureConstant;
if (callee == null)
return false; //$REVIEW: what happens with indirect calls?
var procCallee = callee.Procedure;
var sigCallee = GetProcedureSignature(procCallee);
var fn = new ProcedureConstant(Program.Platform.PointerType, procCallee);
if (sigCallee == null || !sigCallee.ParametersValid)
return false;
var ab = new ApplicationBuilder(Program.Architecture, proc.Frame, call.CallSite, fn, sigCallee, true);
stm.Instruction = ab.CreateInstruction();
return true;
}
示例12: Transform
public Expression Transform(Statement stm)
{
if (binLeft.Operator == Operator.ISub)
cLeftRight = cLeftRight.Negate();
if (bin.Operator == Operator.ISub)
cRight = cRight.Negate();
BinaryOperator op = Operator.IAdd;
Constant c = ExpressionSimplifier.SimplifyTwoConstants(op, cLeftRight, cRight);
if (c.IsNegative)
{
c = c.Negate();
op = Operator.ISub;
}
return new BinaryExpression(op, bin.DataType, binLeft.Left, c);
}
示例13: Test1
public void Test1()
{
BinaryExpression b = m.IAdd(m.SMul(id, 4), id);
Assignment ass = new Assignment(x, b);
Statement stm = new Statement(0, ass, null);
ssaIds[id].Uses.Add(stm);
ssaIds[id].Uses.Add(stm);
ctx.Statement = stm;
Add_mul_id_c_id_Rule rule = new Add_mul_id_c_id_Rule(ctx);
Assert.IsTrue(rule.Match(b));
Assert.AreEqual(2, ssaIds[id].Uses.Count);
ass.Src = rule.Transform();
Assert.AreEqual("x = id *s 0x00000005", ass.ToString());
Assert.AreEqual(1, ssaIds[id].Uses.Count);
}
示例14: FindDefiningExpression
/// <summary>
/// Chases a chain statements to locate the expression that
/// defines the value of a condition code.
/// </summary>
/// <param name="sid"></param>
/// <returns></returns>
public void FindDefiningExpression(SsaIdentifier sid)
{
this.sid = sid;
negated = false;
stm = sid.DefStatement;
if (stm != null)
{
Statement stmOld = null;
defExpr = null;
while (stm != null && defExpr == null)
{
stmOld = stm;
stm = null;
stmOld.Instruction.Accept(this);
}
}
}
示例15: Creation
public void Creation()
{
CallGraph g = new CallGraph();
Procedure p1 = new Procedure("p1000", null);
Procedure p2 = new Procedure("p2000", null);
Procedure p3 = new Procedure("p3000", null);
Procedure p4 = new Procedure("p4000", null);
var pc1 = new ProcedureConstant(PrimitiveType.Pointer32, p1);
var pc2 = new ProcedureConstant(PrimitiveType.Pointer32, p2);
var pc3 = new ProcedureConstant(PrimitiveType.Pointer32, p3);
var pc4 = new ProcedureConstant(PrimitiveType.Pointer32, p4);
Statement s11 = new Statement(0, CreateCall(pc2), p1.EntryBlock);
Statement s12 = new Statement(0, CreateCall(pc2), p1.EntryBlock);
Statement s13 = new Statement(0, CreateCall(pc3), p1.EntryBlock);
p1.EntryBlock.Statements.Add(s11);
p1.EntryBlock.Statements.Add(s12);
p1.EntryBlock.Statements.Add(s13);
Statement s21 = new Statement(0, CreateCall(pc3), p2.EntryBlock);
Statement s22 = new Statement(0, CreateCall(pc4), p2.EntryBlock);
p2.EntryBlock.Statements.Add(s21);
p2.EntryBlock.Statements.Add(s22);
Statement s31 = new Statement(0, CreateCall(pc4), p3.EntryBlock);
p3.EntryBlock.Statements.Add(s31);
Statement s41 = new Statement(0, CreateCall(pc4), p4.EntryBlock);
g.AddEntryPoint(p1);
g.AddEdge(s11, p2);
g.AddEdge(s12, p2);
g.AddEdge(s13, p3);
g.AddEdge(s21, p3);
g.AddEdge(s22, p4);
g.AddEdge(s31, p4);
g.AddEdge(s41, p4); // recursion!
//$TODO: need Count
// Assert.IsTrue(g.Callees(p1).Count == 3);
// Assert.IsTrue(g.CallerStatements(p4).Count == 3);
}