public override IEnumerable<Expression> Generate(Compilation.AstGenerator gen) { var test = gen.Bool(condition.GenerateRead(gen)); var ifb = Utils.If(test, ifTrue.Generate(gen).ToArray()); if (ifFalse != null) yield return ifb.Else(ifFalse.Generate(gen).ToArray()); else yield return ifb.ToStatement(); }
public override IEnumerable<Expression> Generate(Compilation.AstGenerator gen) { return gen.Loop( scope.Variables, () => initializer == null ? new Expression[0] : initializer.Generate(gen), () => condition == null ? Utils.Constant(true) : gen.Bool(condition.GenerateRead(gen)), () => incrementer == null ? null : new[] { incrementer.GenerateRead(gen) }, () => body == null ? null : body.Generate(gen) ); }