// Puts contents of a #splice into NodeQueue and returns the first item of the splice. public LNode EnqueueSplice(VList <LNode> spliced, int maxExpansionsInner, int maxExpansions) { //Debug.Assert(!IsTarget); should be true except that IsTarget may not have been set yet MaybeCreateNodeQueue(maxExpansions, ref NodeQueue); // Enqueue spliced items foreach (var item in spliced.ToFVList()) { NodeQueue.PushFirst(Pair.Create(item, maxExpansionsInner)); } return(NodeQueue.PopFirst().A); }
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); }