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