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

Method putUnit

src/main/java/wyil/lang/WyilFile.java:503–519  ·  view source on GitHub ↗
(Decl.Unit unit)

Source from the content-addressed store, hash-verified

501 }
502
503 public Decl.Unit putUnit(Decl.Unit unit) {
504 Tuple<Decl.Unit> units = getUnits();
505 // Check whether replacing unit or adding new
506 for (int i = 0; i != units.size(); ++i) {
507 Decl.Unit ith = units.get(i);
508 if (ith.getName().equals(unit.getName())) {
509 // We're replacing an existing unit
510 units.setOperand(i, unit);
511 //
512 return ith;
513 }
514 }
515 // We're adding a new unit
516 setOperand(1, getHeap().allocate(units.append(unit)));
517 // Nothing was replaced
518 return null;
519 }
520
521 public Decl.Unit putExtern(Decl.Unit unit) {
522 Tuple<Decl.Unit> externs = getExterns();

Callers 1

readMethod · 0.80

Calls 9

getUnitsMethod · 0.95
sizeMethod · 0.65
getMethod · 0.65
getNameMethod · 0.65
setOperandMethod · 0.65
allocateMethod · 0.65
getHeapMethod · 0.65
equalsMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected