本文整理匯總了C#中Telerik.JustDecompiler.Ast.Statements.BlockStatement類的典型用法代碼示例。如果您正苦於以下問題:C# BlockStatement類的具體用法?C# BlockStatement怎麽用?C# BlockStatement使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
BlockStatement類屬於Telerik.JustDecompiler.Ast.Statements命名空間,在下文中一共展示了BlockStatement類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: ProcessBlock
void ProcessBlock (BlockStatement node)
{
for (int i = 0; i < node.Statements.Count - 1; i++)
{
var matcher = new UsingMatcher(node.Statements[i], node.Statements[i + 1]);
if (!matcher.Match ())
continue;
if (matcher.VariableReference != null)
{
context.MethodContext.RemoveVariable(matcher.VariableReference);
}
if (matcher.RemoveExpression)
{
node.Statements.RemoveAt(i); // declaration
node.Statements.RemoveAt(i); // try
node.AddStatementAt(i, matcher.Using);
}
else
{
int index = i + (matcher.HasExpression ? 1 : 0);
node.Statements.RemoveAt(index); // try
node.AddStatementAt(index, matcher.Using);
}
ProcessBlock(matcher.Using.Body);
}
}
示例2: TryRemoveConditionVariable
private void TryRemoveConditionVariable(BlockStatement node, Statement statement, int index)
{
if (!(statement is ExpressionStatement))
return;
var expressionStatement = (ExpressionStatement) statement;
if (!(expressionStatement.Expression.CodeNodeType == CodeNodeType.BinaryExpression &&
(expressionStatement.Expression as BinaryExpression).IsAssignmentExpression))
return;
var assingExpression = (BinaryExpression) expressionStatement.Expression;
if (!(assingExpression.Left is VariableReferenceExpression))
return;
if (assingExpression.Right is MethodInvocationExpression)
{
var variable = assingExpression.Left as VariableReferenceExpression;
if (variable.Variable.VariableType.Name != TypeCode.Boolean.ToString())
return;
}
var variableReferenceExpression = (VariableReferenceExpression) assingExpression.Left;
if (ContainsKey(variableReferenceExpression.Variable))
{
methodContext.RemoveVariable(variableReferenceExpression.Variable);
node.Statements.RemoveAt(index);
}
}
示例3: Process
/// <summary>
/// The entry point for the step.
/// </summary>
/// <param name="context">The decompilation context.</param>
/// <param name="body">The body of the method.</param>
/// <returns>Returns the updated body of the method.</returns>
public BlockStatement Process(DecompilationContext context, BlockStatement body)
{
MethodSpecificContext methodContext = context.MethodContext;
foreach (int key in methodContext.Expressions.BlockExpressions.Keys)
{
IList<Expression> expressionList = methodContext.Expressions.BlockExpressions[key];
Code lastInstructionCode = methodContext.ControlFlowGraph.InstructionToBlockMapping[key].Last.OpCode.Code;
bool endsWithConditionalJump = lastInstructionCode == Code.Brtrue || lastInstructionCode == Code.Brtrue_S ||
lastInstructionCode == Code.Brfalse || lastInstructionCode == Code.Brfalse_S;
for (int i = 0; i < expressionList.Count; i++)
{
expressionList[i] = (Expression)Visit(expressionList[i]);
}
if (endsWithConditionalJump)
{
expressionList[expressionList.Count - 1] = (Expression)
FixBranchingExpression(expressionList[expressionList.Count - 1], methodContext.ControlFlowGraph.InstructionToBlockMapping[key].Last);
}
//if (lastInstructionCode == Code.Switch)
//{
// //the type of this expression is needed if the switch instruction causes IrregularSwitchLC
// //so that correct expressions can be produced for case's conditions
// //Expression lastExpression = expressionList[expressionList.Count - 1];
//}
}
return body;
}
示例4: Process
public BlockStatement Process(DecompilationContext context, BlockStatement body)
{
MethodDefinition method = context.MethodContext.Method;
if (method.Name == "Finalize" && method.IsVirtual)
{
if (body.Statements.Count == 1 && body.Statements[0] is TryStatement)
{
TryStatement tryFinally = body.Statements[0] as TryStatement;
if (tryFinally.Finally != null && tryFinally.Finally.Body.Statements.Count == 1 && tryFinally.Finally.Body.Statements[0] is ExpressionStatement)
{
ExpressionStatement finallyStatementExpressionStatement = tryFinally.Finally.Body.Statements[0] as ExpressionStatement;
if (finallyStatementExpressionStatement.Expression is MethodInvocationExpression)
{
MethodDefinition baseDestructor = (finallyStatementExpressionStatement.Expression as MethodInvocationExpression).MethodExpression.MethodDefinition;
if (baseDestructor != null)
{
if (baseDestructor.Name == "Finalize" && baseDestructor.DeclaringType.FullName == method.DeclaringType.BaseType.FullName)
{
context.MethodContext.IsDestructor = true;
context.MethodContext.DestructorStatements = new BlockStatement() { Statements = tryFinally.Try.Statements };
}
}
}
}
}
}
return body;
}
示例5: ProcessBlock
void ProcessBlock (BlockStatement node)
{
for (int i = 0; i < node.Statements.Count - 1; i++)
{
ForeachArrayMatcher matcher = new ForeachArrayMatcher(node.Statements[i], node.Statements[i + 1], this.context.MethodContext);
if (!matcher.Match())
{
continue;
}
if (CheckForIndexUsages(matcher))
{
continue;
}
context.MethodContext.RemoveVariable(matcher.Incrementor);
if (matcher.CurrentVariable != null)
{
context.MethodContext.RemoveVariable(matcher.CurrentVariable);
}
node.Statements.RemoveAt(i);
node.Statements.RemoveAt(i);
node.AddStatementAt(i, matcher.Foreach);
ProcessBlock(matcher.Foreach.Body);
}
}
示例6: Process
public BlockStatement Process(DecompilationContext context, BlockStatement body)
{
this.context = context;
this.typeSystem = context.MethodContext.Method.Module.TypeSystem;
InsertTopLevelParameterAssignments(body);
return body;
}
示例7: VisitBlockStatement
public override void VisitBlockStatement (BlockStatement node)
{
ProcessBlock (node);
foreach (var statement in node.Statements)
Visit (statement);
}
示例8: ForStatement
public ForStatement(Expression initializer, Expression condition, Expression increment, BlockStatement body)
: base(condition)
{
this.Initializer = initializer;
this.Increment = increment;
this.Body = body;
}
示例9: Process
public BlockStatement Process(DecompilationContext context, BlockStatement body)
{
theRebuilder = new AnonymousDelegateRebuilder(context, body);
VisitBlockStatement(body);
theRebuilder.CleanUpVariableCopyAssignments();
return body;
}
示例10: VisitBlockStatement
public override void VisitBlockStatement(BlockStatement node)
{
for (int i = 0; i < node.Statements.Count; i++)
{
if (!Match(node.Statements, i))
continue;
// repalce try with lock
node.Statements.RemoveAt(i);
node.AddStatementAt(i, Lock);
//RemoveFlagVariable(i - 1, node, theFlagVariable);
if (this.lockType == LockType.Simple)
{
node.Statements.RemoveAt(i + 1); //the try
node.Statements.RemoveAt(--i); // the second assign
node.Statements.RemoveAt(--i); // the first assign
}
else // LockType.WithFlag
{
Lock.Body.Statements.RemoveAt(0); // the first assign
Lock.Body.Statements.RemoveAt(0); // the second assign
Lock.Body.Statements.RemoveAt(0); // the method invoke
if(i > 0)
{
node.Statements.RemoveAt(--i);
}
}
}
Visit(node.Statements);
}
示例11: Process
public BlockStatement Process(DecompilationContext context, BlockStatement block)
{
this.typeSystem = context.MethodContext.Method.Module.TypeSystem;
this.context = context;
BlockStatement newBlock = (BlockStatement)VisitBlockStatement(block);
return newBlock;
}
示例12: RunInternal
protected BlockStatement RunInternal(MethodBody body, BlockStatement block, ILanguage language)
{
try
{
if (body.Instructions.Count != 0 || body.Method.IsJustDecompileGenerated)
{
foreach (IDecompilationStep step in steps)
{
if (language != null && language.IsStopped)
{
break;
}
block = step.Process(Context, block);
}
}
}
finally
{
if (Context.MethodContext.IsMethodBodyChanged)
{
body.Method.RefreshBody();
}
}
return block;
}
示例13: FilterMethodToBeDecompiled
public FilterMethodToBeDecompiled(MethodDefinition method, CatchClause catchClause, DecompilationContext context, BlockStatement block)
{
this.Method = method;
this.CatchClause = catchClause;
this.Context = context;
this.Block = block;
}
示例14: CheckDictionaryIfBody
private bool CheckDictionaryIfBody(BlockStatement then)
{
/// Check for the pattern
/// someVariable = new Dictionary<string,int>();
/// someVariable.Add("SomeString",0);
/// <moreAdds>
/// conditionField = someField;
if (then.Statements.Count < 1)
{
return false;
}
VariableReferenceExpression localDictionaryVariable;
if (!CheckDictionaryCreation(then.Statements[0], out localDictionaryVariable ))
{
return false;
}
if (localDictionaryVariable == null)
{
// sanity check.
return false;
}
for (int i = 1; i < then.Statements.Count - 1; i++)
{
// check push expressions
if (!CheckDictionaryAdd(then.Statements[i], localDictionaryVariable))
{
return false;
}
}
return CheckDictionaryFieldAssignExpression(then.Statements[then.Statements.Count - 1], localDictionaryVariable);
}
示例15: Process
public BlockStatement Process(DecompilationContext context, BlockStatement body)
{
this.typeSystem = context.MethodContext.Method.Module.TypeSystem;
this.decompiledMethodReturnType = context.MethodContext.Method.ReturnType;
Visit(body);
return body;
}