Added upstream version.
[vlp.git] / head / 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 /* Appetites of values : */
37 #define APINT           1     /* integer,boolean,string,char */
38 #define APREAL          sizeof(real)/sizeof(word)    /* real */
39 #define APVIRT          4     /*  TO TELL APART A VIRTUAL ADDRESS            */
40                               /*   (ANY REFERENCE TYPE)  FROM ANY OTHER TYPE */
41 #define APREF           2     /* ACTUAL SIZE OF REFERENCE TYPE               */
42 #define APFMTYPE        2     /* FORMAL TYPE VALUE                           */
43 #define APFMPROC        3     /* FORMAL PROCEURE OR FUNCTION VALUE, = APREF+1*/
44 #define APOPCODE        (sizeof(extopcode)+sizeof(word)-1)/sizeof(word)
45
46
47
48
49 /* Values identifying types and formal parameters : */
50
51 #define FORMFUNC        7       /* parameter "function" */
52 #define FORMPROC        8       /* parameter "procedure" */
53 #define FORMTYPE        9       /* parameter "type", also formal type */
54 #define PARIN           11      /* parameter "input" */
55 #define PAROUT          12      /* parameter "output" */
56 #define PARINOUT        16      /* parameter "inout" */
57 #define PUREPROCESS     13      /* type PROCESS */
58 #define PURECOROUTINE   14      /* type COROUTINE */
59 #define PRIMITIVETYPE   15      /* simple type */
60 #define CLASSTYPE       17      /* class type */
61 #define FILETYPE        18      /* file type */
62
63
64 /* Values to identify kinds of array elements : */
65
66 #define AINT            -1      /* arrayof integer */
67 #define AREAL           -3      /* arrayof real */
68 #define AVIRT           -2      /* arrayof reference */
69 #define APROCESS        -4      /* process reference implemented as arrayof */
70 #define FILEOBJECT      -11     /* file object */
71 #define SKILLED         -99     /* killed object, only for compactification */
72
73
74 #define DUMMY           -1      /* dummy unit or prefix : SL for main block */
75 #define MAINBLOCK       0       /* main block prototype number */
76 #define MAXPROT         500     /* limit for the number of prototypes */
77
78
79 /* L-code instruction addressing modes : */
80
81 #define GLOBAL          0       /* M[ N ]                */
82 #define LOCAL           1       /* M[ c1+N ]             */
83 #define TEMPLOCAL       2       /* M[ c2+N ]             */
84 #define REMOTE          3       /* M[ M[ K ]+N ]         */
85 #define INDIRECT        4       /* M[ M[ N ] ]           */
86 #define IMMEDIATE       5       /* N                     */
87 #define CONSTANT        6       /* M[ N ]                */
88 #define DOTACCESS       7       /* M[ M[ display+K ]+N ] */
89 #define NOARGUMENT      8       /* ------                */
90
91
92 /* Prototype kind : */
93
94 #define CLASS           0
95 #define RECORD          1
96 #define COROUTINE       2
97 #define PROCESS         3
98 #define BLOCK           4
99 #define PREFBLOCK       5
100 #define FUNCTION        6
101 #define PROCEDURE       7
102 #define HANDLER         8
103
104 #if GEN
105 #define LRECORD    RECORD
106 #define LFUNCTION  FUNCTION
107 #define LPROCEDURE PROCEDURE
108 #endif
109
110
111 #if GEN
112 typedef   int   protaddr ;   /* mainblock..maxprot ; mainblock = 0; */
113                              /* INDIRECT ADDRESS OF PROTOTYPE       */
114 typedef   int   dprotaddr ;  /* PROTADDR + DUMMY                    */
115 typedef   int   protkind ;
116
117
118
119 #else
120 #define protaddr  int
121 #define dprotaddr int
122 #define protkind  int
123 #endif
124
125
126
127 #define TRUE    1
128 #define FALSE   0
129
130
131 typedef int word;
132
133
134 /* Prototype : */
135
136 typedef struct {
137     dprotaddr slprototype ;   /* PROTOTYPE OF SYNTACTIC FATHER */
138                               /* OR DUMMY FOR THE MAIN BLOCK   */
139     word codeaddr;            /* address of code */
140     word appetite;            /* object's total length */
141     word span;                /* distance from beginning of object to */
142                               /* temporary reference variables */
143     word reflist;             /* beginning and length of table with */
144
145     int lthreflist;           /* offsets of reference values in object; */
146                               /* without SL, DL, CL and temporary values */
147     word parlist;             /* beginning and length of table with */
148     int lthparlist;           /* offsets of parameters */
149
150     word preflist;            /* beginning and length of table with */
151     int lthpreflist;          /* prototype numbers of prefix sequence */
152
153     word lastwill;            /* lastwill code address */
154     word handlerlist;         /* list of handlers, 0 if empty */
155     word virtlist;            /* address of table for conversion: */
156                               /*     virtual number --> prototype */
157
158     /* only for processes : */
159     protaddr  maskbase ;      /* lowest procedure prototype number */
160     int       masksize ;      /* size of RPC mask for that process */
161
162     /* for procedures and functions */
163     int virtnumber;           /* virtual number or -1 if not virtual */
164
165     /* for all : */
166     protkind  kind ;          /* kind of unit */
167
168     /* only for procedures, functions and processes : */
169     word pfdescr;             /* address of table with parameters descr. addresses */
170
171     /* only for functions : */
172     int nrarray;
173     word finaltype;  /* type of result */
174
175 } protdescr,*pointprdsc;
176
177