Beispiel #1
0
        public static void Rewrite(RewriteDesign design, RewrittenValueBridge[] args)
        {
            if (design.Iterators.Count > 1)
            {
                design.ListEnumeration = false;
            }

            var takeValue = args[0];

            CheckBounds(design, ref takeValue);
            LocalVariable takeIndexer = CreateGlobalVariable(design, Int, 0);

            if (!design.ModifiedEnumeration)
            {
                design.CurrentIterator.ForTo = design.CurrentIterator.ForFrom + design.CurrentIterator.ForInc * takeValue - design.CurrentIterator.ForInc;
                design.CurrentIterator.ForTo = design.CurrentIterator.ForTo;
            }
            else
            {
                design.ForAdd(If(takeIndexer.PostIncrement() >= takeValue, Break()));
            }

            if (design.ResultSize != null)
            {
                design.ResultSize = takeValue;
            }
            else
            {
                design.SourceSize = takeValue;
            }
            design.Indexer = null;
        }