protected override void DoEmit() { if (this.YieldReturnStatement != null) { this.Write("$yield.push"); this.WriteOpenParentheses(); this.YieldReturnStatement.Expression.AcceptVisitor(this.Emitter); this.WriteCloseParentheses(); this.WriteSemiColon(); this.WriteNewLine(); } else { if (this.YieldBreakStatement.GetParent <ForStatement>() == null && this.YieldBreakStatement.GetParent <ForeachStatement>() == null && this.YieldBreakStatement.GetParent <WhileStatement>() == null && this.YieldBreakStatement.GetParent <DoWhileStatement>() == null) { YieldBlock.EmitYieldReturn(this, this.Emitter.ReturnType); } else { new BreakBlock(this.Emitter, this.YieldBreakStatement).Emit(); } } }
public void EndEmitBlock() { var blockWasEnded = false; if (this.IsYield) { YieldBlock.EmitYieldReturn(this, this.ReturnType); } if (this.IsMethodBlock) { this.Emitter.ReturnType = this.OldReturnType; } if (!this.NoBraces && (!this.Emitter.IsAsync || (!this.AsyncNoBraces && this.BlockStatement.Parent != this.Emitter.AsyncBlock.Node))) { this.EndBlock(); blockWasEnded = true; } if (this.AddEndBlock) { this.WriteNewLine(); this.EndBlock(); blockWasEnded = true; } if (blockWasEnded && this.WrapByFn.HasValue && this.WrapByFn.Value) { this.Outdent(); this.Write(").call(this);"); } if (!this.KeepLineAfterBlock(this.BlockStatement)) { this.WriteNewLine(); } if (this.IsMethodBlock && !this.Emitter.IsAsync) { this.EmitTempVars(this.BeginPosition); } this.PopLocals(); }
public void EndEmitBlock() { if (this.IsYield) { YieldBlock.EmitYieldReturn(this, this.ReturnType); } if (this.IsMethodBlock) { this.Emitter.ReturnType = this.OldReturnType; } if (!this.NoBraces && (!this.Emitter.IsAsync || (!this.AsyncNoBraces && this.BlockStatement.Parent != this.Emitter.AsyncBlock.Node))) { this.EndBlock(); } if (this.AddEndBlock) { this.WriteNewLine(); this.EndBlock(); } if (this.WrapByFn.HasValue && this.WrapByFn.Value) { var isBlock = (this.HandleContinue.HasValue && this.HandleContinue.Value) || (this.HandleBreak.HasValue && this.HandleBreak.Value) || (this.HandleReturn.HasValue && this.HandleReturn.Value); if (this.NoBraces) { this.Outdent(); } if (this.NoBraces) { this.Write("}"); } this.Write(")"); this.WriteCall("this"); if (isBlock) { this.Write(" || {}"); } this.Write(";"); if (this.HandleContinue.HasValue && this.HandleContinue.Value) { this.WriteNewLine(); this.Write("if(" + this.LoopVar + ".jump == 1) continue;"); } if (this.HandleBreak.HasValue && this.HandleBreak.Value) { this.WriteNewLine(); this.Write("if(" + this.LoopVar + ".jump == 2) break;"); } if (this.HandleReturn.HasValue && this.HandleReturn.Value) { this.WriteNewLine(); this.Write("if(" + this.LoopVar + ".jump == 3) return "); if (this.OldReplaceJump.HasValue && this.OldReplaceJump.Value && this.Emitter.JumpStatements == null) { this.Write("{jump: 3, v: " + this.LoopVar + ".v};"); } else { this.Write(this.LoopVar + ".v;"); } } if (!this.NoBraces) { this.WriteNewLine(); this.EndBlock(); } if (isBlock) { this.RemoveTempVar(this.LoopVar); } } if (this.OldReplaceJump.HasValue) { this.Emitter.ReplaceJump = this.OldReplaceJump.Value; } if (!this.KeepLineAfterBlock(this.BlockStatement)) { this.WriteNewLine(); } if (this.IsMethodBlock && !this.Emitter.IsAsync) { this.EmitTempVars(this.BeginPosition); } this.PopLocals(); }
public void EndEmitBlock() { var blockWasEnded = false; if (this.IsYield) { YieldBlock.EmitYieldReturn(this, this.ReturnType); } if (this.IsMethodBlock) { this.Emitter.ReturnType = this.OldReturnType; } if (!this.NoBraces && (!this.Emitter.IsAsync || (!this.AsyncNoBraces && this.BlockStatement.Parent != this.Emitter.AsyncBlock.Node))) { this.EndBlock(); blockWasEnded = true; } if (this.AddEndBlock) { this.WriteNewLine(); this.EndBlock(); blockWasEnded = true; } if (blockWasEnded && this.WrapByFn.HasValue && this.WrapByFn.Value) { var isBlock = (this.HandleContinue.HasValue && this.HandleContinue.Value) || (this.HandleBreak.HasValue && this.HandleBreak.Value); if (!isBlock) { this.Outdent(); } this.Write(").call(this);"); if (this.HandleContinue.HasValue && this.HandleContinue.Value) { this.WriteNewLine(); this.Write("if(" + this.LoopVar + " == 1) continue;"); } if (this.HandleBreak.HasValue && this.HandleBreak.Value) { this.WriteNewLine(); this.Write("if(" + this.LoopVar + " == 2) break;"); } if (isBlock) { this.WriteNewLine(); this.EndBlock(); this.RemoveTempVar(this.LoopVar); } this.Emitter.ReplaceJump = this.OldReplaceJump; } if (!this.KeepLineAfterBlock(this.BlockStatement)) { this.WriteNewLine(); } if (this.IsMethodBlock && !this.Emitter.IsAsync) { this.EmitTempVars(this.BeginPosition); } this.PopLocals(); }