Inheritance: Replacer
Example #1
0
        /// <summary>
        /// Within "node", replace occurrences of identifiers matching oldName (by
        /// value) with the given newNode. newNode must be an expression.
        /// </summary>
        /// <param name="node"></param>
        /// <param name="oldName"></param>
        /// <param name="newNode"></param>
        public static void ZReplace(Node node, Identifier oldName, Node newNode)
        {
            if (!(newNode is Expression))
                throw new ArgumentException("ZReplace: newNode must be an Expression");

            ZReplacer replacer = new ZReplacer(oldName, newNode);
            replacer.Visit(node);
        }
Example #2
0
 /// <summary>
 /// Within "node", find a labeled statement whose label matches the given
 /// string, and replace it with the supplied statement block.
 /// </summary>
 /// <param name="node"></param>
 /// <param name="labelName"></param>
 /// <param name="block"></param>
 public static void ZReplace(Node node, string labelName, Block block)
 {
     Replacer replacer = new ZReplacer(Identifier.For(labelName), block);
     replacer.Visit(node);
 }