/// <summary> /// Creates a <see cref="LoopExpression"/> with the given body. /// </summary> /// <param name="body">The body of the loop.</param> /// <param name="break">The break target used by the loop body.</param> /// <param name="continue">The continue target used by the loop body.</param> /// <returns>The created <see cref="LoopExpression"/>.</returns> public static LoopExpression Loop(Expression body, LabelTarget @break, LabelTarget @continue) { RequiresCanRead(body, nameof(body)); if (@continue != null && @continue.Type != typeof(void)) { throw Error.LabelTypeMustBeVoid(); } return(new LoopExpression(body, @break, @continue)); }
public static GotoLabelCSharpStatement GotoLabel(LabelTarget target) { RequiresNotNull(target, nameof(target)); if (target.Type != typeof(void)) { throw LinqError.LabelTypeMustBeVoid(); } return(new GotoLabelCSharpStatement(target)); }
internal static void ValidateLoop(Expression body, LabelTarget @break, LabelTarget @continue) { if (@break != null && @break.Type != typeof(void)) { // DESIGN: C# statement behavior; can be revisited. throw LinqError.LabelTypeMustBeVoid(); } if (@continue != null && @continue.Type != typeof(void)) { throw LinqError.LabelTypeMustBeVoid(); } if (@break != null && @continue != null && @break == @continue) { throw Error.DuplicateLabels(); } }