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