| 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(); |