home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / Misc / comal3-2.dms / in.adf / ModuleDev / Comal.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-04-10  |  7.7 KB  |  229 lines

  1. /***********************************************************************/
  2. /*                                                                     */
  3. /*                                                                     */
  4. /*                                                                     */
  5. /*            Structures and definitions for machine coded modules           */
  6. /*                                                                     */
  7. /*                     version 93.01.31                                */
  8. /*                                                                     */
  9. /***********************************************************************/
  10.  
  11. #ifndef COMAL_H
  12.  
  13. #define COMAL_H
  14.  
  15. #ifndef EXEC_TYPES_H
  16. #include <exec/types.h>
  17. #endif  /* EXEC_TYPES_H */
  18.  
  19. #ifndef LIBRARIES_DOS_H
  20. #include <libraries/dos.h>
  21. #endif  /* LIBRARIES_DOS_H */
  22.  
  23. struct ComalStruc
  24. {
  25.   UWORD BreakFlags;
  26.   UWORD Flags;                   /* See definitions below               */
  27.   UBYTE *CurrWorkBottom;         /* Current start of workspace          */
  28.   UBYTE *CurrWorkTop;            /* Current top of workspace            */
  29.   UBYTE *MinStack;               /* Safe low value of stack             */
  30.   struct Screen *IO_Screen;      /* Input/output screen                 */
  31.   struct MsgPort *CommPort;      /* Port to comunicate with parent      */
  32.   char  *Id;                     /* ASCII ID string for this project    */
  33.   struct PrgBuf *MainPrgBuf;     /* Main program buffer                 */
  34.   struct PrgEnv *PrgEnv;         /* Current program environment         */
  35.   UBYTE *WorkStart;              /* Start of workspace                  */
  36.   UBYTE *WorkEnd;                /* End of useable workspace            */
  37.   ULONG WorkLength;              /* Total length of workspace           */
  38.   UBYTE *SortTable;              /* String sort table                   */
  39.   UBYTE *ComalPath;              /* Home directory for comal            */
  40. };
  41.  
  42. /* Break flags definitions  */
  43. #define BF_ESC          0x01
  44. #define BF_SingleStep   0x02
  45. #define BF_Interrupt    0x04
  46. #define BF_BreakPoint   0x08
  47.  
  48. /* Secondary break flags definitions  */
  49. #define BF_LineStep     0x01
  50.  
  51. /* Flags definitions  */
  52. #define F_ESCMINUS  0x0001       /* Trap escape key                     */
  53. #define F_ESCPRESS  0x0002       /* Break pressed during TRAP ESC+      */
  54. #define F_TRACEMODE 0x0004       /* Executing in TRACE-mode             */
  55.  
  56.  
  57. struct Module
  58. {
  59.   struct Module *NextModule;        /* Link to next module structure    */
  60.   UBYTE  *Name;                     /* Name of module                   */
  61.   UBYTE  Type;                      /* Modules type - see below         */
  62.   UBYTE  Flags;                     /* Flags - se below                 */
  63.   union
  64.   {
  65.     struct PrgBuf *PrgBuf;          /* Pointer to program buffer        */
  66.     BPTR   Segment;                 /* Pointer to modules segment list  */
  67.   } PrgMem;
  68.   struct PrgEnv *PrgEnv;            /* Only used in comal modules       */
  69.   union
  70.   {
  71.     struct ModuleLine *ModuleLine;  /* Only used in comal modules       */
  72.     char **TextArray;               /* Information text for code module */
  73.   } Inf;
  74.   WORD   NumType;                   /* Number of types defined in modul */
  75.   struct ModuleType *Types;         /* Array of types defined in module */
  76.   WORD   NumName;                   /* Number of names defined in modul */
  77.   struct ModuleName *Names;         /* Array of exported names          */
  78.   void   (*Signal)(ULONG);          /* Address of signal routine        */
  79. };
  80. /* Module types */
  81. #define LOCALMODULE   1             /* Local module                     */
  82. #define EXTERNMODULE  2             /* External module                  */
  83. #define CODEMODULE    3             /* External machine coded module    */
  84.  
  85. /* Signal numbers */
  86. #define SIG_CLOSE       1           /* Interpreter is closed            */
  87. #define SIG_DISCARD     2           /* Module is being discarded        */
  88. #define SIG_CLEAR       3           /* Program buffer is returned       */
  89. #define SIG_RUN         4           /* Program execution starts         */
  90. #define SIG_STOP        5           /* Execution stops (to be continued) */
  91. #define SIG_END         6           /* End of execution (no continue)   */
  92.  
  93. /* Types  */
  94. #define STRING_ID   -1
  95. #define FLOAT_ID    -2
  96. #define ULONG_ID    -3
  97. #define LONG_ID     -4
  98. #define UWORD_ID    -5
  99. #define WORD_ID     -6
  100. #define UBYTE_ID    -7
  101. #define BYTE_ID     -8
  102. #define STRUC_ID    -9
  103. #define ARRAY_ID   -10
  104. #define FUNC_ID    -11
  105. #define PROC_ID    -12
  106. #define POINTER_ID -13
  107.  
  108. /* Type descriptor for array  */
  109.  
  110. struct IndexRange
  111. {
  112.   LONG Lower;
  113.   LONG NumberOf;
  114. };
  115.  
  116. struct Array
  117. {
  118.   WORD TypeId;            /* Type identifier (right side in TYPE line)  */
  119.   WORD ElementType;       /* Element type                               */
  120.   ULONG Length;           /* Length of data                             */
  121.   WORD *TypeDescriptor;   /* address of secondary type descriptor       */
  122.   WORD NumDim;            /* Number of dimensions                       */
  123.   LONG NumElement;        /* Total number of elements                   */
  124.   struct IndexRange Index[1];
  125. };
  126.  
  127.  
  128. /* Type descriptor for FUNC/PROC */
  129.  
  130. struct Param
  131. {
  132.   UBYTE Flags;
  133.   BYTE  SecondaryType;
  134.   WORD  PrimaryType;
  135. };
  136.  
  137. struct ProcType
  138. {
  139.   WORD TypeId;            /* Type identifier (right side in TYPE line)  */
  140.   WORD ReturnType;        /* Return type (FUNC) or zero (PROC)          */
  141.   WORD *TypeDescriptor;   /* Type descriptor for return type            */
  142.   UWORD Flags;
  143.   UBYTE StackUse1;        /* Stack use of type descriptors              */
  144.   UBYTE StackUse0;        /* Primary parameter stack use                */
  145.   UWORD NumPar;           /* Number of formal parameters                */
  146.   struct Param Param[1];
  147. };
  148.  
  149.  
  150. struct ExceptStruc
  151. {
  152.     struct ExceptStruc *Next;
  153.     ULONG SignalMask;
  154.     void  (*ExceptRoutine)();
  155.   APTR  IdField;
  156. };
  157.  
  158. /************************************************************************/
  159. /*                                                                      */
  160. /*        Definitions for streams                                       */
  161. /*                                                                      */
  162. /*                                                                      */
  163. /************************************************************************/
  164.  
  165. struct IoDevice
  166. {
  167.   struct IoDevice *NextDevice;
  168.   UBYTE *Name;
  169.   UWORD Type;
  170.   UWORD Reserved;
  171.   ULONG (*Open)(char *,UWORD,short *);
  172.   void (*Close)(ULONG);
  173.   short (*Read)(ULONG,UBYTE *,LONG *,ULONG);
  174.   BOOL (*Write)(ULONG,UBYTE *,LONG *);
  175.   short (*ReadLn)(ULONG,UBYTE *,LONG *);
  176.   BOOL (*WriteLn)(ULONG,UBYTE *,LONG *);
  177.   short (*Scan)(ULONG,UBYTE *,LONG *);
  178.   union
  179.   {
  180.     BOOL (*Cursor)(ULONG,short *,short *);
  181.     BOOL (*StrmPtr)(ULONG,LONG *);
  182.   } Get;
  183.   union
  184.   {
  185.     BOOL (*Cursor)(ULONG,short,short);
  186.     BOOL (*StrmPtr)(ULONG,LONG);
  187.   } Set;
  188.   short (*StreamError)();
  189. };
  190.  
  191. /* Standard stream numbers  */
  192. #define StdInStream    -1
  193. #define StdOutStream   -2
  194.  
  195. /* Device types */
  196. #define SEQ_DEVICE   0
  197. #define CRT_DEVICE   1
  198. #define KBD_DEVICE   2
  199. #define RBF_DEVICE   3
  200.  
  201. struct Stream
  202. {
  203.   struct Stream *NextStream;
  204.   WORD Number;
  205.   UWORD Flags;
  206.   ULONG RecordLength;             /* Zero if sequential device          */
  207.   struct IoDevice *Device;        /* Pointer to to device information   */
  208.   ULONG StreamId;                 /* Stream identification              */
  209. };
  210.  
  211. /* Stream flags */
  212. #define READ_STREAM   0x0001
  213. #define WRITE_STREAM  0x0002
  214. #define END_OF_STREAM 0x0004
  215.  
  216. /* Stream access modes  */
  217. #define ACCESSREAD   0x0001
  218. #define ACCESSWRITE  0x0002
  219. #define ACCESSNEW    0x0004
  220.  
  221. /* Open modes   */
  222. #define READ_MODE     ACCESSREAD
  223. #define APPEND_MODE   ACCESSWRITE
  224. #define UPDATE_MODE   ACCESSREAD | ACCESSWRITE
  225. #define REWRITE_MODE  ACCESSWRITE | ACCESSNEW
  226.  
  227. #endif
  228.  
  229.