Merge 15329:15546 from trunk
[reactos.git] / rosapps / mc / slang / _slang.h
1 /* header file for S-Lang internal structures that users do not (should not)
2 need. Use slang.h for that purpose. */
3 /* Copyright (c) 1992, 1995 John E. Davis
4 * All rights reserved.
5 *
6 * You may distribute under the terms of either the GNU General Public
7 * License or the Perl Artistic License.
8 */
9
10
11 #include "config.h"
12
13 #include <string.h>
14
15 #include "jdmacros.h"
16
17 #ifdef VMS
18 # define SLANG_SYSTEM_NAME "_VMS"
19 #else
20 # if defined (__GO32__) || defined (__EMX__) || \
21 defined (msdos) || defined (__os2__)
22 # define SLANG_SYSTEM_NAME "_IBMPC"
23 # else
24 # define SLANG_SYSTEM_NAME "_UNIX"
25 # endif
26 #endif /* VMS */
27
28 #ifdef msdos
29 #define SLANG_MAX_SYMBOLS 500
30 #else
31 #define SLANG_MAX_SYMBOLS 2500
32 #endif
33 /* maximum number of global symbols--- slang builtin, functions, global vars */
34
35
36 /* These quantities are main_types for byte-compiled code. They are used
37 * by the inner_interp routine. The ones commented out with a // are
38 * actually defined in slang.h because they are also used as the main_type in
39 * the name table.
40 */
41
42 /* // #define SLANG_LVARIABLE 0x01 */
43 #define SLANG_LOGICAL 0x02
44 #define SLANG_BINARY 0x03
45 /* // #define SLANG_INTRINSIC 0x06 */
46 /* // #define SLANG_FUNCTION 0x07 */
47 #define SLANG_LITERAL 0x08 /* constant objects */
48 #define SLANG_BLOCK 0x09
49 #define SLANG_EQS 0x0A
50 #define SLANG_UNARY 0x0B
51 #define SLANG_LUNARY 0x0C
52
53 /* // #define SLANG_GVARIABLE 0x0D */
54 /* // #define SLANG_IVARIABLE 0x0E */ /* intrinsic variables */
55 /* // #define SLANG_RVARIABLE 0x0F */ /* read only variable */
56
57 /* These 3 MUST be in this order too ! */
58 #define SLANG_RETURN 0x10
59 #define SLANG_BREAK 0x11
60 #define SLANG_CONTINUE 0x12
61
62 #define SLANG_EXCH 0x13
63 #define SLANG_LABEL 0x14
64 #define SLANG_LOBJPTR 0x15
65 #define SLANG_GOBJPTR 0x16
66 #define SLANG_X_ERROR 0x17
67 /* These must be in this order */
68 #define SLANG_X_USER0 0x18
69 #define SLANG_X_USER1 0x19
70 #define SLANG_X_USER2 0x1A
71 #define SLANG_X_USER3 0x1B
72 #define SLANG_X_USER4 0x1C
73
74 #ifdef SLANG_NOOP
75 # define SLANG_NOOP_DIRECTIVE 0x2F
76 #endif
77
78 /* If SLANG_DATA occurs as the main_type for an object in the interpreter's
79 * byte-code, it currently refers to a STRING.
80 */
81 /* // #define SLANG_DATA 0x30 */ /* real objects which may be destroyed */
82
83
84 /* Subtypes */
85 #define ERROR_BLOCK 0x01
86 /* gets executed if block encounters error other than stack related */
87 #define EXIT_BLOCK 0x02
88 #define USER_BLOCK0 0x03
89 #define USER_BLOCK1 0x04
90 #define USER_BLOCK2 0x05
91 #define USER_BLOCK3 0x06
92 #define USER_BLOCK4 0x07
93 /* The user blocks MUST be in the above order */
94
95 /* directive subtypes */
96 #define SLANG_LOOP_MASK 0x80
97 #define SLANG_LOOP 0x81
98 #define SLANG_WHILE 0x82
99 #define SLANG_FOR 0x83
100 #define SLANG_FOREVER 0x84
101 #define SLANG_CFOR 0x85
102 #define SLANG_DOWHILE 0x86
103
104 #define SLANG_IF_MASK 0x40
105 #define SLANG_IF 0x41
106 #define SLANG_IFNOT 0x42
107 #define SLANG_ELSE 0x43
108
109
110 /* local, global variable assignments
111 * The order here is important. See interp_variable_eqs to see how this
112 * is exploited. */
113 #define SLANG_EQS_MASK 0x20
114 /* local variables */
115 /* Keep these in this order!! */
116 #define SLANG_LEQS 0x21
117 #define SLANG_LPEQS 0x22
118 #define SLANG_LMEQS 0x23
119 #define SLANG_LPP 0x24
120 #define SLANG_LMM 0x25
121 /* globals */
122 /* Keep this on this order!! */
123 #define SLANG_GEQS 0x26
124 #define SLANG_GPEQS 0x27
125 #define SLANG_GMEQS 0x28
126 #define SLANG_GPP 0x29
127 #define SLANG_GMM 0x2A
128 /* intrinsic variables */
129 #define SLANG_IEQS 0x2B
130 #define SLANG_IPEQS 0x2C
131 #define SLANG_IMEQS 0x2D
132 #define SLANG_IPP 0x2E
133 #define SLANG_IMM 0x2F
134
135
136 #define SLANG_ELSE_MASK 0x10
137 #define SLANG_ANDELSE 0x11
138 #define SLANG_ORELSE 0x12
139 #define SLANG_SWITCH 0x13
140
141 /* LOGICAL SUBTYPES (operate on integers) */
142 #define SLANG_MOD 16
143 #define SLANG_OR 17
144 #define SLANG_AND 18
145 #define SLANG_BAND 19
146 #define SLANG_BOR 20
147 #define SLANG_BXOR 21
148 #define SLANG_SHL 22
149 #define SLANG_SHR 23
150
151 /* LUnary Subtypes */
152 #define SLANG_NOT 24
153 #define SLANG_BNOT 25
154
155 typedef struct SLBlock_Type
156 {
157 unsigned char main_type;
158 unsigned char sub_type;
159 union
160 {
161 struct SLBlock_Type *blk;
162 int i_blk;
163 SLang_Name_Type *n_blk;
164 char *s_blk;
165 #ifdef FLOAT_TYPE
166 float64 *f_blk; /*literal float is a pointer */
167 #endif
168 long l_blk;
169 }
170 b;
171 }
172 SLBlock_Type;
173
174
175 typedef struct
176 {
177 unsigned char main_type; /* block, intrinsic... */
178 unsigned char sub_type; /* SLANG_WHILE, SLANG_DATA, ... */
179 union
180 {
181 long l_val;
182 char *s_val;
183 int i_val;
184 SLuser_Object_Type *uobj;
185 SLang_Name_Type *n_val;
186 #ifdef FLOAT_TYPE
187 float64 f_val;
188 #endif
189 } v;
190 } SLang_Object_Type;
191
192
193 extern void SLang_free_object (SLang_Object_Type *);
194
195 extern int SLang_pop_non_object (SLang_Object_Type *);
196
197 extern void _SLdo_error (char *, ...);
198 extern void SLcompile(char *);
199 extern void (*SLcompile_ptr)(char *);
200
201 typedef struct
202 {
203 char *name; int type;
204 } SLang_Name2_Type;
205
206 extern void SLstupid_hash(void);
207
208 typedef struct SLName_Table
209 {
210 struct SLName_Table *next; /* next table */
211 SLang_Name_Type *table; /* pointer to table */
212 int n; /* entries in this table */
213 char name[32]; /* name of table */
214 int ofs[256]; /* offsets into table */
215 } SLName_Table;
216
217 extern SLName_Table *SLName_Table_Root;
218 #ifdef MSWINDOWS
219 extern SLang_Name_Type *SLang_Name_Table;
220 #else
221 extern SLang_Name_Type SLang_Name_Table[SLANG_MAX_SYMBOLS];
222 #endif
223
224 extern SLang_Name2_Type SL_Binary_Ops [];
225 extern SLang_Object_Type *SLStack_Pointer;
226 extern char *SLbyte_compile_name(char *);
227 extern int SLang_pop(SLang_Object_Type *);
228 extern char *SLexpand_escaped_char(char *, char *);
229 extern void SLexpand_escaped_string (char *, char *, char *);
230
231 extern SLang_Object_Type *_SLreverse_stack (int);
232 extern SLang_Name_Type *SLang_locate_name(char *);
233
234 /* returns a pointer to a MALLOCED string */
235 extern char *SLstringize_object (SLang_Object_Type *);
236
237 /* array types */
238 typedef struct SLArray_Type
239 {
240 unsigned char type; /* int, float, etc... */
241 int dim; /* # of dims (max 3) */
242 int x, y, z; /* actual dims */
243 union
244 {
245 unsigned char *c_ptr;
246 unsigned char **s_ptr;
247 int *i_ptr;
248 #ifdef FLOAT_TYPE
249 float64 *f_ptr;
250 #endif
251 SLuser_Object_Type **u_ptr;
252 }
253 buf;
254 unsigned char flags; /* readonly, etc... If this is non-zero,
255 * the buf pointer will NOT be freed.
256 * See SLarray_free_array.
257 */
258 } SLArray_Type;
259
260
261 /* Callback to delete array */
262 extern void SLarray_free_array (long *);
263
264
265 /* maximum size of run time stack */
266 #ifdef msdos
267 #define SLANG_MAX_STACK_LEN 500
268 #else
269 #define SLANG_MAX_STACK_LEN 2500
270 #endif
271
272 #ifdef MSWINDOWS
273 extern SLang_Object_Type *SLRun_Stack;
274 #else
275 extern SLang_Object_Type SLRun_Stack[SLANG_MAX_STACK_LEN];
276 #endif
277
278 extern SLang_Object_Type *SLStack_Pointer;
279
280 extern int SLang_Trace;
281 extern int SLstack_depth(void);
282
283 extern void SLang_trace_fun(char *);
284 extern void SLexecute_function(SLang_Name_Type *);
285 extern char *SLmake_string (char *);
286
287 extern int _SLeqs_name(char *, SLang_Name2_Type *);
288 extern void SLang_push(SLang_Object_Type *);
289 extern void SLang_push_float(float64);
290 extern void SLadd_variable(char *);
291 extern void SLang_clear_error(void);
292 extern void SLarray_info (void);
293 extern int SLPreprocess_Only; /* preprocess instead of
294 * bytecompiling
295 */
296
297 extern void SLdo_pop (void);
298 extern unsigned int SLsys_getkey (void);
299 extern int SLsys_input_pending (int);
300
301 #ifdef REAL_UNIX_SYSTEM
302 extern int SLtt_tigetflag (char *, char **);
303 extern int SLtt_tigetnum (char *, char **);
304 extern char *SLtt_tigetstr (char *, char **);
305 extern char *SLtt_tigetent (char *);
306 #endif
307
308 #ifdef msdos
309 #define MAX_INPUT_BUFFER_LEN 40
310 #else
311 #define MAX_INPUT_BUFFER_LEN 1024
312 #endif
313 extern unsigned char SLang_Input_Buffer [MAX_INPUT_BUFFER_LEN];
314 extern unsigned int SLang_Input_Buffer_Len;
315
316 extern int SLregister_types (void);
317
318 #ifndef pc_system
319 extern char *SLtt_Graphics_Char_Pairs;
320 #endif /* NOT pc_system */
321
322 extern void _SLerrno_set_return_status (void);
323 extern char *_SLerrno_strerror (void);
324 extern int _SLerrno_Return_Status;
325