public static GotoExpression Goto(LabelTarget target, Expression value, Type type) { return MakeGoto(GotoExpressionKind.Goto, target, value, type); }
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); }