/// <summary>
        /// Constructs a control flow graph and a data flow graph from a CIL method body.
        /// </summary>
        /// <param name="self">The method body.</param>
        /// <param name="dataFlowGraph">The constructed data flow graph.</param>
        /// <returns>The control flow graph.</returns>
        public static ControlFlowGraph <CilInstruction> ConstructSymbolicFlowGraph(
            this CilMethodBody self,
            out DataFlowGraph <CilInstruction> dataFlowGraph)
        {
            var architecture = new CilArchitecture(self);
            var dfgBuilder   = new CilStateTransitionResolver(architecture);
            var cfgBuilder   = new SymbolicFlowGraphBuilder <CilInstruction>(
                architecture,
                self.Instructions,
                dfgBuilder);

            var ehRanges = self.ExceptionHandlers
                           .ToEchoRanges()
                           .ToArray();

            var cfg = cfgBuilder.ConstructFlowGraph(0, ehRanges);

            if (ehRanges.Length > 0)
            {
                cfg.DetectExceptionHandlerRegions(ehRanges);
            }

            dataFlowGraph = dfgBuilder.DataFlowGraph;
            return(cfg);
        }
        /// <summary>
        /// Constructs a control flow graph from a CIL method body.
        /// </summary>
        /// <param name="self">The method body.</param>
        /// <returns>The control flow graph.</returns>
        public static ControlFlowGraph <CilInstruction> ConstructStaticFlowGraph(this CilMethodBody self)
        {
            var architecture = new CilArchitecture(self);
            var cfgBuilder   = new StaticFlowGraphBuilder <CilInstruction>(
                architecture,
                self.Instructions,
                architecture.SuccessorResolver);

            var ehRanges = self.ExceptionHandlers
                           .ToEchoRanges()
                           .ToArray();

            var cfg = cfgBuilder.ConstructFlowGraph(0, ehRanges);

            if (ehRanges.Length > 0)
            {
                cfg.DetectExceptionHandlerRegions(ehRanges);
            }
            return(cfg);
        }
Exemple #3
0
 /// <summary>
 /// Creates a new instance of the <see cref="CilStateTransitionResolver"/> class.
 /// </summary>
 /// <param name="architecture">The CIL architecture variant to compute state transitions for.</param>
 public CilStateTransitionResolver(CilArchitecture architecture)
     : base(architecture)
 {
     _architecture = architecture;
 }