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

Method setDef

chapter06/src/main/java/com/seaofnodes/simple/node/Node.java:147–162  ·  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

145 // If new def is not null, add the corresponding def->use edge
146 if( new_def != null )
147 new_def.addUse(this);
148 return new_def;
149 }
150
151 // Breaks the edge invariants, used temporarily
152 protected <N extends Node> void addUse(N n) { _outputs.add(n); }
153
154 // Remove node 'use' from 'def's (i.e. our) output list, by compressing the list in-place.
155 // Return true if the output list is empty afterward.
156 // Error is 'use' does not exist; ok for 'use' to be null.
157 protected boolean delUse( Node use ) {
158 Utils.del(_outputs, Utils.find(_outputs, use));
159 return _outputs.isEmpty();
160 }
161
162 // Shortcut for "popping" n nodes. A "pop" is basically a
163 // setDef(last,null) followed by lowering the nIns() count.
164 void popN(int n) {
165 for( int i=0; i<n; i++ ) {

Callers 3

updateMethod · 0.45
ctrlMethod · 0.45
mergeScopesMethod · 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