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

Method cloneOnly

src/main/java/wycc/util/AbstractHeap.java:353–380  ·  view source on GitHub ↗
(T item, Map<Item, Item> mapping, Class<?> clazz)

Source from the content-addressed store, hash-verified

351 }
352
353 public static <T extends Item> T cloneOnly(T item, Map<Item, Item> mapping, Class<?> clazz) {
354 Item clonedItem = mapping.get(item);
355 if (clonedItem == null) {
356 // Item not previously cloned. Therefore, first create new item
357 Item[] operands = item.getAll();
358 Item[] nOperands = operands;
359 if (operands != null) {
360 for (int i = 0; i != operands.length; ++i) {
361 Item operand = operands[i];
362 if (operand != null) {
363 Item nOperand = cloneOnly(operand, mapping,clazz);
364 if(nOperand != operand && operands == nOperands) {
365 nOperands = Arrays.copyOf(operands, operands.length);
366 }
367 nOperands[i] = nOperand;
368 }
369 }
370 }
371 // Now, create new item and store that for later.
372 if(nOperands != operands || clazz.isInstance(item)) {
373 clonedItem = item.clone(nOperands);
374 mapping.put(item, clonedItem);
375 } else {
376 clonedItem = item;
377 }
378 }
379 return (T) clonedItem;
380 }
381
382 /**
383 * <p>

Callers

nothing calls this directly

Calls 3

getMethod · 0.65
getAllMethod · 0.65
cloneMethod · 0.65

Tested by

no test coverage detected