MCPcopy Create free account
hub / github.com/SeaOfNodes/Simple / setDef

Method setDef

chapter09/src/main/java/com/seaofnodes/simple/node/Node.java:186–202  ·  view source on GitHub ↗

Change a def into a Node. Keeps the edges correct, by removing the corresponding use->def edge. This may make the original def go dead. This function is co-recursive with #kill. This method is the normal path for altering a Node, because it does the proper d

(int idx, Node new_def )

Source from the content-addressed store, hash-verified

184 Node old_def = _inputs.removeLast();
185 if( old_def != null && // If it exists and
186 old_def.delUse(this) ) // If we removed the last use, the old def is now dead
187 old_def.kill(); // Kill old def
188 }
189 }
190
191 /**
192 * Kill a Node with no <em>uses</em>, by setting all of its <em>defs</em>
193 * to null. This may recursively kill more Nodes, and is basically dead
194 * code elimination.
195 */
196 public void kill( ) {
197 unlock();
198 assert isUnused(); // Has no uses, so it is dead
199 _type=null; // Flag as dead
200 while( nIns()>0 ) { // Set all inputs to null, recursively killing unused Nodes
201 Node old_def = _inputs.removeLast();
202 if( old_def != null ) {
203 IterPeeps.add(old_def);// Revisit neighbor because removed use
204 if( old_def.delUse(this) ) // If we removed the last use, the old def is now dead
205 old_def.kill(); // Kill old def

Callers 8

parseAdditionMethod · 0.95
endLoopMethod · 0.95
parseComparisonMethod · 0.45
parseMultiplicationMethod · 0.45
updateMethod · 0.45
ctrlMethod · 0.45
mergeScopesMethod · 0.45
idealizeMethod · 0.45

Calls 6

unlockMethod · 0.95
inMethod · 0.95
delUseMethod · 0.95
killMethod · 0.95
addUseMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected