c098f2a1ed76ee5c71b650fdd9705fa3c19c60c4
[vlp.git] / src / global / genint1.h
1 /*     Loglan82 Compiler&Interpreter
2      Copyright (C) 1993 Institute of Informatics, University of Warsaw
3      Copyright (C)  1993, 1994 LITA, Pau
4      
5      This program is free software; you can redistribute it and/or modify
6      it under the terms of the GNU General Public License as published by
7      the Free Software Foundation; either version 2 of the License, or
8      (at your option) any later version.
9      
10      This program is distributed in the hope that it will be useful,
11      but WITHOUT ANY WARRANTY; without even the implied warranty of
12      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13      GNU General Public License for more details.
14      
15              You should have received a copy of the GNU General Public License
16              along with this program; if not, write to the Free Software
17              Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
19  contacts:  Andrzej.Salwicki@univ-pau.fr
20
21 or             Andrzej Salwicki
22                 LITA   Departement d'Informatique
23                 Universite de Pau
24                 Avenue de l'Universite
25                 64000 Pau   FRANCE
26                  tel.  ++33 59923154    fax. ++33 59841696
27
28 =======================================================================
29 */
30
31 #ifndef __GENINT_H
32 #define __GENINT_H
33
34 #if GEN
35 #define word address
36 #endif
37
38
39 /**
40  * Appetites of values
41  * \defgroup AppetitesOfValues Appetites of values
42  * @{
43  */
44 /** integer,boolean,string,char */
45 #define APINT           1
46
47 /** real */
48 #define APREAL          sizeof(real)/sizeof(word)
49
50 /**
51  * To tell apart a virtual address
52  * (any reference type) from any other type
53  */
54 #define APVIRT          4
55
56 /** actual size of reference type */
57 #define APREF           2
58
59 /** formal type value */
60 #define APFMTYPE        2
61
62 /** formal procedure or function value, = apref + 1 */
63 #define APFMPROC        3
64
65 #define APOPCODE        (sizeof(extopcode) + sizeof(word) - 1) / sizeof(word)
66
67 /** @} */
68
69 #ifndef __cplusplus
70 typedef int bool;
71 #endif
72
73 /* In Qt4 these 2 definitions are already made */
74 #ifndef FALSE
75 #define FALSE           0
76 #endif
77
78 #ifndef TRUE
79 #define TRUE            1
80 #endif
81
82
83 /* Values identifying types and formal parameters: */
84 /** @{ */
85
86 #define FORMFUNC        7       /* parameter "function" */
87 #define FORMPROC        8       /* parameter "procedure" */
88 #define FORMTYPE        9       /* parameter "type", also formal type */
89 #define PARIN           11      /* parameter "input" */
90 #define PAROUT          12      /* parameter "output" */
91 #define PARINOUT        16      /* parameter "inout" */
92 #define PUREPROCESS     13      /* type PROCESS */
93 #define PURECOROUTINE   14      /* type COROUTINE */
94 #define PRIMITIVETYPE   15      /* simple type */
95 #define CLASSTYPE       17      /* class type */
96 #define FILETYPE        18      /* file type */
97 /** @} */
98
99 /* Values to identify kinds of array elements : */
100 /** @{ */
101 #define AINT            -1      /* arrayof integer */
102 #define AREAL           -3      /* arrayof real */
103 #define AVIRT           -2      /* arrayof reference */
104 #define APROCESS        -4      /* process reference implemented as arrayof */
105 #define FILEOBJECT      -11     /* file object */
106 #define SKILLED         -99     /* killed object, only for compactification */
107
108 /** @} */
109
110 #define DUMMY           -1      /* dummy unit or prefix : SL for main block */
111 #define MAINBLOCK       0       /* main block prototype number */
112 #define MAXPROT         500     /* limit for the number of prototypes */
113
114
115 /* L-code instruction addressing modes : */
116 /** @{ */
117 #define GLOBAL          0       /* M[ N ]                */
118 #define LOCAL           1       /* M[ c1+N ]             */
119 #define TEMPLOCAL       2       /* M[ c2+N ]             */
120 #define REMOTE          3       /* M[ M[ K ]+N ]         */
121 #define INDIRECT        4       /* M[ M[ N ] ]           */
122 #define IMMEDIATE       5       /* N                     */
123 #define CONSTANT        6       /* M[ N ]                */
124 #define DOTACCESS       7       /* M[ M[ display+K ]+N ] */
125 #define NOARGUMENT      8       /* ------                */
126 /** @} */
127
128
129 /* Prototype kind : */
130 /** @{ */
131 #define CLASS           0
132 #define RECORD          1
133 #define COROUTINE       2
134 #define PROCESS         3
135 #define BLOCK           4
136 #define PREFBLOCK       5
137 #define FUNCTION        6
138 #define PROCEDURE       7
139 #define HANDLER         8
140 /** @} */
141
142 #if GEN
143 #define LRECORD    RECORD
144 #define LFUNCTION  FUNCTION
145 #define LPROCEDURE PROCEDURE
146 #endif
147
148
149 #if GEN
150 typedef int protaddr;   /* mainblock..maxprot ; mainblock = 0; */
151                              /* INDIRECT ADDRESS OF PROTOTYPE       */
152 typedef int dprotaddr;  /* PROTADDR + DUMMY                    */
153 typedef int protkind;
154 #else
155 #define protaddr  int
156 #define dprotaddr int
157 #define protkind  int
158 #endif
159
160 /* TODO: Conditionally restore it:*/
161 typedef int word;
162
163 /**
164  * Prototype:
165  * \defgroup Prototype Prototype
166  * @{
167  */
168 typedef struct {
169         /**
170          * Prototype of syntactic father
171          * or dummy for the main block
172          */
173         dprotaddr slprototype;
174
175         /** address of code */
176         word codeaddr;
177         /** object's total length */
178         word appetite;
179         /**
180          * distance from beginning of object to
181          * temporary reference variables
182          */
183         word span;
184
185         /** beginning and length of table with */
186         word reflist;
187
188         /**
189          * offsets of reference values in object;
190          * without SL, DL, CL and temporary values
191          */
192         int lthreflist;
193         /** beginning and length of table with */
194         word parlist;
195         /** offsets of parameters */
196         int lthparlist;
197
198         /** beginning and length of table with */
199         word preflist;
200         /** prototype numbers of prefix sequence */
201         int lthpreflist;
202
203         /** lastwill code address */
204         word lastwill;
205         /** list of handlers, 0 if empty */
206         word handlerlist;
207         /**
208          * address of table for conversion:
209          * virtual number --> prototype
210          */
211         word virtlist;
212
213         /**
214          * only for processes:
215          * @{
216          */
217         /** lowest procedure prototype number */
218         protaddr maskbase;
219         /** size of RPC mask for that process */
220         int masksize;
221         /** @} */
222
223         /**
224          * for procedures and functions
225          * \defgroup PrototypeForFunctions
226          * @{
227          */
228         /* virtual number or -1 if not virtual */
229         int virtnumber;
230         /** @} */
231
232         /**
233          * for all :
234          * \defgroup PrototypeForAll
235          * @{
236          */
237         /** kind of unit */
238         protkind  kind;
239         /** @} */
240
241         /**
242          * only for procedures, functions and processes:
243          * \defgroup PrototypeForProceduresFunctionsProcesses
244          * @{
245          */
246         /** address of table with parameters descr. addresses */
247         word pfdescr;
248         /** @} */
249
250         /**
251          * only for functions:
252          * \defgroup PrototypeForFunctions
253          * @{
254          */
255         int nrarray;
256         /** @} */
257         /* type of result */
258         word finaltype;
259
260 } protdescr,*pointprdsc;
261
262 /** @} */
263
264 #endif /* __GENINT_H */