replace

Tries to replace the old expression with a new one, given the parent.

There are three things to consider:

  • First, this only works if parent is either an ArgumentHolder or StatementHolder. Otherwise, we cannot instruct the parent to exchange the node

  • Second, since exchanging the node has influence on their edges (such as EOG, DFG, etc.), we only support a replacement very early in the pass system. To be specific, we only allow replacement before any DFG edges are set. We are re-wiring EOG edges, but nothing else. If one tries to replace a node with existing Node.nextDFG or Node.prevDFG, we fail.

  • We also migrate HasType.typeObservers from the old to the new node.