コード例 #1
0
ファイル: IfExecute.cs プロジェクト: toddcoder/Orange2
            public override Value Next()
            {
                using var popper = new RegionPopper(region, "if-generator");
                popper.Push();

                switch (ifStage)
                {
                case IfStage.Condition:
                    if (condition.IsTrue)
                    {
                        ifStage = IfStage.Result;
                        return(resultGenerator.Next());
                    }

                    if (_elseIf.If(out var elseIf))
                    {
                        ifStage = IfStage.ElseIf;
                        return(elseIf.Next());
                    }

                    if (_elseBlockGenerator.If(out var elseBlockGenerator))
                    {
                        ifStage = IfStage.Else;
                        return(elseBlockGenerator.Next());
                    }

                    return(NilValue);

                case IfStage.Result:
                    return(resultGenerator.Next());

                case IfStage.ElseIf:
                    return(_elseIf.If(out elseIf) ? elseIf.Next() : NilValue);

                case IfStage.Else:
                    return(_elseBlockGenerator.If(out elseBlockGenerator) ? elseBlockGenerator.Next() : NilValue);

                default:
                    return(IgnoreValue);
                }
            }
コード例 #2
0
            public override Value Next()
            {
                if (current.If(out var value))
                {
                    if (index++ < MAX_LOOP && compare(value, stop) < 0)
                    {
                        var next   = successor(value);
                        var result = value;
                        current = next.Some();
                        return(result);
                    }
                }

                if (current.If(out value))
                {
                    var result = value;
                    current = none <Object>();
                    return(result);
                }

                return(NilValue);
            }
コード例 #3
0
ファイル: FlatGenerator.cs プロジェクト: toddcoder/Orange2
        public override Value Next()
        {
            if (currentIterator.If(out var iterator))
            {
                var value = iterator.Next();
                if (value.IsNil)
                {
                    currentIterator = none <NSIterator>();
                }
                else
                {
                    return(value);
                }
            }

            while (iterators.Count > 0)
            {
                currentIterator = iterators.Dequeue();
                if (currentIterator.If(out iterator))
                {
                    iterator.Reset();

                    var value = iterator.Next();
                    if (!value.IsNil)
                    {
                        return(value);
                    }
                }
                else
                {
                    return(NilValue);
                }
            }

            return(NilValue);
        }