MCPcopy Create free account
hub / github.com/Whiley/WhileyCompiler / replaceAll

Method replaceAll

src/main/java/wycc/util/AbstractHeap.java:276–297  ·  view source on GitHub ↗
(Item item, T from, T to, BitSet visited)

Source from the content-addressed store, hash-verified

274 }
275
276 private static <T extends Item> void replaceAll(Item item, T from, T to, BitSet visited) {
277 int index = item.getIndex();
278 // Check whether already visited this item
279 if (item != from && !visited.get(index)) {
280 // Record that have now visited
281 visited.set(index);
282 // Attempt the replacement
283 Item[] children = item.getAll();
284 if(children != null) {
285 for (int i = 0; i != children.length; ++i) {
286 // Apply the replacement.
287 if (children[i] == from) {
288 // Time for replacement!
289 item.setOperand(i, to);
290 } else {
291 // Recursively traverse children.
292 replaceAll(children[i],from,to,visited);
293 }
294 }
295 }
296 }
297 }
298
299 /**
300 * Mark all reachable items from a given item, whilst ignoring references. That

Callers 1

replaceMethod · 0.95

Calls 5

getIndexMethod · 0.65
getMethod · 0.65
setMethod · 0.65
getAllMethod · 0.65
setOperandMethod · 0.65

Tested by

no test coverage detected