private async Task <MethodBody> OptimizeBodyAsync( IMethod requestedDef, MethodBodyHolder requestedHolder) { // Get the method's initial body. var body = requestedHolder.Body; // Create optimization state. var state = new OptimizationState(requestedDef, this); // Apply passes from the pipeline until we're done. foreach (var pass in pipeline) { body = await pass.ApplyAsync(body, state); if (pass.IsCheckpoint) { // Update the method body for the method if we've // reached a checkpoint. requestedHolder.Body = body; } } requestedHolder.Body = body; return(body); }
/// <summary> /// Applies the optimization to a method body. /// </summary> /// <param name="body">A method body holder to optimize.</param> /// <param name="state">State associated with optimizations.</param> /// <returns>A task that produces an optimized method body.</returns> public abstract Task <MethodBody> ApplyAsync( MethodBody body, OptimizationState state);