/// <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 Replace(Node node, Identifier oldName, Node newNode) { if (!(newNode is Expression)) throw new ArgumentException("Replace: newNode must be an Expression"); Replacer replacer = new Replacer(oldName, newNode); replacer.Visit(node); }
/// <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 Replace(Node node, string labelName, Block block) { Replacer replacer = new Replacer(new Identifier(labelName), block); replacer.Visit(node); }