a68g-types.h
1 //! @file a68g-types.h
2 //! @author J. Marcel van der Veer
3
4 //! @section Copyright
5 //!
6 //! This file is part of Algol68G - an Algol 68 compiler-interpreter.
7 //! Copyright 2001-2024 J. Marcel van der Veer [algol68g@xs4all.nl].
8
9 //! @section License
10 //!
11 //! This program is free software; you can redistribute it and/or modify it
12 //! under the terms of the GNU General Public License as published by the
13 //! Free Software Foundation; either version 3 of the License, or
14 //! (at your option) any later version.
15 //!
16 //! This program is distributed in the hope that it will be useful, but
17 //! WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
18 //! or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
19 //! more details. You should have received a copy of the GNU General Public
20 //! License along with this program. If not, see [http://www.gnu.org/licenses/].
21
22 //! @section Synopsis
23 //!
24 //! Internal type definitions.
25
26 #if !defined (__A68G_TYPES_H__)
27 #define __A68G_TYPES_H__
28
29 // Type definitions
30
31 #define COMPLEX_T double complex
32
33 typedef unt char BYTE_T;
34 typedef BYTE_T *A68_STRUCT;
35
36 typedef char BUFFER[BUFFER_SIZE + 1];
37 typedef int CHAR_T;
38 typedef int LEAP_T;
39 typedef MP_T A68_LONG[DEFAULT_DOUBLE_DIGITS + 2];
40 typedef struct A68_ARRAY A68_ARRAY;
41 typedef struct A68_BITS A68_BITS;
42 typedef struct A68_BOOL A68_BOOL;
43 typedef struct A68_BYTES A68_BYTES;
44 typedef struct A68_CHANNEL A68_CHANNEL;
45 typedef struct A68_CHAR A68_CHAR;
46 typedef struct A68_COLLITEM A68_COLLITEM;
47 typedef struct A68_FILE A68_FILE;
48 typedef struct A68_FORMAT A68_FORMAT;
49 typedef struct A68_HANDLE A68_HANDLE;
50 typedef struct A68_INT A68_INT;
51 typedef struct A68_LONG_BYTES A68_LONG_BYTES;
52 typedef struct A68_PROCEDURE A68_PROCEDURE;
53 typedef struct A68_REAL A68_REAL;
54 typedef struct A68_REF A68_REF, A68_ROW;
55 typedef struct A68_SOUND A68_SOUND;
56 typedef struct A68_STREAM A68_STREAM;
57 typedef struct A68_TUPLE A68_TUPLE;
58 typedef struct A68_UNION A68_UNION;
59 typedef struct ACTIVATION_RECORD ACTIVATION_RECORD;
60 typedef struct DEC_T DEC_T;
61 typedef struct DIAGNOSTIC_T DIAGNOSTIC_T;
62 typedef struct FILES_T FILES_T;
63 typedef struct GINFO_T GINFO_T;
64 typedef struct KEYWORD_T KEYWORD_T;
65 typedef struct LINE_T LINE_T;
66 typedef struct MODES_T MODES_T;
67 typedef struct MOID_T MOID_T;
68 typedef struct NODE_INFO_T NODE_INFO_T;
69 typedef struct OPTION_LIST_T OPTION_LIST_T;
70 typedef struct OPTIONS_T OPTIONS_T;
71 typedef struct PACK_T PACK_T;
72 typedef struct POSTULATE_T POSTULATE_T;
73 typedef struct PROP_T PROP_T;
74 typedef struct REFINEMENT_T REFINEMENT_T;
75 typedef struct SOID_T SOID_T;
76 typedef struct TABLE_T TABLE_T;
77 typedef struct TAG_T TAG_T;
78 typedef struct TOKEN_T TOKEN_T;
79 typedef unt FILE_T, MOOD_T;
80 typedef void GPROC (NODE_T *);
81
82 typedef PROP_T PROP_PROC (NODE_T *);
83
84 struct A68_REAL
85 {
86 STATUS_MASK_T status;
87 REAL_T value;
88 } ALIGNED;
89
90 struct DEC_T
91 {
92 char *text;
93 int level;
94 DEC_T *sub, *less, *more;
95 };
96
97 struct ACTIVATION_RECORD
98 {
99 ADDR_T static_link, dynamic_link, dynamic_scope, parameters;
100 NODE_T *node;
101 jmp_buf *jump_stat;
102 BOOL_T proc_frame;
103 int frame_no, frame_level, parameter_level;
104 #if defined (BUILD_PARALLEL_CLAUSE)
105 pthread_t thread_id;
106 #endif
107 };
108
109 struct PROP_T
110 {
111 PROP_PROC *unit;
112 NODE_T *source;
113 };
114
115 struct A68_STREAM
116 {
117 char *name;
118 FILE_T fd;
119 BOOL_T opened, writemood;
120 } ALIGNED;
121
122 struct DIAGNOSTIC_T
123 {
124 int attribute, number;
125 NODE_T *where;
126 LINE_T *line;
127 char *text, *symbol;
128 DIAGNOSTIC_T *next;
129 };
130
131 struct FILES_T
132 {
133 char *path, *initial_name, *generic_name;
134 struct A68_STREAM binary, diags, plugin, script, object, source, listing, pretty;
135 };
136
137 struct KEYWORD_T
138 {
139 int attribute;
140 char *text;
141 KEYWORD_T *less, *more;
142 };
143
144 struct MODES_T
145 {
146 MOID_T *BITS, *BOOL, *BYTES, *CHANNEL, *CHAR, *COLLITEM, *COMPL, *COMPLEX,
147 *C_STRING, *ERROR, *FILE, *FORMAT, *HEX_NUMBER, *HIP, *INT, *LONG_BITS, *LONG_BYTES,
148 *LONG_COMPL, *LONG_COMPLEX, *LONG_INT, *LONG_LONG_BITS, *LONG_LONG_COMPL,
149 *LONG_LONG_COMPLEX, *LONG_LONG_INT, *LONG_LONG_REAL, *LONG_REAL, *NUMBER, *PIPE,
150 *PROC_REAL_REAL, *PROC_LONG_REAL_LONG_REAL, *PROC_REF_FILE_BOOL, *PROC_REF_FILE_VOID, *PROC_ROW_CHAR,
151 *PROC_STRING, *PROC_VOID, *REAL, *REF_BITS, *REF_BOOL, *REF_BYTES,
152 *REF_CHAR, *REF_COMPL, *REF_COMPLEX, *REF_FILE, *REF_FORMAT, *REF_INT,
153 *REF_LONG_BITS, *REF_LONG_BYTES, *REF_LONG_COMPL, *REF_LONG_COMPLEX,
154 *REF_LONG_INT, *REF_LONG_LONG_BITS, *REF_LONG_LONG_COMPL,
155 *REF_LONG_LONG_COMPLEX, *REF_LONG_LONG_INT, *REF_LONG_LONG_REAL, *REF_LONG_REAL,
156 *REF_PIPE, *REF_REAL, *REF_REF_FILE, *REF_ROW_CHAR, *REF_ROW_COMPLEX, *REF_ROW_INT,
157 *REF_ROW_REAL, *REF_ROW_ROW_COMPLEX, *REF_ROW_ROW_REAL, *REF_SOUND, *REF_STRING,
158 *ROW_BITS, *ROW_BOOL, *ROW_CHAR, *ROW_COMPLEX, *ROW_INT, *ROW_LONG_BITS, *ROW_LONG_LONG_BITS,
159 *ROW_REAL, *ROW_ROW_CHAR, *ROW_ROW_COMPLEX, *ROW_ROW_REAL, *ROWS, *ROW_SIMPLIN, *ROW_SIMPLOUT,
160 *ROW_STRING, *SEMA, *SIMPLIN, *SIMPLOUT, *SOUND, *SOUND_DATA, *STRING, *FLEX_ROW_CHAR,
161 *FLEX_ROW_BOOL, *UNDEFINED, *VACUUM, *VOID;
162 };
163
164 struct OPTIONS_T
165 {
166 OPTION_LIST_T *list;
167 BOOL_T backtrace, brackets, check_only, clock, cross_reference, debug, compile, compile_check, keep, fold, license, moid_listing, object_listing, portcheck, pragmat_sema, pretty, reductions, regression_test, run, rerun, run_script, source_listing, standard_prelude_listing, statistics_listing, strict, stropping, trace, tree_listing, unused, verbose, version, no_warnings, quiet;
168 int time_limit, opt_level, indent;
169 STATUS_MASK_T nodemask;
170 };
171
172 struct MOID_T
173 {
174 int attribute, dim, number, short_id, size, digits, size_compl, digits_compl;
175 BOOL_T has_rows, use, portable, derivate;
176 NODE_T *node;
177 PACK_T *pack;
178 MOID_T *sub, *equivalent_mode, *slice, *deflexed_mode, *name, *multiple_mode, *next, *rowed, *trim;
179 };
180 #define NO_MOID ((MOID_T *) NULL)
181
182 struct NODE_T
183 {
184 GINFO_T *genie;
185 int number, attribute, annotation;
186 MOID_T *type;
187 NODE_INFO_T *info;
188 NODE_T *next, *previous, *sub, *sequence, *nest;
189 PACK_T *pack;
190 STATUS_MASK_T status, codex;
191 TABLE_T *symbol_table, *non_local;
192 TAG_T *tag;
193 };
194 #define NO_NODE ((NODE_T *) NULL)
195
196 struct NODE_INFO_T
197 {
198 int procedure_level, priority, pragment_type;
199 char *char_in_line, *symbol, *pragment, *expr;
200 LINE_T *line;
201 };
202
203 struct GINFO_T
204 {
205 PROP_T propagator;
206 BOOL_T is_coercion, is_new_lexical_level, need_dns;
207 BYTE_T *offset;
208 MOID_T *partial_proc, *partial_locale;
209 NODE_T *parent;
210 char *compile_name;
211 int level, argsize, size, compile_node;
212 void *constant;
213 };
214
215 struct OPTION_LIST_T
216 {
217 char *str;
218 int scan;
219 BOOL_T processed;
220 LINE_T *line;
221 OPTION_LIST_T *next;
222 };
223
224 struct PACK_T
225 {
226 MOID_T *type;
227 char *text;
228 NODE_T *node;
229 PACK_T *next, *previous;
230 int size;
231 ADDR_T offset;
232 };
233
234 struct POSTULATE_T
235 {
236 MOID_T *a, *b;
237 POSTULATE_T *next;
238 };
239
240 struct REFINEMENT_T
241 {
242 REFINEMENT_T *next;
243 char *name;
244 LINE_T *line_defined, *line_applied;
245 int applications;
246 NODE_T *node_defined, *begin, *end;
247 };
248
249 struct SOID_T
250 {
251 int attribute, sort, cast;
252 MOID_T *type;
253 NODE_T *node;
254 SOID_T *next;
255 };
256
257 struct LINE_T
258 {
259 char marker[6], *string, *filename;
260 DIAGNOSTIC_T *diagnostics;
261 int number, print_status;
262 BOOL_T list;
263 LINE_T *next, *previous;
264 };
265 #define NO_LINE ((LINE_T *) NULL)
266
267 struct TABLE_T
268 {
269 int num, level, nest, attribute;
270 BOOL_T initialise_frame, initialise_anon, proc_ops;
271 ADDR_T ap_increment;
272 TABLE_T *previous, *outer;
273 TAG_T *identifiers, *operators, *priority, *indicants, *labels, *anonymous;
274 NODE_T *jump_to, *sequence;
275 };
276 #define NO_TABLE ((TABLE_T *) NULL)
277
278 struct TAG_T
279 {
280 STATUS_MASK_T status, codex;
281 TABLE_T *symbol_table;
282 MOID_T *type;
283 NODE_T *node, *unit;
284 char *value;
285 GPROC *procedure;
286 BOOL_T scope_assigned, use, in_proc, a68_standenv_proc, loc_assigned, portable;
287 int priority, heap, scope, size, youngest_environ, number;
288 ADDR_T offset;
289 TAG_T *next, *body;
290 };
291 #define NO_TAG ((TAG_T *) NULL)
292
293 struct TOKEN_T
294 {
295 char *text;
296 TOKEN_T *less, *more;
297 };
298
299 //! @struct A68_HANDLE
300 //! @brief Handle for REF into the HEAP.
301 //! @details
302 //! A REF into the HEAP points at a HANDLE.
303 //! The HANDLE points at the actual object in the HEAP.
304 //! Garbage collection modifies HANDLEs, but not REFs.
305
306 struct A68_HANDLE
307 {
308 STATUS_MASK_T status;
309 BYTE_T *pointer;
310 int size;
311 MOID_T *type;
312 A68_HANDLE *next, *previous;
313 } ALIGNED;
314
315 //! @struct A68_REF
316 //! @brief Fat A68 pointer.
317
318 struct A68_REF
319 {
320 STATUS_MASK_T status;
321 ADDR_T offset;
322 ADDR_T scope; // Dynamic scope.
323 A68_HANDLE *handle;
324 } ALIGNED;
325
326 //! @struct A68_ARRAY
327 //! @brief A68 array descriptor.
328 //! @details
329 //! A row is an A68_REF to an A68_ARRAY.
330 //!
331 //! An A68_ARRAY is followed by one A68_TUPLE per dimension.
332 //!
333 //! @verbatim
334 //! A68_REF row -> A68_ARRAY ----+ ARRAY: Description of row, ref to elements.
335 //! A68_TUPLE 1 | TUPLE: Bounds, one for every dimension.
336 //! ... |
337 //! A68_TUPLE dim |
338 //! ... |
339 //! ... |
340 //! Element 1 <---+ Sequential row elements in the heap.
341 //! ...
342 //! Element n
343 //! @endverbatim
344
345 struct A68_ARRAY
346 {
347 MOID_T *type;
348 int dim, elem_size;
349 ADDR_T slice_offset, field_offset;
350 A68_REF array;
351 } ALIGNED;
352
353 struct A68_BITS
354 {
355 STATUS_MASK_T status;
356 UNSIGNED_T value;
357 } ALIGNED;
358
359 struct A68_BYTES
360 {
361 STATUS_MASK_T status;
362 char value[A68_BYTES_WIDTH + 1];
363 } ALIGNED;
364
365 struct A68_CHANNEL
366 {
367 STATUS_MASK_T status;
368 BOOL_T reset, set, get, put, bin, draw, compress;
369 } ALIGNED;
370
371 struct A68_BOOL
372 {
373 STATUS_MASK_T status;
374 BOOL_T value;
375 } ALIGNED;
376
377 struct A68_CHAR
378 {
379 STATUS_MASK_T status;
380 CHAR_T value;
381 } ALIGNED;
382
383 struct A68_COLLITEM
384 {
385 STATUS_MASK_T status;
386 int count;
387 };
388
389 struct A68_INT
390 {
391 STATUS_MASK_T status;
392 INT_T value;
393 } ALIGNED;
394
395 //! @struct A68_FORMAT
396 //! @brief A68 format descriptor.
397 //! @details
398 //! A format behaves very much like a procedure.
399
400 struct A68_FORMAT
401 {
402 STATUS_MASK_T status;
403 NODE_T *body; // Entry point in syntax tree.
404 ADDR_T fp_environ; // Frame pointer to environ.
405 } ALIGNED;
406
407 struct A68_LONG_BYTES
408 {
409 STATUS_MASK_T status;
410 char value[A68_LONG_BYTES_WIDTH + 1];
411 } ALIGNED;
412
413 //! @struct A68_PROCEDURE
414 //! @brief A68 procedure descriptor.
415
416 struct A68_PROCEDURE
417 {
418 STATUS_MASK_T status;
419 union
420 {
421 NODE_T *node;
422 GPROC *procedure;
423 } body; // Entry point in syntax tree or precompiled C procedure.
424 A68_HANDLE *locale; // Locale for partial parametrisation.
425 MOID_T *type;
426 ADDR_T fp_environ; // Frame pointer to environ.
427 } ALIGNED;
428
429 typedef A68_REAL A68_COMPLEX[2];
430
431 //! @struct A68_TUPLE
432 //! @brief A tuple containing bounds etcetera for one dimension.
433
434 struct A68_TUPLE
435 {
436 INT_T upper_bound, lower_bound, shift, span, k;
437 } ALIGNED;
438
439 struct A68_UNION
440 {
441 STATUS_MASK_T status;
442 void *value;
443 } ALIGNED;
444
445 struct A68_SOUND
446 {
447 STATUS_MASK_T status;
448 unt num_channels, sample_rate, bits_per_sample, num_samples, data_size;
449 A68_REF data;
450 };
451
452 struct A68_FILE
453 {
454 STATUS_MASK_T status;
455 A68_CHANNEL channel;
456 A68_FORMAT format;
457 A68_PROCEDURE file_end_mended, page_end_mended, line_end_mended, value_error_mended, open_error_mended, transput_error_mended, format_end_mended, format_error_mended;
458 A68_REF identification, terminator, string;
459 ADDR_T frame_pointer, stack_pointer; // Since formats open frames
460 BOOL_T read_mood, write_mood, char_mood, draw_mood, opened, open_exclusive, end_of_file, tmp_file;
461 FILE_T fd;
462 int transput_buffer, strpos, file_entry;
463 struct
464 {
465 FILE *stream;
466 #if defined (HAVE_GNU_PLOTUTILS)
467 plPlotter *plotter;
468 plPlotterParams *plotter_params;
469 #endif
470 BOOL_T device_made, device_opened;
471 A68_REF device, page_size;
472 int device_handle /* deprecated */ , window_x_size, window_y_size;
473 REAL_T x_coord, y_coord, red, green, blue;
474 }
475 device;
476 #if defined (HAVE_POSTGRESQL)
477 # if ! defined (A68_OPTIMISE)
478 PGconn *connection;
479 PGresult *result;
480 # endif
481 #endif
482 };
483
484 #define M_BITS (MODE (BITS))
485 #define M_BOOL (MODE (BOOL))
486 #define M_BYTES (MODE (BYTES))
487 #define M_CHANNEL (MODE (CHANNEL))
488 #define M_CHAR (MODE (CHAR))
489 #define M_COLLITEM (MODE (COLLITEM))
490 #define M_COMPLEX (MODE (COMPLEX))
491 #define M_COMPL (MODE (COMPL))
492 #define M_C_STRING (MODE (C_STRING))
493 #define M_ERROR (MODE (ERROR))
494 #define M_FILE (MODE (FILE))
495 #define M_FLEX_ROW_BOOL (MODE (FLEX_ROW_BOOL))
496 #define M_FLEX_ROW_CHAR (MODE (FLEX_ROW_CHAR))
497 #define M_FORMAT (MODE (FORMAT))
498 #define M_HEX_NUMBER (MODE (HEX_NUMBER))
499 #define M_HIP (MODE (HIP))
500 #define M_INT (MODE (INT))
501 #define M_LONG_BITS (MODE (LONG_BITS))
502 #define M_LONG_BYTES (MODE (LONG_BYTES))
503 #define M_LONG_COMPLEX (MODE (LONG_COMPLEX))
504 #define M_LONG_COMPL (MODE (LONG_COMPL))
505 #define M_LONG_INT (MODE (LONG_INT))
506 #define M_LONG_LONG_BITS (MODE (LONG_LONG_BITS))
507 #define M_LONG_LONG_COMPLEX (MODE (LONG_LONG_COMPLEX))
508 #define M_LONG_LONG_COMPL (MODE (LONG_LONG_COMPL))
509 #define M_LONG_LONG_INT (MODE (LONG_LONG_INT))
510 #define M_LONG_LONG_REAL (MODE (LONG_LONG_REAL))
511 #define M_LONG_REAL (MODE (LONG_REAL))
512 #define M_NIL (MODE (NIL))
513 #define M_NUMBER (MODE (NUMBER))
514 #define M_PIPE (MODE (PIPE))
515 #define M_PROC_LONG_REAL_LONG_REAL (MODE (PROC_LONG_REAL_LONG_REAL))
516 #define M_PROC_REAL_REAL (MODE (PROC_REAL_REAL))
517 #define M_PROC_REF_FILE_BOOL (MODE (PROC_REF_FILE_BOOL))
518 #define M_PROC_REF_FILE_VOID (MODE (PROC_REF_FILE_VOID))
519 #define M_PROC_ROW_CHAR (MODE (PROC_ROW_CHAR))
520 #define M_PROC_STRING (MODE (PROC_STRING))
521 #define M_PROC_VOID (MODE (PROC_VOID))
522 #define M_REAL (MODE (REAL))
523 #define M_REF_BITS (MODE (REF_BITS))
524 #define M_REF_BOOL (MODE (REF_BOOL))
525 #define M_REF_BYTES (MODE (REF_BYTES))
526 #define M_REF_CHAR (MODE (REF_CHAR))
527 #define M_REF_COMPLEX (MODE (REF_COMPLEX))
528 #define M_REF_COMPL (MODE (REF_COMPL))
529 #define M_REF_FILE (MODE (REF_FILE))
530 #define M_REF_FORMAT (MODE (REF_FORMAT))
531 #define M_REF_INT (MODE (REF_INT))
532 #define M_REF_LONG_BITS (MODE (REF_LONG_BITS))
533 #define M_REF_LONG_BYTES (MODE (REF_LONG_BYTES))
534 #define M_REF_LONG_COMPLEX (MODE (REF_LONG_COMPLEX))
535 #define M_REF_LONG_COMPL (MODE (REF_LONG_COMPL))
536 #define M_REF_LONG_INT (MODE (REF_LONG_INT))
537 #define M_REF_LONG_LONG_COMPLEX (MODE (REF_LONG_LONG_COMPLEX))
538 #define M_REF_LONG_LONG_COMPL (MODE (REF_LONG_LONG_COMPL))
539 #define M_REF_LONG_LONG_INT (MODE (REF_LONG_LONG_INT))
540 #define M_REF_LONG_LONG_REAL (MODE (REF_LONG_LONG_REAL))
541 #define M_REF_LONG_REAL (MODE (REF_LONG_REAL))
542 #define M_REF_PIPE (MODE (REF_PIPE))
543 #define M_REF_REAL (MODE (REF_REAL))
544 #define M_REF_REF_FILE (MODE (REF_REF_FILE))
545 #define M_REF_ROW_CHAR (MODE (REF_ROW_CHAR))
546 #define M_REF_ROW_COMPLEX (MODE (REF_ROW_COMPLEX))
547 #define M_REF_ROW_INT (MODE (REF_ROW_INT))
548 #define M_REF_ROW_REAL (MODE (REF_ROW_REAL))
549 #define M_REF_ROW_ROW_COMPLEX (MODE (REF_ROW_ROW_COMPLEX))
550 #define M_REF_ROW_ROW_REAL (MODE (REF_ROW_ROW_REAL))
551 #define M_REF_SOUND (MODE (REF_SOUND))
552 #define M_REF_STRING (MODE (REF_STRING))
553 #define M_ROW_BITS (MODE (ROW_BITS))
554 #define M_ROW_BOOL (MODE (ROW_BOOL))
555 #define M_ROW_CHAR (MODE (ROW_CHAR))
556 #define M_ROW_COMPLEX (MODE (ROW_COMPLEX))
557 #define M_ROW_INT (MODE (ROW_INT))
558 #define M_ROW_LONG_BITS (MODE (ROW_LONG_BITS))
559 #define M_ROW_LONG_LONG_BITS (MODE (ROW_LONG_LONG_BITS))
560 #define M_ROW_REAL (MODE (ROW_REAL))
561 #define M_ROW_ROW_CHAR (MODE (ROW_ROW_CHAR))
562 #define M_ROW_ROW_COMPLEX (MODE (ROW_ROW_COMPLEX))
563 #define M_ROW_ROW_REAL (MODE (ROW_ROW_REAL))
564 #define M_ROW_SIMPLIN (MODE (ROW_SIMPLIN))
565 #define M_ROW_SIMPLOUT (MODE (ROW_SIMPLOUT))
566 #define M_ROWS (MODE (ROWS))
567 #define M_ROW_STRING (MODE (ROW_STRING))
568 #define M_SEMA (MODE (SEMA))
569 #define M_SIMPLIN (MODE (SIMPLIN))
570 #define M_SIMPLOUT (MODE (SIMPLOUT))
571 #define M_SOUND_DATA (MODE (SOUND_DATA))
572 #define M_SOUND (MODE (SOUND))
573 #define M_STRING (MODE (STRING))
574 #define M_UNDEFINED (MODE (UNDEFINED))
575 #define M_VACUUM (MODE (VACUUM))
576 #define M_VOID (MODE (VOID))
577
578 #endif
© 2002-2024 J.M. van der Veer (jmvdveer@xs4all.nl)
|