internal ActionFlowGraphBuilder (ControlFlowGraph cfg)
		{
			_method = cfg.MethodBody.Method;

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

			_graph = new ActionFlowGraph (_cfg, _blocks);
		}
Example #2
0
        internal ActionFlowGraphBuilder(ControlFlowGraph cfg)
        {
            _method = cfg.MethodBody.Method;

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

            _graph = new ActionFlowGraph(_cfg, _blocks);
        }
Example #3
0
		private static ActionBlock GetFirstBlock(ActionFlowGraph graph)
		{
			if (graph.Blocks.Count < 1) return null;
			return graph.Blocks[0];
		}
Example #4
0
		public static Expression FindIn(ActionFlowGraph graph)
		{
			var finder = new QueryExpressionFinder(graph);
			return finder.QueryExpression;
		}
Example #5
0
		private QueryExpressionFinder(ActionFlowGraph graph)
		{
			_graph = graph;
			_variables = new Dictionary<int, Expression>();
			FindQueryExpression();
		}
		private CecilMethodAnalyser(ActionFlowGraph graph)
		{
			if (graph == null) throw new ArgumentNullException("graph");

			_queryExpression = QueryExpressionFinder.FindIn(graph);
		}
		public static string ToString (ActionFlowGraph afg)
		{
			StringWriter writer = new StringWriter ();
			new ActionFlowGraphPrinter (writer).Print (afg);
			return writer.ToString ();
		}
			void WriteGoto (ActionFlowGraph afg, ActionBlock target)
			{
				_writer.Write ("goto block{0}", afg.Blocks.IndexOf (target) + 1);
			}
			void WriteBranch (ActionFlowGraph afg,  BranchActionBlock block)
			{
				WriteGoto (afg, block.Target);
			}
			void WriteConditionalBranch (ActionFlowGraph afg,  ConditionalBranchActionBlock block)
			{
				_writer.Write ("if ");
				WriteExpression (block.Condition);
				_writer.Write (' ');
				WriteGoto (afg, block.Then);
			}
			public void Print (ActionFlowGraph afg)
			{
				int i = 1;
				foreach (ActionBlock block in afg.Blocks) {
					if (afg.IsBranchTarget (block)) {
						WriteLabel (i);
					}
					switch (block.ActionType) {
					case ActionType.Return:
						WriteReturn ((ReturnActionBlock) block);
						break;

					case ActionType.Branch:
						WriteBranch (afg, (BranchActionBlock) block);
						break;

					case ActionType.ConditionalBranch:
						WriteConditionalBranch (afg, (ConditionalBranchActionBlock) block);
						break;

					case ActionType.Assign:
						WriteAssign ((AssignActionBlock) block);
						break;

					case ActionType.Invoke:
						WriteInvoke ((InvokeActionBlock) block);
						break;

					default:
						throw new InvalidOperationException ();
					}
					_writer.WriteLine ();
					++i;
				}
			}