home *** CD-ROM | disk | FTP | other *** search
/ Gold Fish 2 / goldfish_vol2_cd1.bin / files / dev / obero / oberon-a / source / oc / ocg.mod < prev    next >
Text File  |  1994-08-08  |  7KB  |  241 lines

  1. (***************************************************************************
  2.  
  3.      $RCSfile: OCG.mod $
  4.   Description: Global constants for the compiler
  5.  
  6.    Created by: fjc (Frank Copeland)
  7.     $Revision: 4.9 $
  8.       $Author: fjc $
  9.         $Date: 1994/07/26 18:27:38 $
  10.  
  11.   Copyright © 1993-1994, Frank Copeland
  12.   This module forms part of the OC program
  13.   See OC.doc for conditions of use and distribution
  14.  
  15.   Log entries are at the end of the file.
  16.  
  17. ***************************************************************************)
  18.  
  19. MODULE OCG;
  20.  
  21. (*
  22. ** $C= CaseChk       $I= IndexChk  $L= LongAdr   $N= NilChk
  23. ** $P- PortableCode  $R= RangeChk  $S= StackChk  $T= TypeChk
  24. ** $V= OvflChk       $Z= ZeroVars
  25. *)
  26.  
  27. IMPORT Dos, SYS := SYSTEM;
  28.  
  29. CONST
  30.  
  31.   (* Sizes in bytes of basic data types. *)
  32.  
  33.   ByteSize * = 1; BoolSize * = 1; CharSize * = 1;
  34.   SIntSize * = 1; IntSize * = 2; LIntSize * = 4;
  35.   RealSize * = 4; LRealSize * = RealSize;
  36.   BSetSize * = 1; WSetSize * = 2; SetSize * = 4;
  37.   PtrSize * = 4; ProcSize * = 4;
  38.  
  39.   (*
  40.   ** Maximum size of a procedure's parameter list. This must correspond
  41.   ** to the constant used by the stack checking code. See STACKCHK.asm.
  42.   ** *Must* be at least 1500, to allow for the stack requirements of
  43.   ** dos.library functions.
  44.   *)
  45.  
  46.   ParLimit * = 1500;
  47.  
  48.   (* Minima and Maxima of basic data types. *)
  49.  
  50.   MinBool * = 0; MaxBool * = 1; MinChar * = 0; MaxChar * = 0FFH;
  51.   MinSInt * = -80H; MaxSInt * = 7FH;
  52.   MinInt * = -8000H; MaxInt * = 7FFFH;
  53.   MinLInt * = 80000000H; MaxLInt * = 7FFFFFFFH;
  54.   MinSet * = 0; MaxBSet * = 7; MaxWSet * = 15; MaxSet * = 31;
  55.  
  56.   (* REALs are implemented as Motorola FFP Single-Precision reals. *)
  57.   MinReal * = MIN (REAL)(*-9.22337177E18*);
  58.   MaxReal * = MAX (REAL)(*9.22337177E18*);
  59.   MaxExp * = 18;
  60.  
  61.   (*
  62.     For now, LONGREALs are the same as REALs.  In future, they will be
  63.     implemented as IEEE double-precision reals.
  64.   *)
  65.   MinLReal * = MinReal; MaxLReal * = MaxReal; MaxLExp * = MaxExp;
  66.  
  67.   (*
  68.    * Object and item modes, used by Module OCT and others. These are
  69.    * subject to change.
  70.    *)
  71.  
  72.   Undef   * =  0;
  73.   Var     * =  1; (* local and global variables and value parameters *)
  74.   VarX    * =  2; (* indexed array variables *)
  75.   VarR    * =  3; (* value parameter passed in a register *)
  76.   VarArg  * =  4; (* C-style vararg pushed on stack, for libcalls only *)
  77.   Ind     * =  5; (* variable parameters *)
  78.   IndX    * =  6; (* indexed dynamic array parameters *)
  79.   IndR    * =  7; (* variable parameter passed in a register *)
  80.   RegI    * =  8; (* register indirect mode with displacement *)
  81.   RegX    * =  9; (* register indirect mode with displacement and index *)
  82.   Lab     * = 10; (* absolute mode, the address of a label *)
  83.   LabI    * = 11; (* immediate mode, the address of a label *)
  84.   Abs     * = 12; (* absolute mode *)
  85.   Con     * = 13; (* constants *)
  86.   Push    * = 14; (* register indirect mode with predecrement *)
  87.   Pop     * = 15; (* register indirect mode with postincrement *)
  88.   Coc     * = 16; (* condition code *)
  89.   Reg     * = 17; (* register direct mode *)
  90.   Fld     * = 18; (* record fields *)
  91.   Typ     * = 19; (* types *)
  92.   LProc   * = 20; (* local (non-exportable) procedures *)
  93.   XProc   * = 21; (* exportable procedures *)
  94.   SProc   * = 22; (* standard procedures *)
  95.   LibCall * = 23; (* Amiga library functions *)
  96.   TProc   * = 24; (* Type-bound procedure *)
  97.   FProc   * = 25; (* Foreign procedures (such as in amiga.lib) *)
  98.   Mod     * = 26; (* Modules *)
  99.   Head    * = 27; (* symbol scope header *)
  100.   RList   * = 28; (* Register list for MOVEM *)
  101.  
  102. VAR
  103.   Verbose *: BOOLEAN; (* Verbose compiler output. *)
  104.   Trace -: BOOLEAN; (* Trace procedure calls *)
  105.   indent : INTEGER; (* Indent level for tracing *)
  106.   logFile : Dos.FileHandlePtr;
  107.   Digit : ARRAY 17 OF CHAR;
  108.  
  109. CONST
  110.   logFileName = "CON:100/56/540/189/Oberon.log/CLOSE/WAIT";
  111.   DigitString = "0123456789ABCDEF";
  112.  
  113. (*------------------------------------*)
  114. PROCEDURE Write * (ch : CHAR);
  115.  
  116.   VAR ignore : LONGINT;
  117.  
  118. BEGIN (* Write *)
  119.   IF Trace THEN ignore := Dos.base.Write (logFile, ch, 1) END
  120. END Write;
  121.  
  122. (*------------------------------------*)
  123. (* $D- disable copying of open arrays *)
  124. PROCEDURE WriteStr * (s : ARRAY OF CHAR);
  125.  
  126.   VAR ignore : LONGINT;
  127.  
  128. BEGIN (* WriteStr *)
  129.   IF Trace THEN ignore := Dos.base.Write (logFile, s, SYS.STRLEN (s)) END
  130. END WriteStr;
  131.  
  132. (*------------------------------------*)
  133. PROCEDURE WriteInt * (i : LONGINT);
  134.  
  135.   VAR ignore : LONGINT;
  136.  
  137.   (*------------------------------------*)
  138.   PROCEDURE WriteDigit (i : LONGINT);
  139.  
  140.     VAR ignore : LONGINT;
  141.  
  142.   BEGIN (* WriteDigit *)
  143.     IF i > 0 THEN WriteDigit (i DIV 10); Write (Digit [i MOD 10]) END
  144.   END WriteDigit;
  145.  
  146. BEGIN (* WriteInt *)
  147.   IF Trace THEN
  148.     IF i = 0 THEN Write ("0")
  149.     ELSE IF i < 0 THEN Write ("-") END; WriteDigit (ABS (i))
  150.     END
  151.   END
  152. END WriteInt;
  153.  
  154. (*------------------------------------*)
  155. (* $D- disable copying of open arrays *)
  156. PROCEDURE TraceIn * (mod, proc : ARRAY OF CHAR);
  157.  
  158.   VAR i : INTEGER;
  159.  
  160. BEGIN (* TraceIn *)
  161.   IF Trace THEN
  162.     i := 0; WHILE i < indent DO WriteStr ("  "); INC (i) END;
  163.     WriteStr (">>"); WriteStr (mod); Write ("."); WriteStr (proc);
  164.     Write ("\n");
  165.     INC (indent)
  166.   END
  167. END TraceIn;
  168.  
  169. (*------------------------------------*)
  170. (* $D- disable copying of open arrays *)
  171. PROCEDURE TraceOut * (mod, proc : ARRAY OF CHAR);
  172.  
  173.   VAR i : INTEGER;
  174.  
  175. BEGIN (* TraceOut *)
  176.   IF Trace THEN
  177.     DEC (indent);
  178.     i := 0; WHILE i < indent DO WriteStr ("  "); INC (i) END;
  179.     WriteStr ("<<"); WriteStr (mod); Write ("."); WriteStr (proc);
  180.     Write ("\n");
  181.   END
  182. END TraceOut;
  183.  
  184. (*------------------------------------*)
  185. PROCEDURE StartTrace * ();
  186.  
  187. BEGIN (* StartTrace *)
  188.   logFile := Dos.base.Open (logFileName, Dos.modeNewFile);
  189.   Trace := TRUE;
  190. END StartTrace;
  191.  
  192. (*------------------------------------*)
  193. PROCEDURE EndTrace * ();
  194.  
  195. BEGIN (* EndTrace *)
  196.   IF Trace THEN
  197.     Dos.base.OldClose (logFile); Trace := FALSE; logFile := NIL
  198.   END
  199. END EndTrace;
  200.  
  201. (*------------------------------------*)
  202. PROCEDURE* Cleanup ();
  203.  
  204. BEGIN (* Cleanup *)
  205.   IF logFile # NIL THEN Dos.base.OldClose (logFile); logFile := NIL END;
  206. END Cleanup;
  207.  
  208. BEGIN
  209.   Digit := DigitString; indent := 0;
  210.   Trace := FALSE; logFile := NIL;
  211.   SYS.SETCLEANUP (Cleanup)
  212. END OCG.
  213.  
  214. (***************************************************************************
  215.  
  216.   $Log: OCG.mod $
  217.   Revision 4.9  1994/07/26  18:27:38  fjc
  218.   *** empty log message ***
  219.  
  220.   Revision 4.8  1994/07/25  00:43:07  fjc
  221.   - Exported ParLimit.
  222.  
  223.   Revision 4.7  1994/07/22  13:58:56  fjc
  224.   - Exported FProc.
  225.  
  226.   Revision 4.6  1994/07/10  12:44:34  fjc
  227.   - Changed to use new SETCLEANUP format.
  228.  
  229.   Revision 4.3  1994/06/06  18:34:55  fjc
  230.   - Exported VarArg item mode.
  231.  
  232.   Revision 4.2  1994/06/05  22:43:28  fjc
  233.   - Changed to use new Amiga interface.
  234.   - Added code to cleanup log file.
  235.  
  236.   Revision 4.1  1994/06/01  09:33:44  fjc
  237.   - Bumped version number
  238.  
  239. ***************************************************************************)
  240.  
  241.