forked from vermaseren/form
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstructs.h
2531 lines (2358 loc) · 100 KB
/
structs.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/** @file structs.h
*
* Contains definitions for global structs.
*
* !!!CAUTION!!!
* Changes in this file will most likely have consequences for the recovery
* mechanism (see checkpoint.c). You need to care for the code in checkpoint.c
* as well and modify the code there accordingly!
*
* The marker [D] is used in comments in this file to mark pointers to which
* dynamically allocated memory is assigned by a call to malloc() during
* runtime (in contrast to pointers that point into already allocated memory).
* This information is especially helpful if one needs to know which pointers
* need to be freed (cf. checkpoint.c).
*/
/* #[ License : */
/*
* Copyright (C) 1984-2022 J.A.M. Vermaseren
* When using this file you are requested to refer to the publication
* J.A.M.Vermaseren "New features of FORM" math-ph/0010025
* This is considered a matter of courtesy as the development was paid
* for by FOM the Dutch physics granting agency and we would like to
* be able to track its scientific use to convince FOM of its value
* for the community.
*
* This file is part of FORM.
*
* FORM is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* FORM is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along
* with FORM. If not, see <http://www.gnu.org/licenses/>.
*/
/* #] License : */
#ifndef __STRUCTS__
#define __STRUCTS__
#ifdef _MSC_VER
#include <wchar.h> /* off_t */
#endif
/*
#[ sav&store :
*/
/**
*
*/
typedef struct PoSiTiOn {
off_t p1;
} POSITION;
/* Next are the index structs for stored and saved expressions */
/**
* Defines the structure of the file header for store-files and save-files.
*
* The first 8 bytes serve as a unique mark to identity save-files that
* contain such a header. Older versions of FORM don't have this header and
* will write the POSITION of the next file index (struct FiLeInDeX) here,
* which is always different from this pattern.
*
* It is always 512 bytes long.
*/
typedef struct {
UBYTE headermark[8]; /**< Pattern for header identification. Old versions
of FORM have a maximum sizeof(POSITION) of 8 */
UBYTE lenWORD; /**< Number of bytes for WORD */
UBYTE lenLONG; /**< Number of bytes for LONG */
UBYTE lenPOS; /**< Number of bytes for POSITION */
UBYTE lenPOINTER; /**< Number of bytes for void * */
UBYTE endianness[16]; /**< Used to determine endianness, sizeof(int) should be <= 16 */
UBYTE sSym; /**< sizeof(struct SyMbOl) */
UBYTE sInd; /**< sizeof(struct InDeX) */
UBYTE sVec; /**< sizeof(struct VeCtOr) */
UBYTE sFun; /**< sizeof(struct FuNcTiOn) */
UBYTE maxpower[16]; /**< Maximum power, see #MAXPOWER */
UBYTE wildoffset[16]; /**< #WILDOFFSET macro */
UBYTE revision; /**< Revision number of save-file system */
UBYTE reserved[512-8-4-16-4-16-16-1]; /**< Padding to 512 bytes */
} STOREHEADER;
STATIC_ASSERT(sizeof(STOREHEADER) == 512);
/**
* Defines the structure of an entry in a file index (see struct FiLeInDeX).
*
* It represents one expression in the file.
*/
typedef struct InDeXeNtRy {
POSITION position; /**< Position of the expression itself */
POSITION length; /**< Length of the expression itself */
POSITION variables; /**< Position of the list with variables */
LONG CompressSize; /**< Size of buffer before compress */
WORD nsymbols; /**< Number of symbols in the list */
WORD nindices; /**< Number of indices in the list */
WORD nvectors; /**< Number of vectors in the list */
WORD nfunctions; /**< Number of functions in the list */
WORD size; /**< Size of variables field */
SBYTE name[MAXENAME+1]; /**< Name of expression */
PADPOSITION(0,1,0,5,MAXENAME+1);
} INDEXENTRY;
/**
* Maximum number of entries (struct InDeXeNtRy) in a file index (struct
* FiLeInDeX). Number is calculated such that the size of a file index is no
* more than 512 bytes.
*/
#define INFILEINDEX ((512-2*sizeof(POSITION))/sizeof(INDEXENTRY))
/**
* Number of empty filling bytes for a file index (struct FiLeInDeX). It is
* calculated such that the size of a file index is always 512 bytes.
*/
#define EMPTYININDEX (512-2*sizeof(POSITION)-INFILEINDEX*sizeof(INDEXENTRY))
/**
* Defines the structure of a file index in store-files and save-files.
*
* It contains several entries (see struct InDeXeNtRy) up to a maximum of
* #INFILEINDEX.
*
* The variable number has been made of type POSITION to avoid padding
* problems with some types of computers/OS and keep system independence
* of the .sav files.
*
* This struct is always 512 bytes long.
*/
typedef struct FiLeInDeX {
POSITION next; /**< Position of next FILEINDEX if any */
POSITION number; /**< Number of used entries in this index */
INDEXENTRY expression[INFILEINDEX]; /**< File index entries */
SBYTE empty[EMPTYININDEX]; /**< Padding to 512 bytes */
} FILEINDEX;
STATIC_ASSERT(sizeof(FILEINDEX) == 512);
/**
*
*/
typedef struct FiLeDaTa {
FILEINDEX Index;
POSITION Fill;
POSITION Position;
WORD Handle;
WORD dirtyflag;
PADPOSITION(0,0,0,2,0);
} FILEDATA;
/**
*
* Contains the pointers to an array in which a binary search will be
* performed.
*/
typedef struct VaRrEnUm {
WORD *start; /**< Start point for search. Points inbetween lo and hi */
WORD *lo; /**< Start of memory area */
WORD *hi; /**< End of memory area */
} VARRENUM;
/**
*
* Only symb.lo gets dynamically allocated. All other pointers points into this
* memory.
*/
typedef struct ReNuMbEr {
POSITION startposition;
/* First stage renumbering */
VARRENUM symb; /**< Symbols */
VARRENUM indi; /**< Indices */
VARRENUM vect; /**< Vectors */
VARRENUM func; /**< Functions */
/* Second stage renumbering */
WORD *symnum; /**< Renumbered symbols */
WORD *indnum; /**< Renumbered indices */
WORD *vecnum; /**< Renumbered vectors */
WORD *funnum; /**< Renumbered functions */
PADPOSITION(4,0,0,0,sizeof(VARRENUM)*4);
} *RENUMBER;
/*
#] sav&store :
#[ Variables :
*/
/**
* Much information is stored in arrays of which we can double the size
* if the array proves to be too small. Such arrays are controled by
* a variable of type #LIST. The routines that expand the lists are in the
* file tools.c
*/
typedef struct {
void *lijst; /**< [D] Holds space for "maxnum" elements of size "size" each */
char *message; /**< Text for Malloc1 when allocating lijst. Set to constant string. */
int num; /**< Number of elements in lijst. */
int maxnum; /**< Maximum number of elements in lijst. */
int size; /**< Size of one element in lijst. */
int numglobal; /**< Marker for position when .global is executed. */
int numtemp; /**< At the moment only needed for sets and setstore. */
int numclear; /**< Only for the clear instruction. */
PADPOINTER(0,6,0,0);
} LIST;
/**
* The KEYWORD struct defines names of commands/statements and the routine
* to be called when they are encountered by the compiler or preprocessor.
*/
typedef struct {
char *name;
TFUN func;
int type;
int flags;
} KEYWORD;
/**
* The KEYWORDV struct defines names of commands/statements and the variable
* to be affected when they are encountered by the compiler or preprocessor.
*/
typedef struct {
char *name;
int *var;
int type;
int flags;
} KEYWORDV;
/**
* The names of variables are kept in an array. Elements of type #NAMENODE
* define a tree (that is kept balanced) that make it easy and fast to look for
* variables. See also #NAMETREE.
*/
typedef struct NaMeNode {
LONG name; /**< Offset into NAMETREE::namebuffer. */
WORD parent; /**< =-1 if no parent. */
WORD left; /**< =-1 if no child. */
WORD right; /**< =-1 if no child. */
WORD balance; /**< Used for the balancing of the tree. */
WORD type; /**< Type associated with the name. See @ref CompilerTypes "compiler types". */
WORD number; /**< Number of variable in #LIST's like for example C_const::SymbolList. */
PADLONG(0,6,0);
} NAMENODE;
/**
* A struct of type #NAMETREE controls a complete (balanced) tree of names
* for the compiler. The compiler maintains several of such trees and the
* system has been set up in such a way that one could define more of them
* if we ever want to work with local name spaces.
*/
typedef struct NaMeTree {
NAMENODE *namenode; /**< [D] Vector of #NAMENODE's. Number of elements is #nodesize.
=0 if no memory has been allocated. */
UBYTE *namebuffer; /**< [D] Buffer that holds all the name strings refered to by the
NAMENODE's. Allocation size is #namesize. =0 if no memory
has been allocated. */
LONG nodesize; /**< Maximum number of elements in #namenode. */
LONG nodefill; /**< Number of currently used nodes in #namenode. */
LONG namesize; /**< Allocation size of #namebuffer in bytes. */
LONG namefill; /**< Number of bytes occupied. */
LONG oldnamefill; /**< UNUSED */
LONG oldnodefill; /**< UNUSED */
LONG globalnamefill; /**< Set by .global statement to the value of #namefill. When a .store
command is processed, this value will be used to reset namefill.*/
LONG globalnodefill; /**< Same usage as #globalnamefill, but for nodefill. */
LONG clearnamefill; /**< Marks the reset point used by the .clear statement. */
LONG clearnodefill; /**< Marks the reset point used by the .clear statement. */
WORD headnode; /**< Offset in #namenode of head node. =-1 if tree is empty. */
PADPOINTER(10,0,1,0);
} NAMETREE;
/**
* The subexpressions in the compiler are kept track of in a (balanced) tree
* to reduce the need for subexpressions and hence save much space in
* large rhs expressions (like when we have xxxxxxx occurrences of objects
* like f(x+1,x+1) in which each x+1 becomes a subexpression.
* The struct that controls this tree is COMPTREE.
*/
typedef struct tree {
int parent; /**< Index of parent */
int left; /**< Left child (if not -1) */
int right; /**< Right child (if not -1) */
int value; /**< The object to be sorted and searched */
int blnce; /**< Balance factor */
int usage; /**< Number of uses in some types of trees */
} COMPTREE;
/**
*
*/
typedef struct MiNmAx {
WORD mini; /**< Minimum value */
WORD maxi; /**< Maximum value */
WORD size; /**< Value of one unit in this position. */
} MINMAX;
/**
*
*/
typedef struct BrAcKeTiNdEx { /* For indexing brackets in local expressions */
POSITION start; /* Place where bracket starts - start of expr */
POSITION next; /* Place of next indexed bracket in expr */
LONG bracket; /* Offset of position in bracketbuffer */
LONG termsinbracket;
PADPOSITION(0,2,0,0,0);
} BRACKETINDEX;
/**
*
*/
typedef struct BrAcKeTiNfO {
BRACKETINDEX *indexbuffer; /**< [D] */
WORD *bracketbuffer; /**< [D] */
LONG bracketbuffersize;
LONG indexbuffersize;
LONG bracketfill;
LONG indexfill;
WORD SortType; /**< The sorting criterium used (like POWERFIRST etc) */
PADPOINTER(4,0,1,0);
} BRACKETINFO;
/**
*
* buffers, mm, flags, and prototype are always dynamically allocated,
* tablepointers only if needed (=0 if unallocated),
* boomlijst and argtail only for sparse tables.
*
* Allocation is done for both the normal and the stub instance (spare),
* except for prototype and argtail which share memory.
*/
typedef struct TaBlEs {
WORD *tablepointers; /**< [D] Start in tablepointers table. */
#ifdef WITHPTHREADS
WORD **prototype; /**< [D] The wildcard prototyping for arguments */
WORD **pattern; /**< The pattern with which to match the arguments */
#else
WORD *prototype; /**< [D] The wildcard prototyping for arguments */
WORD *pattern; /**< The pattern with which to match the arguments */
#endif
MINMAX *mm; /**< [D] Array bounds, dimension by dimension. # elements = numind. */
WORD *flags; /**< [D] Is element in use ? etc. # elements = numind. */
COMPTREE *boomlijst; /**< [D] Tree for searching in sparse tables */
UBYTE *argtail; /**< [D] The arguments in characters. Starts for tablebase
with parenthesis to indicate tail */
struct TaBlEs *spare; /**< [D] For tablebase. Alternatingly stubs and real */
WORD *buffers; /**< [D] When we use more than one compiler buffer. */
LONG totind; /**< Total number requested */
LONG reserved; /**< Total reservation in tablepointers for sparse */
LONG defined; /**< Number of table elements that are defined */
LONG mdefined; /**< Same as defined but after .global */
int prototypeSize; /**< Size of allocated memory for prototype in bytes. */
int numind; /**< Number of array indices */
int bounds; /**< Array bounds check on/off. */
int strict; /**< >0: all must be defined. <0: undefined not substitute */
int sparse; /**< > 0 --> sparse table */
int numtree; /**< For the tree for sparse tables */
int rootnum; /**< For the tree for sparse tables */
int MaxTreeSize; /**< For the tree for sparse tables */
WORD bufnum; /**< Each table potentially its own buffer */
WORD bufferssize; /**< When we use more than one compiler buffer */
WORD buffersfill; /**< When we use more than one compiler buffer */
WORD tablenum; /**< For testing of tableuse */
WORD mode; /**< 0: normal, 1: stub */
WORD numdummies; /**< */
PADPOINTER(4,8,6,0);
} *TABLES;
/**
*
*/
typedef struct ExPrEsSiOn {
POSITION onfile;
POSITION prototype;
POSITION size;
RENUMBER renum; /* For Renumbering of global stored expressions */
BRACKETINFO *bracketinfo;
BRACKETINFO *newbracketinfo;
WORD *renumlists; /**< Allocated only for threaded version if variables exist,
else points to AN.dummyrenumlist */
WORD *inmem; /* If in memory like e.g. a polynomial */
LONG counter;
LONG name;
WORD hidelevel;
WORD vflags; /* Various flags */
WORD printflag;
WORD status;
WORD replace;
WORD node;
WORD whichbuffer;
WORD namesize;
WORD compression;
WORD numdummies;
WORD numfactors;
WORD sizeprototype;
#ifdef PARALLELCODE
WORD partodo; /* Whether to be done in parallel mode */
PADPOSITION(5,2,0,13,0);
#else
PADPOSITION(5,2,0,12,0);
#endif
} *EXPRESSIONS;
/**
*
*/
typedef struct SyMbOl { /* Don't change unless altering .sav too */
LONG name; /* Location in names buffer */
WORD minpower; /* Minimum power admissible */
WORD maxpower; /* Maximum power admissible */
WORD complex; /* Properties wrt complex conjugation */
WORD number; /* Number when stored in file */
WORD flags; /* Used to indicate usage when storing */
WORD node;
WORD namesize;
WORD dimension; /* For dimensionality checks */
PADLONG(0,8,0);
} *SYMBOLS;
/**
*
*/
typedef struct InDeX { /* Don't change unless altering .sav too */
LONG name; /* Location in names buffer */
WORD type; /* Regular or dummy */
WORD dimension; /* Value of d_(n,n) or -number of symbol */
WORD number; /* Number when stored in file */
WORD flags; /* Used to indicate usage when storing */
WORD nmin4; /* Used for n-4 if dimension < 0 */
WORD node;
WORD namesize;
PADLONG(0,7,0);
} *INDICES;
/**
*
*/
typedef struct VeCtOr { /* Don't change unless altering .sav too */
LONG name; /* Location in names buffer */
WORD complex; /* Properties under complex conjugation */
WORD number; /* Number when stored in file */
WORD flags; /* Used to indicate usage when storing */
WORD node;
WORD namesize;
WORD dimension; /* For dimensionality checks */
PADLONG(0,6,0);
} *VECTORS;
/**
* Contains all information about a function. Also used for tables.
* It is used in the #LIST elements of #AC.
*/
typedef struct FuNcTiOn { /* Don't change unless altering .sav too */
TABLES tabl; /**< Used if redefined as table. != 0 if function is a table */
LONG symminfo; /**< Info regarding symm properties offset in buffer */
LONG name; /**< Location in namebuffer of #NAMETREE */
WORD commute; /**< Commutation properties */
WORD complex; /**< Properties under complex conjugation */
WORD number; /**< Number when stored in file */
WORD flags; /**< Used to indicate usage when storing */
WORD spec; /**< Regular, Tensor, etc. See @ref FunSpecs. */
WORD symmetric; /**< > 0 if symmetric properties */
WORD node; /**< Location in namenode of #NAMETREE */
WORD namesize; /**< Length of the name */
WORD dimension; /* For dimensionality checks */
WORD maxnumargs;
WORD minnumargs;
PADPOINTER(2,0,11,0);
} *FUNCTIONS;
/**
*
*/
typedef struct SeTs {
LONG name; /* Location in names buffer */
WORD type; /* Symbol, vector, index or function */
WORD first; /* First element in setstore */
WORD last; /* Last element in setstore (excluding) */
WORD node;
WORD namesize;
WORD dimension; /* For dimensionality checks */
WORD flags; /* Like: ordered */
PADLONG(0,7,0);
} *SETS;
/**
*
*/
typedef struct DuBiOuS { /* Undeclared objects. Just for compiler. */
LONG name; /* Location in names buffer */
WORD node;
WORD dummy;
PADLONG(0,2,0);
} *DUBIOUSV;
typedef struct FaCdOlLaR {
WORD *where; /* A pointer(!) to the content */
LONG size;
WORD type; /* Type can be DOLNUMBER or DOLTERMS */
WORD value; /* in case it is a (short) number */
PADPOINTER(1,0,2,0);
} FACDOLLAR;
typedef struct DoLlArS {
WORD *where; /* A pointer(!) to the object */
FACDOLLAR *factors; /* an array of factors. nfactors elements */
#ifdef WITHPTHREADS
pthread_mutex_t pthreadslockread;
pthread_mutex_t pthreadslockwrite;
#endif
LONG size; /* The number of words */
LONG name;
WORD type;
WORD node;
WORD index;
WORD zero;
WORD numdummies;
WORD nfactors;
#ifdef WITHPTHREADS
PADPOINTER(2,0,6,sizeof(pthread_mutex_t)*2);
#else
PADPOINTER(2,0,6,0);
#endif
} *DOLLARS;
/**
*
*/
typedef struct MoDoPtDoLlArS {
#ifdef WITHPTHREADS
DOLLARS dstruct; /* If local dollar: list of DOLLARS for each thread */
#endif
WORD number;
WORD type;
#ifdef WITHPTHREADS
PADPOINTER(0,0,2,0);
#endif
} MODOPTDOLLAR;
/**
*
*/
typedef struct fixedset {
char *name;
char *description;
int type;
int dimension;
} FIXEDSET;
/**
*
*/
typedef struct TaBlEbAsEsUbInDeX {
POSITION where;
LONG size;
PADPOSITION(0,1,0,0,0);
} TABLEBASESUBINDEX;
/**
*
*/
typedef struct TaBlEbAsE {
POSITION fillpoint;
POSITION current;
UBYTE *name;
int *tablenumbers; /* Number of each table */
TABLEBASESUBINDEX *subindex; /* For each table */
int numtables;
PADPOSITION(3,0,1,0,0);
} TABLEBASE;
/**
* The struct FUN_INFO is used for information about functions in the file
* smart.c which is supposed to intelligently look for patterns in
* complicated wildcard situations involving symmetric functions.
*/
typedef struct {
WORD *location;
int numargs;
int numfunnies;
int numwildcards;
int symmet;
int tensor;
int commute;
PADPOINTER(0,6,0,0);
} FUN_INFO;
/*
#] Variables :
#[ Files :
*/
/**
* The type FILEHANDLE is the struct that controls all relevant information
* of a file, whether it is open or not. The file may even not yet exist.
* There is a system of caches (PObuffer) and as long as the information
* to be written still fits inside the cache the file may never be
* created. There are variables that can store information about different
* types of files, like scratch files or sort files.
* Depending on what is available in the system we may also have information
* about gzip compression (currently sort file only) or locks (TFORM).
*/
typedef struct FiLe {
POSITION POposition; /* File position */
POSITION filesize; /* Because SEEK_END is unsafe on IBM */
WORD *PObuffer; /* Address of the intermediate buffer */
WORD *POstop; /* End of the buffer */
WORD *POfill; /* Fill position of the buffer */
WORD *POfull; /* Full buffer when only cached */
#ifdef WITHPTHREADS
WORD *wPObuffer; /* Address of the intermediate worker buffer */
WORD *wPOstop; /* End of the worker buffer */
WORD *wPOfill; /* Fill position of the worker buffer */
WORD *wPOfull; /* Full buffer when only worker cached */
#endif
char *name; /* name of the file */
#ifdef WITHZLIB
z_streamp zsp; /* The pointer to the stream struct for gzip */
Bytef *ziobuffer; /* The output buffer for compression */
#endif
ULONG numblocks; /* Number of blocks in file */
ULONG inbuffer; /* Block in the buffer */
LONG POsize; /* size of the buffer */
#ifdef WITHZLIB
LONG ziosize; /* size of the zoutbuffer */
#endif
#ifdef WITHPTHREADS
LONG wPOsize; /* size of the worker buffer */
pthread_mutex_t pthreadslock;
#endif
int handle; /**< Our own handle. Equal -1 if no file exists. */
int active; /* File is open or closed. Not used. */
#ifdef WITHPTHREADS
#ifdef WITHZLIB
PADPOSITION(11,5,2,0,sizeof(pthread_mutex_t));
#else
PADPOSITION(9,4,2,0,sizeof(pthread_mutex_t));
#endif
#else
#ifdef WITHZLIB
PADPOSITION(7,4,2,0,0);
#else
PADPOSITION(5,3,2,0,0);
#endif
#endif
} FILEHANDLE;
/**
* Input is read from 'streams' which are represented by objects of type
* STREAM. A stream can be a file, a do-loop, a procedure, the string value
* of a preprocessor variable .....
* When a new stream is opened we have to keep information about where
* to fall back in the parent stream to allow this to happen even in the
* middle of reading names etc as would be the case with a`i'b
*/
typedef struct StreaM {
off_t fileposition;
off_t linenumber;
off_t prevline;
UBYTE *buffer; /**< [D] Size in buffersize */
UBYTE *pointer; /**< pointer into buffer memory */
UBYTE *top; /**< pointer into buffer memory */
UBYTE *FoldName; /**< [D] */
UBYTE *name; /**< [D] */
UBYTE *pname; /**< for DOLLARSTREAM and PREVARSTREAM it points always to name, else it
is undefined */
LONG buffersize;
LONG bufferposition;
LONG inbuffer;
int previous;
int handle;
int type;
int prevars;
int previousNoShowInput;
int eqnum;
int afterwards;
int olddelay;
int oldnoshowinput;
UBYTE isnextchar;
UBYTE nextchar[2];
UBYTE reserved;
PADPOSITION(6,3,9,0,4);
} STREAM;
typedef struct SpecTatoR {
POSITION position; /* The place where we will be writing */
POSITION readpos; /* The place from which we read */
FILEHANDLE *fh;
char *name; /* We identify the spectator by the name of the expression */
WORD exprnumber; /* During running we use the number. */
WORD flags; /* local, global? */
PADPOSITION(2,0,0,2,0);
} SPECTATOR;
/*
#] Files :
#[ Traces :
*/
/**
* The struct TRACES keeps track of the progress during the expansion
* of a 4-dimensional trace. Each time a term gets generated the expansion
* tree continues in the next statement. When it returns it has to know
* where to continue. The 4-dimensional traces are more complicated
* than the n-dimensional traces (see TRACEN) because of the extra tricks
* that can be used. They are responsible for the shorter final expressions.
*/
typedef struct TrAcEs { /* For computing 4 dimensional traces */
WORD *accu; /* NUMBER * 2 */
WORD *accup;
WORD *termp;
WORD *perm; /* number */
WORD *inlist; /* number */
WORD *nt3; /* number/2 */
WORD *nt4; /* number/2 */
WORD *j3; /* number*2 */
WORD *j4; /* number*2 */
WORD *e3; /* number*2 */
WORD *e4; /* number */
WORD *eers; /* number/2 */
WORD *mepf; /* number/2 */
WORD *mdel; /* number/2 */
WORD *pepf; /* number*2 */
WORD *pdel; /* number*3/2 */
WORD sgn;
WORD stap;
WORD step1,kstep,mdum;
WORD gamm,ad,a3,a4,lc3,lc4;
WORD sign1,sign2,gamma5,num,level,factor,allsign;
WORD finalstep;
PADPOINTER(0,0,19,0);
} TRACES;
/**
* The struct TRACEN keeps track of the progress during the expansion
* of a 4-dimensional trace. Each time a term gets generated the expansion
* tree continues in the next statement. When it returns it has to know
* where to continue.
*/
typedef struct TrAcEn { /* For computing n dimensional traces */
WORD *accu; /* NUMBER */
WORD *accup;
WORD *termp;
WORD *perm; /* number */
WORD *inlist; /* number */
WORD sgn,num,level,factor,allsign;
PADPOINTER(0,0,5,0);
} *TRACEN;
/*
#] Traces :
#[ Preprocessor :
*/
/**
* An element of the type PREVAR is needed for each preprocessor variable.
*/
typedef struct pReVaR {
UBYTE *name; /**< allocated */
UBYTE *value; /**< points into memory of name */
UBYTE *argnames; /**< names of arguments, zero separated. points into memory of name */
int nargs; /**< 0 = regular, >= 1: number of macro arguments. total number */
int wildarg; /**< The number of a potential ?var. If none: 0. wildarg<nargs */
PADPOINTER(0,2,0,0);
} PREVAR;
/**
* Used for #inside
*/
typedef struct {
WORD *buffer;
int oldcompiletype;
int oldparallelflag;
int oldnumpotmoddollars;
WORD size;
WORD numdollars;
WORD oldcbuf;
WORD oldrbuf;
WORD inscbuf;
WORD oldcnumlhs;
PADPOINTER(0,3,6,0);
} INSIDEINFO;
/**
* Used by the preprocessor to load the contents of a doloop or a procedure.
* The struct PRELOAD is used both in the DOLOOP and PROCEDURE structs.
*/
typedef struct {
UBYTE *buffer;
LONG size;
PADPOINTER(1,0,0,0);
} PRELOAD;
/**
* An element of the type PROCEDURE is needed for each procedure in the system.
*/
typedef struct {
PRELOAD p;
UBYTE *name;
int loadmode;
PADPOINTER(0,1,0,0);
} PROCEDURE;
/**
* Each preprocessor do loop has a struct of type DOLOOP to keep track
* of all relevant parameters like where the beginning of the loop is,
* what the boundaries, increment and value of the loop parameter are, etc.
* Also we keep the whole loop inside a buffer of type PRELOAD
*/
typedef struct DoLoOp {
PRELOAD p; /**< size, name and buffer */
UBYTE *name; /**< pointer into PRELOAD buffer */
UBYTE *vars; /* for {} or name of expression */
UBYTE *contents;
UBYTE *dollarname; /**< For loop over terms in expression. Allocated with Malloc1() */
LONG startlinenumber;
LONG firstnum;
LONG lastnum;
LONG incnum;
int type;
int NoShowInput;
int errorsinloop;
int firstloopcall;
WORD firstdollar; /* When >= 0 we have to get the value from a dollar */
WORD lastdollar; /* When >= 0 we have to get the value from a dollar */
WORD incdollar; /* When >= 0 we have to get the value from a dollar */
WORD NumPreTypes;
WORD PreIfLevel;
WORD PreSwitchLevel;
PADPOINTER(4,4,6,0);
} DOLOOP;
/**
* The struct bit_field is used by set_in, set_set, set_del and set_sub.
* They in turn are used in pre.c to toggle bits that indicate whether
* a character can be used as a separator of function arguments.
* This facility is used in the communication with external channels.
*/
struct bit_field { /* Assume 8 bits per byte */
UBYTE bit_0 : 1;
UBYTE bit_1 : 1;
UBYTE bit_2 : 1;
UBYTE bit_3 : 1;
UBYTE bit_4 : 1;
UBYTE bit_5 : 1;
UBYTE bit_6 : 1;
UBYTE bit_7 : 1;
/*
UINT bit_0 : 1;
UINT bit_1 : 1;
UINT bit_2 : 1;
UINT bit_3 : 1;
UINT bit_4 : 1;
UINT bit_5 : 1;
UINT bit_6 : 1;
UINT bit_7 : 1;
*/
};
/**
* Used in set_in, set_set, set_del and set_sub.
*/
typedef struct bit_field set_of_char[32];
/**
* Used in set_in, set_set, set_del and set_sub.
*/
typedef struct bit_field *one_byte;
/**
* The struct HANDLERS is used in the communication with external channels.
*/
typedef struct {
WORD newlogonly;
WORD newhandle;
WORD oldhandle;
WORD oldlogonly;
WORD oldprinttype;
WORD oldsilent;
} HANDLERS;
/*
#] Preprocessor :
#[ Varia :
*/
typedef WORD (*FINISHUFFLE)(WORD *);
typedef WORD (*DO_UFFLE)(WORD *,WORD,WORD,WORD);
typedef WORD (*COMPARE)(WORD *,WORD *,WORD);
/**
* The CBUF struct is used by the compiler. It is a compiler buffer of which
* since version 3.0 there can be many.
*/
typedef struct CbUf {
WORD *Buffer; /**< [D] Size in BufferSize */
WORD *Top; /**< pointer to the end of the Buffer memory */
WORD *Pointer; /**< pointer into the Buffer memory */
WORD **lhs; /**< [D] Size in maxlhs. list of pointers into Buffer. */
WORD **rhs; /**< [D] Size in maxrhs. list of pointers into Buffer. */
LONG *CanCommu; /**< points into rhs memory behind WORD* area. */
LONG *NumTerms; /**< points into rhs memory behind CanCommu area */
WORD *numdum; /**< points into rhs memory behind NumTerms */
WORD *dimension; /**< points into rhs memory behind numdum */
COMPTREE *boomlijst; /**< [D] Number elements in MaxTreeSize */
LONG BufferSize; /**< Number of allocated WORD's in Buffer */
int numlhs;
int numrhs;
int maxlhs;
int maxrhs;
int mnumlhs;
int mnumrhs;
int numtree;
int rootnum;
int MaxTreeSize;
PADPOINTER(1,9,0,0);
} CBUF;
/**
* When we read input from text files we have to remember not only their
* handle but also their name. This is needed for error messages.
* Hence we call such a file a channel and reserve a struct of type
* #CHANNEL to allow to lay this link.
*/
typedef struct ChAnNeL {
char *name; /**< [D] Name of the channel */
int handle; /**< File handle */
PADPOINTER(0,1,0,0);
} CHANNEL;
/**
* Each setup parameter has one element of the struct SETUPPARAMETERS
* assigned to it. By binary search in the array of them we can then
* locate the proper element by name.
* We have to assume that two ints make a long and either one or two longs
* make a pointer. The long before the ints and padding gives a problem
* in the initialization.
*/
typedef struct {
UBYTE *parameter;
int type;
int flags;
LONG value;
} SETUPPARAMETERS;
/**
* The NESTING struct is used when we enter the argument of functions and
* there is the possibility that we have to change something there.
* Because functions can be nested we have to keep track of all levels
* of functions in case we have to move the outer layers to make room
* for a larger function argument.
*/
typedef struct NeStInG {
WORD *termsize;