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