Added upstream from http://ftp.icm.edu.pl/pub/loglan/
[loglan.git] / sources / int / int.h
1 #define MAXMARKER       MAXINTEGER  /* maximum special value of mark */\r
2 #define MAXAPPT         MAXINTEGER  /* maximum appetite (easily extensible ?) */\r
3 #define MAXTRACNT       13      /* maximum number of trace messages in line */\r
4 #define MAXHDLEN        40      /* maximum length of formal procedure header */\r
5 #define MAXSYSSN        62      /* maximum number of a system signal */\r
6 #define MAXPARAM        10      /* maximum number of params to standard proc */\r
7 #define IOBLOCK         0x4000  /* size of I/O transfer block in bytes */\r
8 \r
9 /* Object structure : */\r
10 \r
11 /* Offsets from the beginning : */\r
12 #define PROTNUM         1       /* prototype number */\r
13 #define SHORTLINK       1       /* link to same size list (killed only) */\r
14 #define LONGLINK        2       /* link to other size list (killed only) */\r
15 \r
16 /* Files : */\r
17 /*      appetite        0       */\r
18 /*      prot number     1       always FILEOBJECT */\r
19 #define FSTAT           2       /* file status */\r
20 #define FTEMP           3       /* flag to tell if file is temporary */\r
21 #define FTYPE           4       /* file type */\r
22 #define FNAME           5       /* file name pointer */\r
23 #define FFILE           (FNAME+sizeof(char *)/sizeof(word)) /*file handle */\r
24 #define APFILE          (FFILE+sizeof(FILE *)/sizeof(word)) /*appetite of file*/\r
25                                                             /* object */\r
26 \r
27 /* Offsets from the first address after object : */\r
28 #define SL              -2      /* static link */\r
29 #define DL              -4      /* dynamic link */\r
30 #define LSC             -5      /* local control */\r
31 #define STATSL          -6      /* number of times the object occurs in SL */\r
32 #define SIGNR           -7      /* signal number (handlers only) */\r
33 #define RPCDL           -8      /* remote dynamic link (procedures only) */\r
34 #define CL              -8      /* coroutine link (coroutine only) */\r
35 #define CHD             -10     /* coroutine head (process only) */\r
36 #define VIRTSC          -12     /* virtual scratch  (process only) */\r
37 \r
38 /* Virtual address (also formal type) : */\r
39 \r
40 typedef struct {\r
41                 word addr;      /* address of dictionary item */\r
42                                 /* (node and process index for processes) */\r
43                                 /* (or for formal types - number of arrayof) */\r
44                 word mark;      /* address mark */\r
45                                 /* (negative for processes) */\r
46                                 /* (or for formal types - actual type) */\r
47                } virtaddr;\r
48 \r
49 #define loadvirt(v, a)  { word ta;              \\r
50                           ta = (a);             \\r
51                           (v).addr = M[ ta++ ]; \\r
52                           (v).mark = M[ ta ]; }\r
53 #define storevirt(v, a) { word ta;              \\r
54                           ta = (a);             \\r
55                           M[ ta++ ] = (v).addr; \\r
56                           M[ ta ] = (v).mark; }\r
57                         \r
58 #define MF(a)           (*( (FILE **) (M+(a)) ))\r
59 #define MN(a)           (*( (char **) (M+(a)) ))\r
60 #define MR(a)            *( (real *) (M+(a)) )\r
61 \r
62 \r
63 #ifdef max\r
64 #undef max\r
65 #endif\r
66 \r
67 #ifdef min\r
68 #undef min\r
69 #endif\r
70 \r
71 #define min(x, y)       ((x) < (y) ? (x) : (y))\r
72 #define max(x, y)       ((x) > (y) ? (x) : (y))\r
73 #define absolute(x)     ((x) >= 0 ? (x) : -(x))\r
74 \r
75 /* LOGLAN's booleans : */\r
76 #define LFALSE          ((word)0)\r
77 #define LTRUE           (~LFALSE)\r
78 #define lbool(b)        ( (b) ? LTRUE : LFALSE )\r
79 \r
80 /* Type of files : */\r
81 #define TEXTF           1       /* text file */\r
82 #define CHARF           2       /* file of char */\r
83 #define INTF            3       /* file of integer */\r
84 #define REALF           4       /* file of real */\r
85 #define DIRECT          5       /* direct access file */\r
86 \r
87 /* File status : */\r
88 #define READING         0       /* sequential file opened for read */\r
89 #define WRITING         1       /* sequential file opened for write */\r
90 #define UPDATING        2       /* direct access file */\r
91 #define UNKNOWN         3       /* file not opened */\r
92 \r
93 /* Run time error types : */\r
94 \r
95 #define RTESLCOF        0       /* SL chain cut off */\r
96 #define RTEUNSTP        1       /* unimplemented standard procedure */\r
97 #define RTEILLAT        2       /* illegal attach */\r
98 #define RTEILLDT        3       /* illegal detach */\r
99 #define RTECORTM        4       /* coroutine terminated */\r
100 #define RTECORAC        5       /* coroutine active */\r
101 #define RTEINVIN        6       /* array index error */\r
102 #define RTEILLAB        7       /* incorrect array bounds */\r
103 #define RTEINCQA        8       /* improper QUA */\r
104 #define RTEINCAS        9       /* illegal assignment */\r
105 #define RTEFTPMS        10      /* formal type missing */\r
106 #define RTEILLKL        11      /* illegal kill */\r
107 #define RTEILLCP        12      /* illegal copy */\r
108 #define RTEINCHS        13      /* incompatible headers */\r
109 #define RTEHNDNF        14      /* handler not found */\r
110 #define RTEMEMOV        15      /* memory overflow */\r
111 #define RTEFHTLG        16      /* formal header too long */\r
112 #define RTEILLRT        17      /* illegal return */\r
113 #define RTEREFTN        18      /* reference to NONE */\r
114 #define RTEDIVBZ        19      /* division by zero */\r
115 #define RTESYSER        20      /* system error */\r
116 #define RTEILLIO        21      /* illegal I/O operation */\r
117 #define RTEIOERR        22      /* I/O error */\r
118 #define RTECNTOP        23      /* Cannot open file */\r
119 #define RTEBADFM        24      /* Input data format bad */\r
120 #define RTEILLRS        25      /* illegal resume */\r
121 #define RTETMPRC        26      /* too many processes on one machine */\r
122 #define RTEINVND        27      /* invalid node number */\r
123 #define RTENEGST        28      /* negative step value */\r
124 #define RTENONGL        29      /* only process may be global */\r
125 \r
126 union value {\r
127                 unsigned int xint;\r
128                 word xword;\r
129                 real xreal;\r
130                 virtaddr xvirt;\r
131                 word xbool;\r
132             };\r
133 \r
134 /* Variables : */\r
135 \r
136 extern memory M;                /* main memory for code and data */\r
137 extern union value *param;      /* pointer to standard proc. param list */\r
138 extern int offset[];            /* offset conversion table for compact. */\r
139 extern int scot[];              /* signal to number conversion table */\r
140 extern int primapet[];          /* appetites of primitive types */\r
141 extern word ic;                 /* instruction counter */\r
142 extern word lastic;             /* previous ic for redecoding after comp. */\r
143 extern int opcode;              /* opcode of L-code instruction */\r
144 extern word a1, a2, a3;         /* arguments of L-code instruction */\r
145 \r
146 /* kernel variables for the running system */\r
147 \r
148 extern word memorysize;         /* size of memory array for code and data */\r
149 extern word dispoff;            /* DISPLAY offset in process object */\r
150 extern word disp2off;           /* indirect DISPLAY offset in process object */\r
151 extern word display;            /* DISPLAY address - physical addresses */\r
152 extern word display2;           /* DISPLAY address - indirect addresses */\r
153 extern word c1, c2;             /* pointers to current object */\r
154 extern word mainprog;           /* main block object */\r
155 extern word mnoff;              /* offset of variable main */\r
156 \r
157 \r
158 extern bool infmode;            /* TRUE if compactification message printed */\r
159 extern bool debug;              /* TRUE if trace is printed */\r
160 extern FILE *tracefile;         /* output file for trace */\r
161 \r
162 extern jmp_buf contenv;         /* for continue execution */\r
163 \r
164 \r
165 \r