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

Goto() public static method

Creates a GotoExpression representing a goto. The value passed to the label upon jumping can be specified.
public static Goto ( LabelTarget target, Expression value ) : GotoExpression
target LabelTarget The that the will jump to.
value Expression The value that will be passed to the associated label upon jumping.
return GotoExpression
        public static GotoExpression Goto(LabelTarget target, Expression value)
        {
            return MakeGoto(GotoExpressionKind.Goto, target, value, typeof(void));
        }

Same methods

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

Usage Example

Exemplo 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