996
|
1 /* abcess.h -- functions used by compiled INTERCAL programs */
|
|
2
|
|
3 /* AIS note: This header file now serves two purposes. For non-multithread
|
|
4 programs, it serves as headers to the degenerated code and many support
|
|
5 functions. For multithread programs, this header file adds extra functions
|
|
6 only when compiling the degenerated code and unravel.c, and holds its
|
|
7 previous contents during other files. */
|
|
8
|
|
9 #include <stdlib.h>
|
|
10 #include <stdio.h>
|
|
11 #include <setjmp.h>
|
|
12
|
|
13 #ifndef ICKBOOL_DEFINED
|
|
14 /*@-redef@*/
|
|
15 typedef int ick_bool;
|
|
16 /*@=redef@*/
|
|
17 #define ICKBOOL_DEFINED
|
|
18 #endif
|
|
19
|
|
20 #define ICK_ABCESS_H_INCLUDED
|
|
21
|
|
22 #define ick_TRUE 1
|
|
23 #define ick_FALSE 0
|
|
24
|
|
25 #define ick_ONESPOT 0
|
|
26 #define ick_TWOSPOT 1
|
|
27 #define ick_TAIL 2
|
|
28 #define ick_HYBRID 3
|
|
29
|
|
30 #define ick_MAXNEXT 80 /* AIS: Moved from cesspool.c */
|
|
31
|
|
32 /* the following two types must both promote to unsigned int in expressions */
|
|
33
|
|
34 typedef unsigned short ick_type16;
|
|
35 typedef unsigned int ick_type32;
|
|
36
|
|
37 typedef struct ick_array_t
|
|
38 {
|
|
39 unsigned int rank;
|
|
40 size_t *dims;
|
|
41 union
|
|
42 {
|
|
43 ick_type16 *tail;
|
|
44 ick_type32 *hybrid;
|
|
45 } data;
|
|
46 } ick_array;
|
|
47
|
|
48
|
|
49 /* AIS: For operand overloading, a more complicated data type is needed. */
|
|
50 typedef struct ick_overop_t
|
|
51 {
|
|
52 ick_type32 (*get)(ick_type32);
|
|
53 void (*set)(ick_type32, void(*)());
|
|
54 } ick_overop;
|
|
55
|
|
56 /* AIS: Moved from cesspool.c */
|
|
57 typedef struct ick_stashbox_t /* this is a save-stack element */
|
|
58 {
|
|
59 unsigned int type; /* variable type */
|
|
60 unsigned int index; /* variable's index within the type */
|
|
61 union /* the data itself */
|
|
62 {
|
|
63 ick_type16 onespot;
|
|
64 ick_type32 twospot;
|
|
65 ick_array *a;
|
|
66 } save;
|
|
67 /*@null@*/ /*@dependent@*/ struct ick_stashbox_t *ick_next; /* pointer to next-older ick_stashbox */
|
|
68 ick_overop overloadinfo; /* AIS: overloading info is stashed too, in a
|
|
69 non-overloaded program (ignored otherwise) */
|
|
70 } ick_stashbox;
|
|
71
|
|
72 /* AIS: files to take input and output from */
|
|
73 /*@null@*/ extern FILE* ick_cesspoolin;
|
|
74 /*@null@*/ extern FILE* ick_cesspoolout;
|
|
75
|
|
76 /* defined in cesspool.c */
|
|
77 extern void ick_pushnext(unsigned n);
|
|
78 extern unsigned int ick_popnext(unsigned n);
|
|
79 extern unsigned int ick_resume(unsigned n);
|
|
80 extern unsigned int ick_pin(void);
|
|
81 extern void ick_clockface(ick_bool mode);
|
|
82 extern void ick_setclcsemantics(ick_bool mode); /* AIS */
|
|
83 extern void ick_pout(unsigned int val);
|
|
84 extern void ick_binin(unsigned int type, ick_array *a, ick_bool forget);
|
|
85 extern void ick_binout(unsigned int type, const ick_array *a);
|
|
86 extern unsigned int ick_assign(char *dest, unsigned int type, ick_bool forget,
|
|
87 unsigned int value);
|
|
88
|
|
89 /* AIS: yuk, unravel and ick_ec need these */
|
|
90 extern unsigned* ick_next;
|
|
91 /*@null@*/ extern jmp_buf* ick_next_jmpbufs;
|
|
92 extern int ick_nextindex;
|
|
93 extern /*@null@*/ ick_stashbox *ick_first;
|
|
94
|
|
95 /* AIS: Implement the +ick_mystery command line option. */
|
|
96 extern unsigned long ick_mysteryc;
|
|
97 extern int ick_mystery;
|
|
98 #define ick_MYSTERYLINE if(ick_mystery && ick_mysteryc++ > 4000000000LU) exit(42);
|
|
99
|
|
100 /* AIS: More command-line options */
|
|
101 extern int ick_wimp_mode;
|
|
102 extern int ick_instapipe;
|
|
103
|
|
104 /* AIS: Handle multiple COME FROMs aiming at the same line */
|
|
105 extern int ick_multicome0(int errlineno, jmp_buf pc);
|
|
106
|
|
107 #ifdef HAVE_STDARG_H
|
|
108 /*@dependent@*/ extern void *ick_aref(unsigned int type, ...);
|
|
109 extern void ick_resize(unsigned int type, ...);
|
|
110 #else
|
|
111 /*@dependent@*/ extern void *ick_aref();
|
|
112 extern void ick_resize();
|
|
113 #endif
|
|
114
|
|
115 extern void ick_stashinit(void);
|
|
116 /* AIS: Added mentions of oo. This is set to 0 in a non-overloaded program. */
|
|
117 extern void ick_stash(unsigned int type, unsigned int index, void *from, ick_overop* oo);
|
|
118 extern void ick_retrieve(void *to, unsigned int type, unsigned int index,
|
|
119 ick_bool forget, ick_overop* oo);
|
|
120 extern unsigned int ick_roll(unsigned int n);
|
|
121
|
|
122 /* AIS: Lose with IE277 */
|
|
123 extern ick_type32 ick_ieg277(ick_type32);
|
|
124 extern void ick_ies277(ick_type32, void(*)());
|
|
125
|
|
126 /* defined in arrgghh.c */
|
|
127 extern void ick_parseargs(int argc, char **argv);
|
|
128 extern int ick_printflow;
|
|
129
|
|
130 /* AIS: For the CREATE statement */
|
|
131 typedef struct ick_tag_createdata ick_createdata;
|
|
132 struct ick_tag_createdata
|
|
133 {
|
|
134 int width; /* 16 or 32 (maybe 0 will be allowed at some point) */
|
|
135 int isarray; /* this and the previous determine what vartype it is */
|
|
136 unsigned short varnumber;
|
|
137 /* 0 if not a variable, the var's number if it is */
|
|
138 ick_overop accessors;/* how to get and set this lvalue, or {0,0} */
|
|
139 unsigned long value; /* current value of the var or expression */
|
|
140 };
|
|
141 extern void ick_registercreation(const char*,unsigned long);
|
|
142 extern unsigned long ick_jicmatch(const char*);
|
|
143
|
|
144 /* AIS: Multithreading types and defines */
|
|
145 #if MULTITHREAD != 0
|
|
146 typedef struct tag_ickthread ickthread;
|
|
147 /*@refcounted@*/ struct tag_ickthread
|
|
148 {
|
|
149 void* varforget[10]; /* holds all four variable types, and forgetting data */
|
|
150 unsigned* nextstack;
|
|
151 int nextpointer;
|
|
152 jmp_buf pc; /* program counter */
|
|
153 ick_stashbox* sb; /* holds all stash data */
|
|
154 /*@partial@*/ /*@dependent@*/ ickthread* ick_next;
|
|
155 /*@null@*/ /*@partial@*/ /*@dependent@*/ ickthread* choicepoint;
|
|
156 /* the top choicepoint available. Used as a next pointer in the choicepoint
|
|
157 stack. */
|
|
158 int stale; /* if this is a choicepoint, whether it's a stale choicepoint. */
|
|
159 int refcount; /* when Threaded INTERCAL and Backtracking INTERCAL are
|
|
160 combined, reference-counting on choicepoints is needed
|
|
161 so that backtracking past multithreading is possible.
|
|
162 This also allows for garbage-collection of choicepoints.
|
|
163 (Luckily, choicepoints cannot refer to themselves, so this
|
|
164 mechanism works.) This only applies to ickthreads that are
|
|
165 acting as choicepoints, not those acting as threads. */
|
|
166 int ick_ccfc; /* number of comefroms currently active */
|
|
167 long ick_skipto; /* compucome line number */
|
|
168 jmp_buf ick_cjb; /* keeps track of compucomes */
|
|
169 /*@partial@*/ /*@dependent@*/ ickthread* dsi; /* which thread's varforget and sb to use */
|
|
170 /*@null@*/ /*@dependent@*/ ickthread* usesthis; /* for garbage collection purposes */
|
|
171 };
|
|
172 /*@partial@*/ /*@dependent@*/ extern ickthread* ickmt_cur; /* current thread */
|
|
173 /*@partial@*/ /*@dependent@*/ extern ickthread*ickmt_prev; /* previous thread: an optimisation to make
|
|
174 thread switching O(1), not O(n), with
|
|
175 respect to the number of threads */
|
|
176 extern int weaving; /* whether to weave newly created threads */
|
|
177 #define NEXTTHREAD if(ick_printflow) fprintf(stderr,"[%d:%lx]",ick_lineno, \
|
|
178 (unsigned long)ickmt_cur); \
|
|
179 if(setjmp(ick_cjb) == 0) \
|
|
180 nextthread(ick_cjb, ick_lineno, 3);
|
|
181
|
|
182 extern void nextthread(jmp_buf pc, int errlineno, int flags);
|
|
183 extern void killthread(void);
|
|
184 extern void ickmtinit(void);
|
|
185 extern int multicome1(int errlineno, jmp_buf pc);
|
|
186 extern void choicepoint(void);
|
|
187 extern void choiceahead(void);
|
|
188 extern void choiceback(void);
|
|
189
|
|
190 /* from ick-wrap.c, declare as extern so they can be accessed by cesspool.c,
|
|
191 unravel.c */
|
|
192 extern int onespotcount;
|
|
193 extern int twospotcount;
|
|
194 extern int tailcount;
|
|
195 extern int hybridcount;
|
|
196
|
|
197 extern int ick_oldabstain;
|
|
198 extern int gonebackto;
|
|
199 extern int ick_ccfc;
|
|
200 extern long ick_skipto;
|
|
201 extern jmp_buf btjb;
|
|
202 extern jmp_buf ick_cjb;
|
|
203
|
|
204 #define MULTICOME multicome1
|
|
205 #else
|
|
206 #define MULTICOME ick_multicome0
|
|
207 #endif /* MULTITHREAD */
|
|
208
|
|
209 /* AIS: Used by the debugger, multithread code, external calls */
|
|
210 #if (MULTITHREAD != 0) || (YUKDEBUG != 0) || defined(ICK_EC)
|
|
211 extern ick_type16* ick_onespots;
|
|
212 extern ick_bool* ick_oneforget;
|
|
213 extern ick_type32* ick_twospots;
|
|
214 extern ick_bool* ick_twoforget;
|
|
215 extern ick_array* ick_tails;
|
|
216 extern ick_bool* ick_tailforget;
|
|
217 extern ick_array* ick_hybrids;
|
|
218 extern ick_bool* ick_hyforget;
|
|
219 #if (MULTITHREAD != 0) || defined(ICK_EC)
|
|
220 /*@null@*/ extern ick_overop* ick_oo_onespots;
|
|
221 /*@null@*/ extern ick_overop* ick_oo_twospots;
|
|
222 #endif
|
|
223 #endif
|
|
224
|
|
225 /* abcess.h ends here */
|