System.Linq.Expressions.Expression.Goto C# (CSharp) Method

Goto() public static method

Creates a GotoExpression representing a goto.
public static Goto ( LabelTarget target ) : GotoExpression
target LabelTarget The that the will jump to.
return GotoExpression
        public static GotoExpression Goto(LabelTarget target)
        {
            return MakeGoto(GotoExpressionKind.Goto, target, null, typeof(void));
        }

Same methods

Expression::Goto ( LabelTarget target, Expression value ) : GotoExpression
Expression::Goto ( LabelTarget target, Expression value, Type type ) : GotoExpression
Expression::Goto ( LabelTarget target, Type type ) : GotoExpression

Usage Example

Ejemplo n.º 1
0
        protected override object VisitFor(For F)
        {
            target.PushScope();

            // Generate the loop header code.
            Visit(F.Init);

            string name = target.LabelName();

            LinqExprs.LabelTarget begin = LinqExpr.Label("for_" + name + "_begin");
            LinqExprs.LabelTarget end   = LinqExpr.Label("for_" + name + "_end");
            loops.Push(new Loop(LinqExpr.Goto(end), LinqExpr.Goto(begin)));

            // Check the condition, exit if necessary.
            target.Add(LinqExpr.Label(begin));
            target.Add(LinqExpr.IfThen(LinqExpr.Not(target.Compile(F.Condition)), LinqExpr.Goto(end)));

            // Generate the body code.
            Visit(F.Body);

            // Generate the step code.
            Visit(F.Step);
            target.Add(LinqExpr.Goto(begin));

            // Exit point.
            target.Add(LinqExpr.Label(end));

            loops.Pop();
            target.PopScope();

            return(null);
        }
All Usage Examples Of System.Linq.Expressions.Expression::Goto
Expression