[Oberon] Module finalization in PO2013

Andreas Pirklbauer andreas_pirklbauer at yahoo.com
Wed Dec 30 18:35:23 CET 2020

Thank you all for the module finalization discussion today (mostly off-forum). It turns out
that the whole thing can be implemented in less than 10 lines of code in Modules:

  PROCEDURE SetClose*(close: Command); (*set module finalization sequence*)
    VAR u, v: INTEGER; mod: Module;
  BEGIN u := SYSTEM.REG(LNK); mod := root;
    WHILE (mod # NIL) & ((u < mod.code) OR (u >= mod.imp)) DO mod := mod.next END ; (*search for caller*)
    IF mod # NIL THEN SYSTEM.GET(mod.ent, v); (*offset to body*)
      IF (mod.code + v <= u) & (u < mod.imp) THEN mod.close := close ELSE res := 9 END
  END SetClose;


More information about the Oberon mailing list