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

Method setDef

chapter04/src/main/java/com/seaofnodes/simple/node/Node.java:137–152  ·  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

135 protected boolean delUse( Node use ) {
136 Utils.del(_outputs, Utils.find(_outputs, use));
137 return _outputs.isEmpty();
138 }
139
140 // Shortcut for "popping" n nodes. A "pop" is basically a
141 // setDef(last,null) followed by lowering the nIns() count.
142 void popN(int n) {
143 for( int i=0; i<n; i++ ) {
144 Node old_def = _inputs.removeLast();
145 if( old_def != null && // If it exists and
146 old_def.delUse(this) ) // If we removed the last use, the old def is now dead
147 old_def.kill(); // Kill old def
148 }
149 }
150
151 /**
152 * Kill a Node with no <em>uses</em>, by setting all of its <em>defs</em>
153 * to null. This may recursively kill more Nodes and is basically dead
154 * code elimination. This function is co-recursive with {@link #popN}.
155 */

Callers 2

updateMethod · 0.45
ctrlMethod · 0.45

Calls 5

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

Tested by

no test coverage detected