home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Tools / Languages / MacOberonLite 1.0.1 / Docu / Runtime.Mod < prev   
Encoding:
Text File  |  1993-07-11  |  1.4 KB  |  45 lines  |  [TEXT/ObLi]

  1. MODULE Runtime;    (*mf 8.10.92*)
  2.  
  3. (* If you want to use Oberon memory allocation and Garbage Collection,
  4.     you have to import Runtime and call GC by yourself! *)
  5.  
  6.     IMPORT
  7.         SYS:=SYSTEM;
  8.  
  9.     TYPE
  10.         Module= POINTER- TO ModDesc;
  11.         ModDesc= RECORD link: Module; data: LONGINT END;
  12.  
  13.     VAR
  14.         a5: LONGINT; modList: Module; mark1, scan: PROCEDURE;
  15.  
  16.     PROCEDURE GC*;    (*Call the Garbage Collector*)
  17.         VAR mod: Module;
  18.     BEGIN    mod:=modList;
  19.         WHILE    mod#NIL    DO    SYS.PUTREG(9, mod.data); mark1;
  20.             mod:=mod.link
  21.         END;
  22.         scan
  23.     END GC;
  24.  
  25. BEGIN    SYS.GETREG(13, a5);
  26.     SYS.GET(a5-24, modList); SYS.GET(a5-20, mark1); SYS.GET(a5-16, scan)
  27. END Runtime.
  28.  
  29. (*
  30.     Runtime exceptions are generated to vector number 7 (TRAPcc), and array index check 
  31.     exceptions are compiled into the CHK instruction which has vector number 6. You can
  32.     install a trap handler of your own in these slots. If you don't, MacsBug will handle the
  33.     exception if installed. The TRAPcc.W instruction is used with a word parameter signifying
  34.     the source of the trap as follows:
  35.  
  36.       2    NIL_reference (/n compiler option disables NIL_checking)
  37.     16    Invalid case in CASE statement
  38.     17    Function procedure without RETURN statement
  39.     18    Type guard check (/t compiler option disables type_checking)
  40.     19    Implied type guard check in record assignment
  41.     23    Out of heap space (when Oberon's NEW is used, not NewPtr)
  42.  
  43. Use the /x compiler option to turn off array index range checking.
  44.  
  45. *)