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

Method putExtern

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

Source from the content-addressed store, hash-verified

519 }
520
521 public Decl.Unit putExtern(Decl.Unit unit) {
522 Tuple<Decl.Unit> externs = getExterns();
523 // Check whether replacing unit or adding new
524 for (int i = 0; i != externs.size(); ++i) {
525 Decl.Unit ith = externs.get(i);
526 if (ith.getName().equals(unit.getName())) {
527 // We're replacing an existing unit
528 externs.setOperand(i, unit);
529 return ith;
530 }
531 }
532 // We're adding a new unit
533 setOperand(2, getHeap().allocate(externs.append(unit)));
534 // Nothing was replaced
535 return null;
536 }
537
538 public void addAttribute(Syntactic.Marker attribute) {
539 setOperand(3, getHeap().allocate(getAttributes().append(attribute)));

Callers 1

consolidateMethod · 0.80

Calls 9

getExternsMethod · 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