Exemple #1
0
        VList <LNode> ApplyMacrosToList(VList <LNode> list, int maxExpansions, bool areAttributes)
        {
            VList <LNode> results = list;
            LNode         result = null;
            int           i, count;
            bool          dropRemaining = false;

            // Share as much of the original VList as is left unchanged
            for (i = 0, count = list.Count; i < count; i++)
            {
                Debug.Assert(!dropRemaining);
                _s.StartListItem(list, i, areAttributes);
                LNode input = list[i];
                result = ApplyMacros(input, maxExpansions, false, out dropRemaining);
                if (result != null || (result = input).Calls(S.Splice))
                {
                    results = list.First(i);
                    Add(ref results, result);
                    break;
                }
            }
            // Prepare a modified list from now on
            for (i++; i < count && !dropRemaining; i++)
            {
                _s.StartListItem(list, i, areAttributes);
                LNode input = list[i];
                result = ApplyMacros(input, maxExpansions, false, out dropRemaining);
                Add(ref results, result ?? input);
            }
            _s.IsAttribute = false;
            return(results);
        }
Exemple #2
0
 public bool DropRemainingNodesRequested;             // Any macro can set this flag
 public void DropRemainingNodes()
 {
     if (DropRemainingNodesRequested && !IsTarget)
     {
         OldAndRemainingNodes = OldAndRemainingNodes.First(CurrentNodeIndex + 1);
         _remainingNodes      = null;
     }
 }
        VList <LNode> ApplyMacrosToList(VList <LNode> list, int maxExpansions, bool areAttributes)
        {
            DList <Pair <LNode, int> > nodeQueue = null;
            VList <LNode> results;
            LNode         result = null;

            // Share as much of the original VList as is left unchanged
            for (int i = 0, count = list.Count;; ++i)
            {
                if (i >= count)
                {
                    return(list);                    // Entire list did not change
                }
                _s.StartListItem(list, i, areAttributes);
                LNode input = list[i];
                result = ApplyMacros(input, maxExpansions, false, false, ref nodeQueue);
                if (result != null)
                {
                    results = list.First(i);
                    Add(ref results, result);
                    // restore possibly-clobbered state
                    _s.StartListItem(list, i, areAttributes);
                    _s.MaybeCreateNodeQueue(maxExpansions, ref nodeQueue);
                    break;
                }
            }

            // The rest of the list is in _s.NodeQueue. Process that.
            while (!nodeQueue.IsEmpty)
            {
                _s.StartListItem(LNode.List(), 0, areAttributes);
                Pair <LNode, int> input2 = nodeQueue.PopFirst();
                result = ApplyMacros(input2.A, input2.B, false, false, ref nodeQueue);
                Add(ref results, result ?? input2.A);
            }
            _s.NodeQueue = null;
            return(results);
        }