public static ILMethodAst Build(MethodDefinition methodDef, bool optimize)
        {
            if (methodDef.Body.Instructions.Count == 0)
            {
                return(ILMethodAst.Empty);
            }
            else
            {
                var             ilastBuilder = new ILMethodAstBuilder(methodDef, optimize);
                List <ByteCode> body         = ilastBuilder.StackAnalysis(methodDef);
                List <ILNode>   ast          = ilastBuilder.ConvertToAst(body, new HashSet <ExceptionHandler>(methodDef.Body.ExceptionHandlers));

                return(new ILMethodAst(ilastBuilder.parameterList, ast));
            }
        }
        /// <summary>
        /// Creates ILAst for the specified method, optimized up to before the 'YieldReturn' step.
        /// </summary>
        ILBlock CreateILAst(MethodDefinition method)
        {
            if (method == null || !method.HasBody)
            {
                throw new YieldAnalysisFailedException();
            }

            ILBlock ilMethod   = new ILBlock();
            var     astBuilder = ILMethodAstBuilder.Build(method, true);

            ilMethod.Body = astBuilder.Nodes.ToList();
            ILAstOptimizer optimizer = new ILAstOptimizer();

            optimizer.Optimize(context, ilMethod, ILAstOptimizationStep.YieldReturn);
            return(ilMethod);
        }
		public static ILMethodAst Build(MethodDefinition methodDef, bool optimize)
		{
            if (methodDef.Body.Instructions.Count == 0)
            {
                return ILMethodAst.Empty;
            }
            else
            {
                var ilastBuilder = new ILMethodAstBuilder(methodDef, optimize);
                List<ByteCode> body = ilastBuilder.StackAnalysis(methodDef);
                List<ILNode> ast = ilastBuilder.ConvertToAst(body, new HashSet<ExceptionHandler>(methodDef.Body.ExceptionHandlers));

                return new ILMethodAst(ilastBuilder.parameterList, ast);
            }
        }