void SyntaxTree :: copyNode(SyntaxTree::Writer& writer, SyntaxTree::Node node) { SNode current = node.firstChild(); while (current != lxNone) { if (current.strArgument >= 0) { writer.newNode(current.type, current.identifier()); } else writer.newNode(current.type, current.argument); copyNode(writer, current); writer.closeNode(); current = current.nextNode(); } }
void SyntaxTree :: copyNode(SyntaxTree::Node source, SyntaxTree::Node destination) { SNode current = source.firstChild(); while (current != lxNone) { if (current.strArgument >= 0) { if (source.tree == destination.tree) { // HOTFIX : literal argument could be corrupted by reallocating the string buffer, // so the special routine should be used copyNode(current, destination.appendStrNode(current.type, current.strArgument)); } else copyNode(current, destination.appendNode(current.type, current.identifier())); } else copyNode(current, destination.appendNode(current.type, current.argument)); current = current.nextNode(); } }
void SyntaxTree :: moveNodes(Writer& writer, SyntaxTree& buffer) { SNode current = buffer.readRoot(); while (current != lxNone) { if (current != lxIdle) { if (current.strArgument >= 0) { writer.newNode(current.type, current.identifier()); } else writer.newNode(current.type, current.argument); SyntaxTree::copyNode(writer, current); writer.closeNode(); current = lxIdle; } current = current.nextNode(); } }