public override Value Next() { using var popper = new RegionPopper(region, "for-generator"); popper.Push(); if (blockGenerating) { parameters.SetValues(sourceValue, index); var value = blockGenerator.Next(); if (!value.IsNil) { index++; return(value); } blockGenerating = false; } sourceValue = sourceGenerator.Next(); if (sourceValue.IsNil) { return(sourceValue); } blockGenerator.Reset(); index++; blockGenerating = true; return(Values.Ignore.IgnoreValue); }
public override Value Next() { using var outerPopper = new ObjectRegionPopper(objectRegion, "object-region"); outerPopper.Push(); using var innerPopper = new SharedRegionPopper(region, sharedRegion, "lambda-generator"); innerPopper.Push(); var next = block.Next(); more = !next.IsNil; return(next); }
protected IMaybe <Value> evaluateGenerator(INSGenerator generator, int i) { _currentGenerator = generator.Some(); generator.Region = Region; generator.Reset(); var returnValue = generator.Next(); if (returnValue.IsNil) { _currentGenerator = none <INSGenerator>(); return(none <Value>()); } index = i + 1; return(block.evaluateReturn(returnValue).Some()); }
public override Value Next() { using var popper = new RegionPopper(region, "while-generator"); popper.Push(); if (index++ < MAX_LOOP && (!checkPredicate || predicate())) { var next = blockGenerator.Next(); checkPredicate = false; if (next.IsNil) { next = IgnoreValue; Reset(); } return(next); } return(NilValue); }