public ActionFlowGraph (ControlFlowGraph cfg, Collection<ActionBlock> blocks)
		{
			if (null == cfg) throw new ArgumentNullException ("cfg");
			if (null == blocks) throw new ArgumentNullException ("blocks");

			_cfg = cfg;
			_blocks = blocks;
		}
		internal ActionFlowGraphBuilder (ControlFlowGraph cfg)
		{
			_method = cfg.MethodBody.Method;

			_cfg = cfg;
			_expressionDecompiler = new ExpressionDecompiler (_method);

			_graph = new ActionFlowGraph (_cfg, _blocks);
		}
Пример #3
0
        public static void FormatControlFlowGraph(TextWriter writer, ControlFlowGraph cfg)
        {
            int id = 1;
            foreach (InstructionBlock block in cfg.Blocks) {
                writer.WriteLine ("block {0}:", id);
                writer.WriteLine ("\tbody:");
                foreach (Instruction instruction in block) {
                    writer.Write ("\t\t");
                    Formatter.WriteInstruction (writer, instruction);
                    writer.WriteLine ();
                }
                InstructionBlock [] successors = block.Successors;
                if (successors.Length > 0) {
                    writer.WriteLine ("\tsuccessors:");
                    foreach (InstructionBlock successor in successors) {
                        writer.WriteLine ("\t\tblock {0}", GetBlockId (cfg, successor));
                    }
                }

                ++id;
            }
        }
Пример #4
0
 private static int GetBlockId(ControlFlowGraph cfg, InstructionBlock block)
 {
     return ((IList) cfg.Blocks).IndexOf (block) + 1;
 }
		public static ActionFlowGraph CreateActionFlowGraph (ControlFlowGraph cfg)
		{
			if (null == cfg) throw new ArgumentNullException ("cfg");
			ActionFlowGraphBuilder builder = new ActionFlowGraphBuilder (cfg);
			return builder.BuildGraph ();
		}
		public static string ToString (ControlFlowGraph cfg)
		{
			StringWriter writer = new StringWriter ();
			FormatControlFlowGraph (writer, cfg);
			return writer.ToString ();
		}