2 * The Regina Rexx Interpreter
3 * Copyright (C) 1992-1994 Anders Christensen <anders@pvv.unit.no>
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library 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 GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the Free
17 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 typedef struct varbox
*variableptr
;
26 typedef const struct varbox
*cvariableptr
;
27 typedef struct varbox
{
28 variableptr next
, prev
, realbox
, *index
;
29 struct strengtype
*name
, *value
;
33 long hwired
, valid
; /* FGC: at least valid may be too small for many
34 recursions with short instead of long.
35 27.09.98 (09/27/98). */
39 /* typedef int bool ; */
44 unsigned int lsvar
:1 ;
45 unsigned int rsvar
:1 ;
46 unsigned int lcvar
:1 ;
47 unsigned int rcvar
:1 ;
58 unsigned int append
:1 ;
59 unsigned int isinput
:1 ;
60 unsigned int awt
:3 ; /* overlay with AddressWithType */
61 } outputflags
; /* used by ADDRESS WITH resourceo */
63 typedef struct pparambox
*paramboxptr
;
64 typedef const struct pparambox
*cparamboxptr
;
65 typedef struct tnode
*nodeptr
;
66 typedef const struct tnode
*cnodeptr
;
73 struct _tsd_t
; /* If this won't work change "struct _tsd_t *" to "void *"
74 * below. This will require more changes. Let your compiler
77 typedef struct tnode
{
81 struct strengtype
*name
;
85 streng
*(*func
)(struct _tsd_t
*,cparamboxptr
) ;
95 unsigned long nodeindex
; /* for an effectiv relocation, never change! */
98 typedef struct pparambox
{
101 struct strengtype
*value
;
104 typedef struct lineboxx
*lineboxptr
;
105 typedef const struct lineboxx
*clineboxptr
;
106 typedef struct lineboxx
{
107 lineboxptr next
, prev
;
108 struct strengtype
*line
;
112 typedef struct labelboxx
*labelboxptr
;
113 typedef const struct labelboxx
*clabelboxptr
;
114 typedef struct labelboxx
{
120 typedef struct trap_type
/* index is type of signal */
122 unsigned int on_off
:1 ; /* true if trap is active/on */
123 /* unsigned int trapped:1 ; */ /* true if condition has been raised */
124 unsigned int def_act
:1 ; /* true if default action is to ignore */
125 unsigned int delayed
:1 ; /* true if trap is in delay mode */
126 unsigned int ignored
:1 ; /* true if ignored when in delayed mode */
127 unsigned int invoked
:1 ; /* true if invoked by SIGNAL */
128 streng
*name
; /* label to transfer control to */
131 typedef struct sig_type
136 int invoke
; /* is true if invoked with SIGNAL */
137 int rc
, subrc
, lineno
;
140 typedef void (*signal_handler
)(int);
142 typedef struct __regina_option
149 typedef struct { /* one for each redirection in environment */
150 streng
*name
; /* stemname or streamname if any */
152 streng
*base
; /* "number" if name is a stem */
153 streng
*currname
; /* name + ".number" if name is a stem */
154 int currnum
; /* current number for a stem position */
155 /* or -1 if unknown */
156 int maxnum
; /* maximum number for a stem position */
157 /* or -1 if unknown */
158 void *file
; /* fileboxptr of the file with the */
159 /* above name or NULL. */
160 unsigned int SameAsOutput
:1; /* locally used in shell.c */
161 unsigned int FileRedirected
:1; /* locally used in shell.c */
162 char *tempname
; /* locally used filename in shell.c */
163 int type
; /* locally used source in shell.c */
164 int hdls
[2]; /* locally used connection in shell.c */
168 struct strengtype
*name
; /* stemname or streamname if any */
169 int subtype
; /* SUBENVIR_... */
175 typedef struct proclevelbox
*proclevel
;
176 typedef const struct proclevelbox
*cproclevel
;
177 typedef struct proclevelbox
{
178 int numfuzz
, currnumsize
, numform
;
181 proclevel prev
, next
;
184 struct strengtype
*environment
, *prev_env
;
185 char tracestat
, traceint
, varflag
; /* MDW 30012002 */
188 jmp_buf *buf
; /* for use by longjmp */
190 unsigned char flags
[4] ;
194 typedef struct _ttree
{ /* bucket list of treenodes which allows ultra fast
195 * loading of instore macros.
198 unsigned long max
; /* maximum number of elements in the bucket */
199 unsigned long num
; /* current number of elements in the bucket */
200 unsigned long sum
; /* sum of indices until element 0 */
202 } ttree
; /* treenode type */
204 typedef struct { /* offsrcline: offset based source lines */
205 unsigned long length
;
206 unsigned long offset
;
207 /* That's all. You need the source string of the incore macro to create
208 * a real sourceline using this information.
212 typedef struct _otree
{ /* bucket list of offscrlines which allows ultra fast
213 * loading of instore macros.
216 unsigned long max
; /* maximum number of elements in the bucket */
217 unsigned long num
; /* current number of elements in the bucket */
218 unsigned long sum
; /* sum of indices until element 0 */
220 } otree
; /* offsrcline type */
222 typedef struct { /* internal_parser_type is a structure containing data from a
225 lineboxptr first_source_line
; /* Either this two values */
226 lineboxptr last_source_line
; /* exist or srclines below */
227 int tline
; /* line number where error occured */
228 int tstart
; /* column number where error occured */
229 int if_linenr
; /* line number of last IF keyword */
230 int when_linenr
; /* line number of last WHEN keyword */
231 labelboxptr first_label
;
232 labelboxptr last_label
;
233 unsigned long numlabels
;
234 labelboxptr sort_labels
;
238 otree
* srclines
; /* Either this two values exist */
239 const char * incore_source
; /* or the two values above */
240 streng
* kill
; /* Probably the true source of incore_source in case
241 * of an "INTERPRET" instruction or other not user
242 * generated but interpreted strings; else NULL.
244 struct _tsd_t
*TSD
; /* needed during the parsing step */
245 } internal_parser_type
;
247 typedef struct { /* extstring: external (instore) string */
248 unsigned long length
;
249 /* and directly following the string's content */
252 typedef struct { /* external_parser_type: the instore macro in user space */
253 /* Never change from here until source including since it allows the
254 * reconstruction of the source if the machine type or Regina version
257 char Magic
[32]; /* "Regina's Internal Format\r\n" filled with 0 */
258 #define MAGIC "Regina's Internal Format\r\n"
259 char ReginaVersion
[64]; /* PARSE_VERSION_STRING */
261 /* The following structure allows the detection of different
262 * architectures. We don't want to try to decode something from
263 * a 64 bit big endian encoded parsing tree on an i586 for
267 char ignore
[4 * 256/8]; /* Allow 256 bit machines */
269 unsigned long one
; /* value one */
270 unsigned long two
; /* value two */
271 void * ptr3
; /* value (void*)3, size may be different to unsigned */
272 void * ptr4
; /* value (void*)4 */
276 unsigned long OverallSize
; /* in byte of this structure and all dependencies */
278 unsigned long version
; /* INSTORE_VERSION */
280 /* We describe the sourcelines first */
281 unsigned long NumberOfSourceLines
;
282 unsigned long source
;
283 /* Offset to table of source lines. Imagine a value of 1000 and
284 * 5 source lines (previous value). This structure has an address
285 * of 500 in the memory (what you get from malloc or something else).
286 * Then: The table has 5 entries at position 1500 in memory.
287 * Each table entry is an offsrcline structure. The source string is the
288 * instore[0] string of RexxStart or another source string.
291 unsigned long NumberOfTreeElements
;
292 unsigned long TreeStart
; /* Within 0 .. (NumberOfTreeElements-1) */
294 /* Offset to table of nodes. Imagine a value of 2000 and
295 * 6 elements (NumberIfTreeElements). This structure has an address
296 * of 500 in the memory (what you get from malloc or something else).
297 * Then: The table has 6 treenodes at position 2500 in memory.
298 * Each table entry (treenode) must be relocated. Every nodeptr within a
299 * element is just an index within this table. If node->p[2] of one picked
300 * table entry is ((nodeptr) 4) then the address is calculated as follows:
301 * 500 + tree + (4*sizeof(treenode))
302 * This value should be assigned to node->p[2] to use the value in its
304 * A NULL value is represented by (nodeptr) (unsigned) -1.
305 * Every string within a treenode is relocated by adding 500. Imagine a
306 * value of 3000 for node->name. Then an extstring structure is located
307 * at 3500 in memory which represents the string's content.
309 } external_parser_type
;
311 typedef struct systeminfobox
*sysinfo
;
312 typedef const struct systeminfobox
*csysinfo
;
313 typedef struct systeminfobox
{
314 struct strengtype
*called_as
;
315 struct strengtype
*input_file
; /* must be 0-terminated without counting of the '\0' */
316 streng
*environment
;
322 proclevbox
*currlevel0
;
323 struct systeminfobox
*previous
;
325 int cstackcnt
, cstackmax
;
329 internal_parser_type tree
;
342 struct library_func
*first
;
343 struct entrypt
*funcs
;
344 struct library
*next
, *prev
;
347 #if !defined(DONT_TYPEDEF_PFN) && !defined(PFN_DEFINED)
348 typedef unsigned long (*PFN
)() ;
352 struct library_func
{
356 struct library
*lib
;
357 struct library_func
*next
, *prev
;
358 struct library_func
*forw
, *backw
;