示例#1
0
		public static void RunStep1(DecompilerContext context, ILBlock method, List<ILExpression> listExpr, List<ILBlock> listBlock, Dictionary<ILLabel, int> labelRefCount)
		{
			if (!context.Settings.AsyncAwait)
				return; // abort if async decompilation is disabled
			var yrd = new AsyncDecompiler();
			yrd.context = context;
			if (!yrd.MatchTaskCreationPattern(method))
				return;
			#if DEBUG
			if (Debugger.IsAttached) {
				yrd.Run();
			} else {
				#endif
				try {
					yrd.Run();
				} catch (SymbolicAnalysisFailedException) {
					return;
				}
				#if DEBUG
			}
			#endif
			context.CurrentMethodIsAsync = true;
			
			method.Body.Clear();
			method.EntryGoto = null;
			method.Body.AddRange(yrd.newTopLevelBody);//TODO: Make sure that the removed ILRanges from Clear() above is saved in the new body
			ILAstOptimizer.RemoveRedundantCode(context, method, listExpr, listBlock, labelRefCount);
		}
示例#2
0
		public static void RunStep2(DecompilerContext context, ILBlock method, List<ILExpression> listExpr, List<ILBlock> listBlock, Dictionary<ILLabel, int> labelRefCount, List<ILNode> list_ILNode, Func<ILBlock, ILInlining> getILInlining)
		{
			if (context.CurrentMethodIsAsync) {
				Step2(method.Body);
				ILAstOptimizer.RemoveRedundantCode(context, method, listExpr, listBlock, labelRefCount);
				// Repeat the inlining/copy propagation optimization because the conversion of field access
				// to local variables can open up additional inlining possibilities.
				ILInlining inlining = getILInlining(method);
				inlining.InlineAllVariables();
				inlining.CopyPropagation(list_ILNode);
			}
		}
 public static void RunStep2(DecompilerContext context, ILBlock method)
 {
     if (context.CurrentMethodIsAsync)
     {
         Step2(method.Body);
         ILAstOptimizer.RemoveRedundantCode(method);
         // Repeat the inlining/copy propagation optimization because the conversion of field access
         // to local variables can open up additional inlining possibilities.
         ILInlining inlining = new ILInlining(method);
         inlining.InlineAllVariables();
         inlining.CopyPropagation();
     }
 }
        public static void RunStep1(DecompilerContext context, ILBlock method)
        {
            if (!context.Settings.AsyncAwait)
            {
                return; // abort if async decompilation is disabled
            }
            var yrd = new AsyncDecompiler();

            yrd.context = context;
            if (!yrd.MatchTaskCreationPattern(method))
            {
                return;
            }
#if DEBUG
            if (Debugger.IsAttached)
            {
                yrd.Run();
            }
            else
            {
#endif
            try
            {
                yrd.Run();
            }
            catch (SymbolicAnalysisFailedException)
            {
                return;
            }
#if DEBUG
        }
#endif
            context.CurrentMethodIsAsync = true;

            method.Body.Clear();
            method.EntryGoto = null;
            method.Body.AddRange(yrd.newTopLevelBody);
            ILAstOptimizer.RemoveRedundantCode(method);
        }