public static ControlFlowGraph Create(MethodDefinition method) { if (method == null) { throw new ArgumentNullException("method"); } if (!method.HasBody) { throw new ArgumentException(); } ControlFlowGraphBuilder builder = new ControlFlowGraphBuilder(method); return builder.CreateGraph(); }
public static ControlFlowGraph Create(MethodDefinition method) { if (method == null) { throw new ArgumentNullException("method"); } if (!method.HasBody) { throw new ArgumentException(); } ControlFlowGraphBuilder builder = new ControlFlowGraphBuilder(method); return(builder.CreateGraph()); }
private BlockStatement GetStatements(MethodBody body) { //Performance improvement ControlFlowGraph cfg = new ControlFlowGraphBuilder(body.Method).CreateGraph(); if (cfg.Blocks.Length > 2) { return null; } DecompilationPipeline pipeline = new DecompilationPipeline(BaseLanguage.IntermediateRepresenationPipeline.Steps, new DecompilationContext(new MethodSpecificContext(body) { EnableEventAnalysis = false }, new TypeSpecificContext(body.Method.DeclaringType))) ; pipeline.Run(body); return pipeline.Body; }
private BlockStatement DecompileMethodPartially(MethodBody body, out DecompilationContext context, bool needDecompiledMember = false) { context = null; if (this.IsCachingEnabled && this.cacheService.IsDecompiledMemberInCache(body.Method, this.language, this.renameInvalidMembers)) { CachedDecompiledMember cachedDecompiledMember = this.cacheService.GetDecompiledMemberFromCache(body.Method, this.language, this.renameInvalidMembers); return cachedDecompiledMember.Member.Statement as BlockStatement; } //Performance improvement ControlFlowGraph cfg = new ControlFlowGraphBuilder(body.Method).CreateGraph(); if (cfg.Blocks.Length > 2) { return null; } BlockStatement block; try { DecompilationPipeline pipeline; DecompilationContext decompilationContext = new DecompilationContext(new MethodSpecificContext(body), this.typeContext ?? new TypeSpecificContext(body.Method.DeclaringType), this.language); if (!needDecompiledMember) { decompilationContext.MethodContext.EnableEventAnalysis = false; } pipeline = new DecompilationPipeline(BaseLanguage.IntermediateRepresenationPipeline.Steps, decompilationContext); context = pipeline.Run(body, this.language); block = pipeline.Body; } catch (Exception ex) { this.ExceptionsWhileDecompiling.Add(body.Method); block = new BlockStatement(); block.AddStatement(new ExceptionStatement(ex, body.Method)); OnExceptionThrown(ex); } return block; }