protected void EmitAsyncBody() { this.BeginBlock(); var asyncTryVisitor = new AsyncTryVisitor(); this.Node.AcceptVisitor(asyncTryVisitor); var needTry = asyncTryVisitor.Found || this.IsTaskReturn; this.Emitter.AsyncVariables.Add("$jumpFromFinally"); if (needTry) { if (this.IsTaskReturn) { this.Emitter.AsyncVariables.Add("$returnTask = new Bridge.Task()"); } this.Emitter.AsyncVariables.Add("$returnValue"); this.Write("try"); this.WriteSpace(); this.BeginBlock(); } this.Write("for (;;) "); this.BeginBlock(); this.WriteIndent(); int checkerPos = this.Emitter.Output.Length; this.WriteNewLine(); this.Write("switch ($step) "); this.BeginBlock(); this.Step = 0; var writer = this.SaveWriter(); this.AddAsyncStep(); this.Body.AcceptVisitor(this.Emitter); this.RestoreWriter(writer); this.InjectSteps(); this.WriteNewLine(); this.EndBlock(); this.InjectStepsChecker(checkerPos); this.WriteNewLine(); this.EndBlock(); if (needTry) { this.WriteNewLine(); this.EndBlock(); this.Write(" catch($e1) "); this.BeginBlock(); this.Write("$e1 = Bridge.Exception.create($e1);"); this.WriteNewLine(); this.InjectCatchHandlers(); this.WriteNewLine(); this.EndBlock(); } this.WriteNewLine(); this.EndBlock(); }