Ejemplo n.º 1
0
        SyntaxTreeNodeCollection GetModifiedSubNodes(SyntaxTreeNode node)
        {
            SyntaxTreeNodeCollection modifiedSubNodes = null; //lazy

            for (int i = 0; i < node.SubNodes.Count; i++)
            {
                var subNode = node.SubNodes[i];

                var replacement = Visit(subNode);
                if (replacement != subNode)
                {
                    if (modifiedSubNodes == null) //lazy init
                    {
                        modifiedSubNodes = new SyntaxTreeNodeCollection();
                        for (int j = 0; j < i; j++) //copy unmodified nodes
                        {
                            modifiedSubNodes.Add(node.SubNodes[j]);
                        }
                    }

                    if (replacement != null) //insert replacement
                    {
                        modifiedSubNodes.Add(replacement);
                    }
                }
                else
                {
                    if (modifiedSubNodes != null) //only insert unmodified subnode if the lazy collection has been initialized
                    {
                        modifiedSubNodes.Add(subNode);
                    }
                }
            }
            return(modifiedSubNodes);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Initialize an instance with the given <see cref="SyntaxTreeNodeCollection"/>.
 /// </summary>
 /// <param name="subNodes">Can not be null!</param>
 /// <exception cref="ArgumentNullException"></exception>
 public SequenceNode(SyntaxTreeNodeCollection subNodes)
     : base(subNodes)
 {
     if (subNodes == null)
     {
         throw new ArgumentNullException(nameof(subNodes));
     }
 }
Ejemplo n.º 3
0
 protected SyntaxTreeNode()
 {
     SubNodes = new SyntaxTreeNodeCollection();
 }
Ejemplo n.º 4
0
 public SequenceNode(SyntaxTreeNodeCollection subNodes) : base(subNodes)
 {
 }