Documentation fixes
[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 /**
35  * @file
36  */
37
38 #if GEN
39 #define word address
40 #endif
41
42
43 /**
44  * Appetites of values
45  * \defgroup AppetitesOfValues Appetites of values
46  * @{
47  */
48 /** integer,boolean,string,char */
49 #define APINT           1
50
51 /** real */
52 #define APREAL          sizeof(real)/sizeof(word)
53
54 /**
55  * To tell apart a virtual address
56  * (any reference type) from any other type
57  */
58 #define APVIRT          4
59
60 /** actual size of reference type */
61 #define APREF           2
62
63 /** formal type value */
64 #define APFMTYPE        2
65
66 /** formal procedure or function value, = apref + 1 */
67 #define APFMPROC        3
68
69 #define APOPCODE        (sizeof(extopcode) + sizeof(word) - 1) / sizeof(word)
70
71 /** @} */
72
73 #ifndef __cplusplus
74 typedef int bool;
75 #endif
76
77 /* In Qt4 these 2 definitions are already made */
78 #ifndef FALSE
79 #define FALSE           0
80 #endif
81
82 #ifndef TRUE
83 #define TRUE            1
84 #endif
85
86
87 /* Values identifying types and formal parameters: */
88 /** @{ */
89
90 #define FORMFUNC        7       /* parameter "function" */
91 #define FORMPROC        8       /* parameter "procedure" */
92 #define FORMTYPE        9       /* parameter "type", also formal type */
93 #define PARIN           11      /* parameter "input" */
94 #define PAROUT          12      /* parameter "output" */
95 #define PARINOUT        16      /* parameter "inout" */
96 #define PUREPROCESS     13      /* type PROCESS */
97 #define PURECOROUTINE   14      /* type COROUTINE */
98 #define PRIMITIVETYPE   15      /* simple type */
99 #define CLASSTYPE       17      /* class type */
100 #define FILETYPE        18      /* file type */
101 /** @} */
102
103 /* Values to identify kinds of array elements : */
104 /** @{ */
105 #define AINT            -1      /* arrayof integer */
106 #define AREAL           -3      /* arrayof real */
107 #define AVIRT           -2      /* arrayof reference */
108 #define APROCESS        -4      /* process reference implemented as arrayof */
109 #define FILEOBJECT      -11     /* file object */
110 #define SKILLED         -99     /* killed object, only for compactification */
111
112 /** @} */
113
114 #define DUMMY           -1      /* dummy unit or prefix : SL for main block */
115 #define MAINBLOCK       0       /* main block prototype number */
116 #define MAXPROT         500     /* limit for the number of prototypes */
117
118
119 /* L-code instruction addressing modes : */
120 /** @{ */
121 #define GLOBAL          0       /* M[ N ]                */
122 #define LOCAL           1       /* M[ c1+N ]             */
123 #define TEMPLOCAL       2       /* M[ c2+N ]             */
124 #define REMOTE          3       /* M[ M[ K ]+N ]         */
125 #define INDIRECT        4       /* M[ M[ N ] ]           */
126 #define IMMEDIATE       5       /* N                     */
127 #define CONSTANT        6       /* M[ N ]                */
128 #define DOTACCESS       7       /* M[ M[ display+K ]+N ] */
129 #define NOARGUMENT      8       /* ------                */
130 /** @} */
131
132
133 /* Prototype kind : */
134 /** @{ */
135 #define CLASS           0
136 #define RECORD          1
137 #define COROUTINE       2
138 #define PROCESS         3
139 #define BLOCK           4
140 #define PREFBLOCK       5
141 #define FUNCTION        6
142 #define PROCEDURE       7
143 #define HANDLER         8
144 /** @} */
145
146 #if GEN
147 #define LRECORD    RECORD
148 #define LFUNCTION  FUNCTION
149 #define LPROCEDURE PROCEDURE
150 #endif
151
152
153 #if GEN
154 typedef int protaddr;   /* mainblock..maxprot ; mainblock = 0; */
155                              /* INDIRECT ADDRESS OF PROTOTYPE       */
156 typedef int dprotaddr;  /* PROTADDR + DUMMY                    */
157 typedef int protkind;
158 #else
159 #define protaddr  int
160 #define dprotaddr int
161 #define protkind  int
162 #endif
163
164 /* TODO: Conditionally restore it:*/
165 typedef int word;
166
167 /**
168  * Prototype:
169  * \defgroup Prototype Prototype
170  * @{
171  */
172 typedef struct {
173         /**
174          * Prototype of syntactic father
175          * or dummy for the main block
176          */
177         dprotaddr slprototype;
178
179         /** address of code */
180         word codeaddr;
181         /** object's total length */
182         word appetite;
183         /**
184          * distance from beginning of object to
185          * temporary reference variables
186          */
187         word span;
188
189         /** beginning and length of table with */
190         word reflist;
191
192         /**
193          * offsets of reference values in object;
194          * without SL, DL, CL and temporary values
195          */
196         int lthreflist;
197         /** beginning and length of table with */
198         word parlist;
199         /** offsets of parameters */
200         int lthparlist;
201
202         /** beginning and length of table with */
203         word preflist;
204         /** prototype numbers of prefix sequence */
205         int lthpreflist;
206
207         /** lastwill code address */
208         word lastwill;
209         /** list of handlers, 0 if empty */
210         word handlerlist;
211         /**
212          * address of table for conversion:
213          * virtual number --> prototype
214          */
215         word virtlist;
216
217         /**
218          * only for processes:
219          * @{
220          */
221         /** lowest procedure prototype number */
222         protaddr maskbase;
223         /** size of RPC mask for that process */
224         int masksize;
225         /** @} */
226
227         /**
228          * for procedures and functions
229          * \defgroup PrototypeForFunctions
230          * @{
231          */
232         /* virtual number or -1 if not virtual */
233         int virtnumber;
234         /** @} */
235
236         /**
237          * for all :
238          * \defgroup PrototypeForAll
239          * @{
240          */
241         /** kind of unit */
242         protkind  kind;
243         /** @} */
244
245         /**
246          * only for procedures, functions and processes:
247          * \defgroup PrototypeForProceduresFunctionsProcesses
248          * @{
249          */
250         /** address of table with parameters descr. addresses */
251         word pfdescr;
252         /** @} */
253
254         /**
255          * only for functions:
256          * \defgroup PrototypeForFunctions
257          * @{
258          */
259         int nrarray;
260         /** @} */
261         /* type of result */
262         word finaltype;
263
264 } protdescr,*pointprdsc;
265
266 /** @} */
267
268 #endif /* __GENINT_H */