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

Method setDef

chapter03/src/main/java/com/seaofnodes/simple/node/Node.java:146–161  ·  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

144 void popN(int n) {
145 for( int i=0; i<n; i++ ) {
146 Node old_def = _inputs.removeLast();
147 if( old_def != null && // If it exists and
148 old_def.delUse(this) ) // If we removed the last use, the old def is now dead
149 old_def.kill(); // Kill old def
150 }
151 }
152
153 /**
154 * Kill a Node with no <em>uses</em>, by setting all of its <em>defs</em>
155 * to null. This may recursively kill more Nodes and is basically dead
156 * code elimination. This function is co-recursive with {@link #popN}.
157 */
158 public void kill( ) {
159 assert isUnused(); // Has no uses, so it is dead
160 popN(nIns()); // Set all inputs to null, recursively killing unused Nodes
161 _type=null; // Flag as dead
162 assert isDead(); // Really dead now
163 }
164

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