1 #ifndef PRIVATE_SLANG_H_
2 #define PRIVATE_SLANG_H_
3 /* header file for S-Lang internal structures that users do not (should not)
4 need. Use slang.h for that purpose. */
6 Copyright (C) 2004, 2005, 2006 John E. Davis
8 This file is part of the S-Lang Library.
10 The S-Lang Library is free software; you can redistribute it and/or
11 modify it under the terms of the GNU General Public License as
12 published by the Free Software Foundation; either version 2 of the
13 License, or (at your option) any later version.
15 The S-Lang Library is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this library; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
26 /* #include "config.h" */
31 # define SLANG_SYSTEM_NAME "_VMS"
33 # if defined (IBMPC_SYSTEM)
34 # define SLANG_SYSTEM_NAME "_IBMPC"
36 # define SLANG_SYSTEM_NAME "_UNIX"
40 /* These quantities are main_types for byte-compiled code. They are used
41 * by the inner_interp routine. The _BC_ means byte-code.
44 /* Nametype byte-codes --- these must correspond to those in slang.h */
47 SLANG_BC_LAST_BLOCK
= 0,
48 SLANG_BC_LVARIABLE
= SLANG_LVARIABLE
, /* 0x01 */
49 SLANG_BC_GVARIABLE
= SLANG_GVARIABLE
, /* 0x02 */
50 SLANG_BC_IVARIABLE
= SLANG_IVARIABLE
, /* 0x03 */
51 SLANG_BC_RVARIABLE
= SLANG_RVARIABLE
, /* 0x04 */
52 SLANG_BC_INTRINSIC
= SLANG_INTRINSIC
, /* 0x05 */
53 SLANG_BC_FUNCTION
= SLANG_FUNCTION
, /* 0x06 */
54 SLANG_BC_MATH_UNARY
= SLANG_MATH_UNARY
, /* 0x07 */
55 SLANG_BC_APP_UNARY
= SLANG_APP_UNARY
, /* 0x08 */
56 SLANG_BC_ARITH_UNARY
= SLANG_ARITH_UNARY
, /* 0x09 */
57 SLANG_BC_ARITH_BINARY
= SLANG_ARITH_BINARY
, /* 0x0A */
58 SLANG_BC_ICONST
= SLANG_ICONSTANT
, /* 0x0B */
59 SLANG_BC_DCONST
= SLANG_DCONSTANT
, /* 0x0C */
60 SLANG_BC_FCONST
= SLANG_FCONSTANT
, /* 0x0D */
61 SLANG_BC_LLCONST
= SLANG_LLCONSTANT
, /* 0x0E */
62 SLANG_BC_PVARIABLE
= SLANG_PVARIABLE
, /* 0x0F */
63 SLANG_BC_PFUNCTION
= SLANG_PFUNCTION
, /* 0x10 */
64 SLANG_BC_HCONST
= SLANG_HCONSTANT
, /* 0x11 */
65 SLANG_BC_LCONST
= SLANG_LCONSTANT
, /* 0x12 */
66 SLANG_BC_UNUSED_0x12
= 0x12,
67 SLANG_BC_UNUSED_0x13
= 0x13,
68 SLANG_BC_UNUSED_0x14
= 0x14,
69 SLANG_BC_UNUSED_0x15
= 0x15,
70 SLANG_BC_UNUSED_0x16
= 0x16,
71 SLANG_BC_UNUSED_0x17
= 0x17,
72 SLANG_BC_UNUSED_0x18
= 0x18,
73 SLANG_BC_UNUSED_0x19
= 0x19,
74 SLANG_BC_UNUSED_0x1A
= 0x1A,
75 SLANG_BC_UNUSED_0x1B
= 0x1B,
76 SLANG_BC_UNUSED_0x1C
= 0x1C,
77 SLANG_BC_UNUSED_0x1D
= 0x1D,
78 SLANG_BC_UNUSED_0x1E
= 0x1E,
79 SLANG_BC_UNUSED_0x1F
= 0x1F,
81 /* bytes codes for setting/assigning variables/arrays/structures/refs */
82 SLANG_BC_SET_LOCAL_LVALUE
= 0x20,
83 SLANG_BC_SET_GLOBAL_LVALUE
= 0x21,
84 SLANG_BC_SET_INTRIN_LVALUE
= 0x22,
85 SLANG_BC_SET_STRUCT_LVALUE
= 0x23,
86 SLANG_BC_SET_ARRAY_LVALUE
= 0x24,
87 SLANG_BC_SET_DEREF_LVALUE
= 0x25,
88 SLANG_BC_FIELD
= 0x26,
89 SLANG_BC_METHOD
= 0x27,
90 SLANG_BC_LVARIABLE_AGET
= 0x28,
91 SLANG_BC_LVARIABLE_APUT
= 0x29,
92 SLANG_BC_LOBJPTR
= 0x2A,
93 SLANG_BC_GOBJPTR
= 0x2B,
94 SLANG_BC_UNUSED_0x2C
= 0x2C,
95 SLANG_BC_UNUSED_0x2D
= 0x2D,
96 SLANG_BC_UNUSED_0x2E
= 0x2E,
97 SLANG_BC_UNUSED_0x2F
= 0x2F,
98 SLANG_BC_UNUSED_0x30
= 0x30,
99 SLANG_BC_UNUSED_0x31
= 0x31,
100 SLANG_BC_UNUSED_0x32
= 0x32,
101 SLANG_BC_UNUSED_0x33
= 0x33,
102 SLANG_BC_UNUSED_0x34
= 0x34,
103 SLANG_BC_UNUSED_0x35
= 0x35,
104 SLANG_BC_UNUSED_0x36
= 0x36,
105 SLANG_BC_UNUSED_0x37
= 0x37,
106 SLANG_BC_UNUSED_0x38
= 0x38,
107 SLANG_BC_UNUSED_0x39
= 0x39,
108 SLANG_BC_UNUSED_0x3A
= 0x3A,
109 SLANG_BC_UNUSED_0x3B
= 0x3B,
110 SLANG_BC_UNUSED_0x3C
= 0x3C,
111 SLANG_BC_UNUSED_0x3D
= 0x3D,
112 SLANG_BC_UNUSED_0x3E
= 0x3E,
113 SLANG_BC_UNUSED_0x3F
= 0x3F,
115 /* byte codes for literals */
116 SLANG_BC_LITERAL
= 0x40, /* constant objects */
117 SLANG_BC_LITERAL_INT
= 0x41,
118 SLANG_BC_LITERAL_DBL
= 0x42,
119 SLANG_BC_LITERAL_STR
= 0x43,
120 SLANG_BC_DOLLAR_STR
= 0x44,
121 SLANG_BC_LITERAL_SHORT
= 0x45,
122 SLANG_BC_LITERAL_LONG
= 0x46,
123 SLANG_BC_UNUSED_0x45
= 0x45,
124 SLANG_BC_UNUSED_0x46
= 0x46,
125 SLANG_BC_UNUSED_0x47
= 0x47,
126 SLANG_BC_UNUSED_0x48
= 0x48,
127 SLANG_BC_UNUSED_0x49
= 0x49,
128 SLANG_BC_UNUSED_0x4A
= 0x4A,
129 SLANG_BC_UNUSED_0x4B
= 0x4B,
130 SLANG_BC_UNUSED_0x4C
= 0x4C,
131 SLANG_BC_UNUSED_0x4D
= 0x4D,
132 SLANG_BC_UNUSED_0x4E
= 0x4E,
133 SLANG_BC_UNUSED_0x4F
= 0x4F,
135 /* Unary/Binary operation codes */
136 SLANG_BC_UNARY
= 0x50,
137 SLANG_BC_BINARY
= 0x51,
138 SLANG_BC_INTEGER_PLUS
= 0x52,
139 SLANG_BC_INTEGER_MINUS
= 0x53,
140 SLANG_BC_UNUSED_0x54
= 0x54,
141 SLANG_BC_UNUSED_0x55
= 0x55,
142 SLANG_BC_UNUSED_0x56
= 0x56,
143 SLANG_BC_UNUSED_0x57
= 0x57,
144 SLANG_BC_UNUSED_0x58
= 0x58,
145 SLANG_BC_UNUSED_0x59
= 0x59,
146 SLANG_BC_UNUSED_0x5A
= 0x5A,
147 SLANG_BC_UNUSED_0x5B
= 0x5B,
148 SLANG_BC_UNUSED_0x5C
= 0x5C,
149 SLANG_BC_UNUSED_0x5D
= 0x5D,
150 SLANG_BC_UNUSED_0x5E
= 0x5E,
151 SLANG_BC_UNUSED_0x5F
= 0x5F,
153 /* byte codes associated with keywords and blocks */
155 SLANG_BC_EXCH
= 0x61,
156 SLANG_BC_LABEL
= 0x62,
157 SLANG_BC_BLOCK
= 0x63,
158 SLANG_BC_RETURN
= 0x64,
159 SLANG_BC_BREAK
= 0x65,
160 SLANG_BC_CONTINUE
= 0x66,
161 SLANG_BC_IF_BLOCK
= 0x67, /* optimized code */
162 SLANG_BC_UNUSED_0x68
= 0x68,
163 SLANG_BC_UNUSED_0x69
= 0x69,
164 SLANG_BC_X_ERROR
= 0x6A,
165 SLANG_BC_X_USER0
= 0x6B,
166 SLANG_BC_X_USER1
= 0x6C,
167 SLANG_BC_X_USER2
= 0x6D,
168 SLANG_BC_X_USER3
= 0x6E,
169 SLANG_BC_X_USER4
= 0x6F,
171 /* byte codes for dealing with the frame pointer and arg list */
172 SLANG_BC_CALL_DIRECT
= 0x70,
173 SLANG_BC_CALL_DIRECT_FRAME
= 0x71,
174 /* SLANG_BC_ARG_LVARIABLE = 0x72, */
175 SLANG_BC_UNUSED_0x72
= 0x72,
176 SLANG_BC_EARG_LVARIABLE
= 0x73,
177 SLANG_BC_LINE_NUM
= 0x74,
180 SLANG_BC_UNUSED_0x77
= 0x77,
181 SLANG_BC_UNUSED_0x78
= 0x78,
182 SLANG_BC_UNUSED_0x79
= 0x79,
183 SLANG_BC_UNUSED_0x7A
= 0x7A,
184 SLANG_BC_UNUSED_0x7B
= 0x7B,
185 SLANG_BC_UNUSED_0x7C
= 0x7C,
186 SLANG_BC_UNUSED_0x7D
= 0x7D,
187 SLANG_BC_UNUSED_0x7E
= 0x7E,
188 SLANG_BC_UNUSED_0x7F
= 0x7F,
190 /* These are used only when compiled with USE_COMBINED_BYTECODES */
191 SLANG_BC_CALL_DIRECT_INTRINSIC
= 0x80,
192 SLANG_BC_INTRINSIC_CALL_DIRECT
= 0x81,
193 SLANG_BC_CALL_DIRECT_LSTR
= 0x82,
194 SLANG_BC_CALL_DIRECT_SLFUN
= 0x83,
195 SLANG_BC_CALL_DIRECT_RETINTR
= 0x84,
196 SLANG_BC_RET_INTRINSIC
= 0x85,
197 SLANG_BC_CALL_DIRECT_EARG_LVAR
= 0x86,
198 SLANG_BC_CALL_DIRECT_LINT
= 0x87,
199 SLANG_BC_CALL_DIRECT_LVAR
= 0x88,
200 SLANG_BC_LLVARIABLE_BINARY
= 0x89,
201 SLANG_BC_LGVARIABLE_BINARY
= 0x8A,
202 SLANG_BC_GLVARIABLE_BINARY
= 0x8B,
203 SLANG_BC_GGVARIABLE_BINARY
= 0x8C,
204 SLANG_BC_LIVARIABLE_BINARY
= 0x8D,
205 SLANG_BC_LDVARIABLE_BINARY
= 0x8E,
206 SLANG_BC_ILVARIABLE_BINARY
= 0x8F,
207 SLANG_BC_DLVARIABLE_BINARY
= 0x90,
208 SLANG_BC_LVARIABLE_BINARY
= 0x91,
209 SLANG_BC_GVARIABLE_BINARY
= 0x92,
210 SLANG_BC_LITERAL_INT_BINARY
= 0x93,
211 SLANG_BC_LITERAL_DBL_BINARY
= 0x94,
212 SLANG_BC_LASSIGN_LLBINARY
= 0x95,
213 SLANG_BC_LASSIGN_LIBINARY
= 0x96,
214 SLANG_BC_LASSIGN_ILBINARY
= 0x97,
215 SLANG_BC_LASSIGN_LDBINARY
= 0x98,
216 SLANG_BC_LASSIGN_DLBINARY
= 0x99,
217 SLANG_BC_RET_LVARIABLE
= 0x9A,
218 SLANG_BC_RET_LITERAL_INT
= 0x9B,
219 SLANG_BC_MANY_LVARIABLE
= 0x9C,
220 SLANG_BC_MANY_LVARIABLE_DIR
= 0x9D,
221 SLANG_BC_LVARIABLE_AGET1
= 0x9E,
222 SLANG_BC_LITERAL_AGET1
= 0x9F,
223 SLANG_BC_LVARIABLE_APUT1
= 0xA0,
224 SLANG_BC_LITERAL_APUT1
= 0xA1,
225 SLANG_BC_UNUSED_0xA2
= 0xA2,
226 SLANG_BC_UNUSED_0xA3
= 0xA3,
227 SLANG_BC_UNUSED_0xA4
= 0xA4,
228 SLANG_BC_UNUSED_0xA5
= 0xA5,
229 SLANG_BC_UNUSED_0xA6
= 0xA6,
230 SLANG_BC_UNUSED_0xA7
= 0xA7,
231 SLANG_BC_UNUSED_0xA8
= 0xA8,
232 SLANG_BC_UNUSED_0xA9
= 0xA9,
233 SLANG_BC_UNUSED_0xAA
= 0xAA,
234 SLANG_BC_UNUSED_0xAB
= 0xAB,
235 SLANG_BC_UNUSED_0xAC
= 0xAC,
236 SLANG_BC_UNUSED_0xAD
= 0xAD,
237 SLANG_BC_UNUSED_0xAE
= 0xAE,
238 SLANG_BC_UNUSED_0xAF
= 0xAF,
239 /* The following do not actually occur in inner_interp. They used
240 * to signify the bytecode has been combined with another.
242 SLANG_BC_LVARIABLE_COMBINED
= 0xB0,
243 SLANG_BC_GVARIABLE_COMBINED
= 0xB1,
244 SLANG_BC_LITERAL_COMBINED
= 0xB2,
245 SLANG_BC_CALL_DIRECT_COMB
= 0xB3,
246 SLANG_BC_COMBINED
= 0xB4,
247 SLANG_BC_UNUSED_0xB5
= 0xB5,
248 SLANG_BC_UNUSED_0xB6
= 0xB6,
249 SLANG_BC_UNUSED_0xB7
= 0xB7,
250 SLANG_BC_UNUSED_0xB8
= 0xB8,
251 SLANG_BC_UNUSED_0xB9
= 0xB9,
252 SLANG_BC_UNUSED_0xBA
= 0xBA,
253 SLANG_BC_UNUSED_0xBB
= 0xBB,
254 SLANG_BC_UNUSED_0xBC
= 0xBC,
255 SLANG_BC_UNUSED_0xBD
= 0xBD,
256 SLANG_BC_UNUSED_0xBE
= 0xBE,
257 SLANG_BC_UNUSED_0xBF
= 0xBF,
258 SLANG_BC_UNUSED_0xC0
= 0xC0,
259 SLANG_BC_UNUSED_0xC1
= 0xC1,
260 SLANG_BC_UNUSED_0xC2
= 0xC2,
261 SLANG_BC_UNUSED_0xC3
= 0xC3,
262 SLANG_BC_UNUSED_0xC4
= 0xC4,
263 SLANG_BC_UNUSED_0xC5
= 0xC5,
264 SLANG_BC_UNUSED_0xC6
= 0xC6,
265 SLANG_BC_UNUSED_0xC7
= 0xC7,
266 SLANG_BC_UNUSED_0xC8
= 0xC8,
267 SLANG_BC_UNUSED_0xC9
= 0xC9,
268 SLANG_BC_UNUSED_0xCA
= 0xCA,
269 SLANG_BC_UNUSED_0xCB
= 0xCB,
270 SLANG_BC_UNUSED_0xCC
= 0xCC,
271 SLANG_BC_UNUSED_0xCD
= 0xCD,
272 SLANG_BC_UNUSED_0xCE
= 0xCE,
273 SLANG_BC_UNUSED_0xCF
= 0xCF,
274 SLANG_BC_UNUSED_0xD0
= 0xD0,
275 SLANG_BC_UNUSED_0xD1
= 0xD1,
276 SLANG_BC_UNUSED_0xD2
= 0xD2,
277 SLANG_BC_UNUSED_0xD3
= 0xD3,
278 SLANG_BC_UNUSED_0xD4
= 0xD4,
279 SLANG_BC_UNUSED_0xD5
= 0xD5,
280 SLANG_BC_UNUSED_0xD6
= 0xD6,
281 SLANG_BC_UNUSED_0xD7
= 0xD7,
282 SLANG_BC_UNUSED_0xD8
= 0xD8,
283 SLANG_BC_UNUSED_0xD9
= 0xD9,
284 SLANG_BC_UNUSED_0xDA
= 0xDA,
285 SLANG_BC_UNUSED_0xDB
= 0xDB,
286 SLANG_BC_UNUSED_0xDC
= 0xDC,
287 SLANG_BC_UNUSED_0xDD
= 0xDD,
288 SLANG_BC_UNUSED_0xDE
= 0xDE,
289 SLANG_BC_UNUSED_0xDF
= 0xDF,
290 SLANG_BC_UNUSED_0xE0
= 0xE0,
291 SLANG_BC_UNUSED_0xE1
= 0xE1,
292 SLANG_BC_UNUSED_0xE2
= 0xE2,
293 SLANG_BC_UNUSED_0xE3
= 0xE3,
294 SLANG_BC_UNUSED_0xE4
= 0xE4,
295 SLANG_BC_UNUSED_0xE5
= 0xE5,
296 SLANG_BC_UNUSED_0xE6
= 0xE6,
297 SLANG_BC_UNUSED_0xE7
= 0xE7,
298 SLANG_BC_UNUSED_0xE8
= 0xE8,
299 SLANG_BC_UNUSED_0xE9
= 0xE9,
300 SLANG_BC_UNUSED_0xEA
= 0xEA,
301 SLANG_BC_UNUSED_0xEB
= 0xEB,
302 SLANG_BC_UNUSED_0xEC
= 0xEC,
303 SLANG_BC_UNUSED_0xED
= 0xED,
304 SLANG_BC_UNUSED_0xEE
= 0xEE,
305 SLANG_BC_UNUSED_0xEF
= 0xEF,
306 SLANG_BC_UNUSED_0xF0
= 0xF0,
307 SLANG_BC_UNUSED_0xF1
= 0xF1,
308 SLANG_BC_UNUSED_0xF2
= 0xF2,
309 SLANG_BC_UNUSED_0xF3
= 0xF3,
310 SLANG_BC_UNUSED_0xF4
= 0xF4,
311 SLANG_BC_UNUSED_0xF5
= 0xF5,
312 SLANG_BC_UNUSED_0xF6
= 0xF6,
313 SLANG_BC_UNUSED_0xF7
= 0xF7,
314 SLANG_BC_UNUSED_0xF8
= 0xF8,
315 SLANG_BC_UNUSED_0xF9
= 0xF9,
316 SLANG_BC_UNUSED_0xFA
= 0xFA,
317 SLANG_BC_UNUSED_0xFB
= 0xFB,
318 SLANG_BC_UNUSED_0xFC
= 0xFC,
319 SLANG_BC_UNUSED_0xFD
= 0xFD,
320 SLANG_BC_UNUSED_0xFE
= 0xFE,
321 SLANG_BC_UNUSED_0xFF
= 0xFF
325 /* Byte-Code Sub Types (_BCST_) */
327 /* These are sub_types of SLANG_BC_BLOCK */
328 #define SLANG_BCST_ERROR_BLOCK 0x01
329 #define SLANG_BCST_EXIT_BLOCK 0x02
330 #define SLANG_BCST_USER_BLOCK0 0x03
331 #define SLANG_BCST_USER_BLOCK1 0x04
332 #define SLANG_BCST_USER_BLOCK2 0x05
333 #define SLANG_BCST_USER_BLOCK3 0x06
334 #define SLANG_BCST_USER_BLOCK4 0x07
335 /* The user blocks MUST be in the above order */
336 #define SLANG_BCST_LOOP 0x10
337 #define SLANG_BCST_WHILE 0x11
338 #define SLANG_BCST_FOR 0x12
339 #define SLANG_BCST_FOREVER 0x13
340 #define SLANG_BCST_CFOR 0x14
341 #define SLANG_BCST_DOWHILE 0x15
342 #define SLANG_BCST_FOREACH 0x16
343 #define SLANG_BCST_TRY 0x17
345 #define SLANG_BCST_IF 0x20
346 #define SLANG_BCST_IFNOT 0x21
347 #define SLANG_BCST_ELSE 0x22
348 #define SLANG_BCST_ANDELSE 0x23
349 #define SLANG_BCST_ORELSE 0x24
350 #define SLANG_BCST_SWITCH 0x25
351 #define SLANG_BCST_NOTELSE 0x26
353 /* assignment (SLANG_BC_SET_*_LVALUE) subtypes. The order MUST correspond
354 * to the assignment token order with the ASSIGN_TOKEN as the first!
356 #define SLANG_BCST_ASSIGN 0x01
357 #define SLANG_BCST_PLUSEQS 0x02
358 #define SLANG_BCST_MINUSEQS 0x03
359 #define SLANG_BCST_TIMESEQS 0x04
360 #define SLANG_BCST_DIVEQS 0x05
361 #define SLANG_BCST_BOREQS 0x06
362 #define SLANG_BCST_BANDEQS 0x07
363 #define SLANG_BCST_PLUSPLUS 0x08
364 #define SLANG_BCST_POST_PLUSPLUS 0x09
365 #define SLANG_BCST_MINUSMINUS 0x0A
366 #define SLANG_BCST_POST_MINUSMINUS 0x0B
368 /* These use SLANG_PLUS, SLANG_MINUS, SLANG_PLUSPLUS, etc... */
371 #define LONG_IS_INT (SIZEOF_INT == SIZEOF_LONG)
372 #define LONG_IS_NOT_INT (SIZEOF_INT != SIZEOF_LONG)
373 #define SHORT_IS_INT (SIZEOF_INT == SIZEOF_SHORT)
374 #define SHORT_IS_NOT_INT (SIZEOF_INT != SIZEOF_SHORT)
375 #define LLONG_IS_LONG (SIZEOF_LONG == SIZEOF_LONG_LONG)
376 #define LLONG_IS_NOT_LONG (SIZEOF_LONG != SIZEOF_LONG_LONG)
378 /* If long or short are ints, then map the slang types to ints. This is
379 * done because slang has some optimizations for ints.
382 # define _pSLANG_LONG_TYPE SLANG_INT_TYPE
383 # define _pSLANG_ULONG_TYPE SLANG_UINT_TYPE
385 # define _pSLANG_LONG_TYPE SLANG_LONG_TYPE
386 # define _pSLANG_ULONG_TYPE SLANG_ULONG_TYPE
389 # define _pSLANG_SHORT_TYPE SLANG_INT_TYPE
390 # define _pSLANG_USHORT_TYPE SLANG_UINT_TYPE
392 # define _pSLANG_SHORT_TYPE SLANG_SHORT_TYPE
393 # define _pSLANG_USHORT_TYPE SLANG_USHORT_TYPE
396 # define _pSLANG_LLONG_TYPE _pSLANG_LONG_TYPE
397 # define _pSLANG_ULLONG_TYPE _pSLANG_ULONG_TYPE
399 # define _pSLANG_LLONG_TYPE SLANG_LLONG_TYPE
400 # define _pSLANG_ULLONG_TYPE SLANG_ULLONG_TYPE
403 /* Map off_t to a slang type */
404 #if defined(HAVE_LONG_LONG) && (SIZEOF_OFF_T == SIZEOF_LONG_LONG) && (SIZEOF_LONG_LONG > SIZEOF_LONG)
405 # define SLANG_C_OFF_T_TYPE _pSLANG_LLONG_TYPE
406 typedef long long _pSLc_off_t_Type
;
407 # define SLANG_PUSH_OFF_T SLang_push_long_long
409 # if (SIZEOF_OFF_T == SIZEOF_INT)
410 # define SLANG_C_OFF_T_TYPE SLANG_INT_TYPE
411 # define SLANG_PUSH_OFF_T SLang_push_int
412 typedef int _pSLc_off_t_Type
;
414 # define SLANG_C_OFF_T_TYPE _pSLANG_LONG_TYPE
415 # define SLANG_PUSH_OFF_T SLang_push_long
416 typedef long _pSLc_off_t_Type
;
421 # define _pSLANG_INT16_TYPE SLANG_INT_TYPE
422 # define _pSLANG_UINT16_TYPE SLANG_UINT_TYPE
424 # if SIZEOF_SHORT == 2
425 # define _pSLANG_INT16_TYPE SLANG_SHORT_TYPE
426 # define _pSLANG_UINT16_TYPE SLANG_USHORT_TYPE
428 # if SIZEOF_LONG == 2
429 # define _pSLANG_INT16_TYPE SLANG_LONG_TYPE
430 # define _pSLANG_UINT16_TYPE SLANG_ULONG_TYPE
432 # define _pSLANG_INT16_TYPE 0
433 # define _pSLANG_UINT16_TYPE 0
439 # define _pSLANG_INT32_TYPE SLANG_INT_TYPE
440 # define _pSLANG_UINT32_TYPE SLANG_UINT_TYPE
442 # if SIZEOF_SHORT == 4
443 # define _pSLANG_INT32_TYPE SLANG_SHORT_TYPE
444 # define _pSLANG_UINT32_TYPE SLANG_USHORT_TYPE
446 # if SIZEOF_LONG == 4
447 # define _pSLANG_INT32_TYPE SLANG_LONG_TYPE
448 # define _pSLANG_UINT32_TYPE SLANG_ULONG_TYPE
450 # define _pSLANG_INT32_TYPE 0
451 # define _pSLANG_UINT32_TYPE 0
457 # define _pSLANG_INT64_TYPE SLANG_INT_TYPE
458 # define _pSLANG_UINT64_TYPE SLANG_UINT_TYPE
460 # if SIZEOF_SHORT == 8
461 # define _pSLANG_INT64_TYPE SLANG_SHORT_TYPE
462 # define _pSLANG_UINT64_TYPE SLANG_USHORT_TYPE
464 # if SIZEOF_LONG == 8
465 # define _pSLANG_INT64_TYPE SLANG_LONG_TYPE
466 # define _pSLANG_UINT64_TYPE SLANG_ULONG_TYPE
468 # if SIZEOF_LONG_LONG == 8
469 # define _pSLANG_INT64_TYPE SLANG_LLONG_TYPE
470 # define _pSLANG_UINT64_TYPE SLANG_ULLONG_TYPE
472 # define _pSLANG_INT64_TYPE 0
473 # define _pSLANG_UINT64_TYPE 0
486 #ifdef HAVE_LONG_LONG
488 unsigned long long ullong_val
;
491 unsigned long ulong_val
;
495 unsigned int uint_val
;
497 SLang_Name_Type
*n_val
;
498 struct _pSLang_Struct_Type
*struct_val
;
499 struct _pSLang_Array_Type
*array_val
;
501 unsigned short ushort_val
;
503 unsigned char uchar_val
;
504 SLindex_Type index_val
;
506 _pSL_Object_Union_Type
;
508 typedef struct _pSLang_Object_Type
510 SLtype data_type
; /* SLANG_INT_TYPE, ... */
511 _pSL_Object_Union_Type v
;
515 struct _pSLang_MMT_Type
517 SLtype data_type
; /* int, string, etc... */
518 VOID_STAR user_data
; /* address of user structure */
519 unsigned int count
; /* number of references */
522 extern int _pSLang_pop_object_of_type (SLtype
, SLang_Object_Type
*, int);
526 char *name
; /* slstring */
527 SLang_Object_Type obj
;
529 _pSLstruct_Field_Type
;
531 typedef struct _pSLang_Struct_Type
533 _pSLstruct_Field_Type
*fields
;
534 unsigned int nfields
; /* number used */
535 unsigned int num_refs
;
536 /* user-defined methods */
537 SLang_Name_Type
*destroy_method
;
541 extern void _pSLstruct_delete_struct (_pSLang_Struct_Type
*);
542 extern int _pSLang_push_struct (_pSLang_Struct_Type
*);
543 extern int _pSLang_pop_struct (_pSLang_Struct_Type
**);
544 extern int _pSLstruct_init (void);
545 /* extern int _pSLstruct_get_field (char *); */
546 extern int _pSLstruct_define_struct (void);
547 extern int _pSLstruct_define_typedef (void);
549 struct _pSLang_Ref_Type
555 SLang_Object_Type
*local_obj
;
560 extern int _pSLang_dereference_ref (SLang_Ref_Type
*);
561 extern int _pSLang_deref_assign (SLang_Ref_Type
*);
562 extern int _pSLang_push_ref (int, VOID_STAR
);
564 extern int _pSL_increment_frame_pointer (void);
565 extern int _pSL_decrement_frame_pointer (void);
567 extern int SLang_pop(SLang_Object_Type
*);
568 extern void SLang_free_object (SLang_Object_Type
*);
569 extern int _pSLanytype_typecast (SLtype
, VOID_STAR
, unsigned int,
571 extern void _pSLstring_intrinsic (void);
574 /* NULL not allowed here */
575 extern char *_pSLmalloced_to_slstring (char *, unsigned int);
576 /* But here it is ok */
577 extern int _pSLpush_malloced_string (char *, unsigned int);
580 /* These functions are used to create slstrings of a fixed length. Be
581 * very careful how they are used. In particular, if len bytes are allocated,
582 * then the string must be len characters long, no more and no less.
584 extern char *_pSLallocate_slstring (unsigned int);
585 extern char *_pSLcreate_via_alloced_slstring (char *, unsigned int);
586 extern void _pSLunallocate_slstring (char *, unsigned int);
587 extern int _pSLpush_alloced_slstring (char *, unsigned int);
590 extern unsigned int _pSLstring_bytelen (SLstr_Type
*);
591 extern void _pSLang_free_slstring (SLstr_Type
*); /* slstring required and assumed */
592 extern unsigned long _pSLstring_get_hash (SLstr_Type
*s
); /* slstring required */
597 unsigned int max_num
;
599 unsigned int delta_num
;
600 int is_malloced
; /* non-zero if object was malloced */
602 _pSLString_List_Type
;
604 /* Note that _pSLstring_list_append makes no copy of the object-- it steals it.
605 * For a copy, use _pSLstring_list_append_copy */
606 extern int _pSLstring_list_append (_pSLString_List_Type
*, char *);
607 extern int _pSLstring_list_append_copy (_pSLString_List_Type
*, char *);
608 extern int _pSLstring_list_init (_pSLString_List_Type
*, unsigned int, unsigned int);
609 extern _pSLString_List_Type
*_pSLstring_list_new (unsigned int, unsigned int);
610 extern void _pSLstring_list_delete (_pSLString_List_Type
*);
611 extern int _pSLstring_list_push (_pSLString_List_Type
*, int);
612 extern SLang_Array_Type
*_pSLstrings_to_array (char **strs
, unsigned int n
);
614 /* This function assumes that s is an slstring. */
615 extern char *_pSLstring_dup_slstring (char *);
616 extern int _pSLang_dup_and_push_slstring (char *);
619 extern int _pSLang_init_import (void);
620 extern int _pSLinit_exceptions (void);
622 /* This function checks to see if the referenced object is initialized */
623 extern int _pSLang_is_ref_initialized (SLang_Ref_Type
*);
624 extern int _pSLcheck_identifier_syntax (char *);
625 extern int _pSLang_uninitialize_ref (SLang_Ref_Type
*);
627 extern int _pSLpush_slang_obj (SLang_Object_Type
*);
629 extern char *_pSLexpand_escaped_char(char *, SLwchar_Type
*, int *);
630 extern void _pSLexpand_escaped_string (char *, char *, char *);
632 /* returns a pointer to an SLstring string-- use SLang_free_slstring */
633 extern char *_pSLstringize_object (SLang_Object_Type
*);
634 extern int _pSLdump_objects (char *, SLang_Object_Type
*, unsigned int, int);
636 extern SLang_Object_Type
*_pSLang_get_run_stack_pointer (void);
637 extern SLang_Object_Type
*_pSLang_get_run_stack_base (void);
638 extern int _pSLang_dump_stack (void);
639 extern int _pSLang_peek_at_stack2 (SLtype
*);
641 struct _pSLang_NameSpace_Type
643 struct _pSLang_NameSpace_Type
*next
;
644 char *name
; /* this is the load_type name */
645 char *namespace_name
; /* this name is assigned by implements */
647 unsigned int table_size
;
648 SLang_Name_Type
**table
;
650 extern SLang_NameSpace_Type
*_pSLns_new_namespace (char *, unsigned int);
651 extern SLang_NameSpace_Type
*_pSLns_allocate_namespace (char *, unsigned int);
652 extern void _pSLns_deallocate_namespace (SLang_NameSpace_Type
*);
653 extern SLang_NameSpace_Type
*_pSLns_find_namespace (char *);
654 extern int _pSLns_set_namespace_name (SLang_NameSpace_Type
*, char *);
655 extern SLang_Array_Type
*_pSLnspace_apropos (SLang_NameSpace_Type
*, char *, unsigned int);
656 extern void _pSLang_use_namespace_intrinsic (char *name
);
657 extern char *_pSLang_cur_namespace_intrinsic (void);
658 extern SLang_Array_Type
*_pSLang_apropos (char *, char *, unsigned int);
659 extern void _pSLang_implements_intrinsic (char *);
660 extern SLang_Array_Type
*_pSLns_list_namespaces (void);
661 extern SLang_Name_Type
*_pSLns_locate_hashed_name (SLang_NameSpace_Type
*, char *, unsigned long);
662 extern int _pSLns_add_hashed_name (SLang_NameSpace_Type
*, SLang_Name_Type
*, unsigned long);
663 extern SLang_NameSpace_Type
*_pSLns_find_object_namespace (SLang_Name_Type
*nt
);
664 extern SLang_Name_Type
*_pSLns_locate_name (SLang_NameSpace_Type
*, char *);
665 extern SLang_NameSpace_Type
*_pSLns_get_private_namespace (char *name
, char *nsname
);
666 extern SLang_NameSpace_Type
*_pSLns_create_namespace2 (char *name
, char *nsname
);
668 extern int _pSLang_Trace
;
669 extern char *_pSLang_current_function_name (void);
671 extern int _pSLang_trace_fun(char *);
673 /* This is a bitmapped variable */
674 extern int _pSLang_Compile_Line_Num_Info
;
676 extern int _pSLang_Compile_BOSEOS
;
677 extern int _pSLang_init_boseos (void);
678 extern int _pSLcall_bos_handler (char *, int);
679 extern int _pSLcall_eos_handler (void);
680 extern int _pSLcall_debug_hook (char *file
, int linenum
);
681 /* extern int _pSLcall_debug_hook (char *file, int linenum, char *funct); */
684 extern char *_pSLstring_dup_hashed_string (char *, unsigned long);
685 extern unsigned long _pSLcompute_string_hash (char *);
686 extern char *_pSLstring_make_hashed_string (char *, unsigned int, unsigned long *);
687 extern void _pSLfree_hashed_string (char *, unsigned int, unsigned long);
688 unsigned long _pSLstring_hash (unsigned char *, unsigned char *);
689 extern int _pSLinit_slcomplex (void);
691 extern int _pSLang_init_slstrops (void);
692 extern int _pSLstrops_do_sprintf_n (int);
693 extern int _pSLang_sscanf (void);
694 extern double _pSLang_atof (char *);
695 extern int _pSLang_init_bstring (void);
696 extern int _pSLang_init_sltime (void);
697 extern void _pSLpack (void);
698 extern void _pSLunpack (char *, SLang_BString_Type
*);
699 extern void _pSLpack_pad_format (char *);
700 extern unsigned int _pSLpack_compute_size (char *);
701 extern int _pSLusleep (unsigned long);
703 /* frees upon error. NULL __NOT__ ok. */
704 extern int _pSLang_push_slstring (char *);
706 extern SLtype
_pSLarith_promote_type (SLtype
);
707 extern int _pSLarith_get_precedence (SLtype
);
708 extern int _pSLarith_typecast (SLtype
, VOID_STAR
, unsigned int,
711 extern int SLang_push(SLang_Object_Type
*);
712 extern int SLadd_global_variable (char *);
714 extern int _pSLdo_pop (void);
715 extern unsigned int _pSLsys_getkey (void);
716 extern int _pSLsys_input_pending (int);
718 extern unsigned int _pSLpc_convert_scancode (unsigned int, unsigned int, int);
719 #define _pSLTT_KEY_SHIFT 1
720 #define _pSLTT_KEY_CTRL 2
721 #define _pSLTT_KEY_ALT 4
724 typedef struct _pSLterminfo_Type SLterminfo_Type
;
725 extern SLterminfo_Type
*_pSLtt_tigetent (char *);
726 extern char *_pSLtt_tigetstr (SLterminfo_Type
*, char *);
727 extern int _pSLtt_tigetnum (SLterminfo_Type
*, char *);
728 extern int _pSLtt_tigetflag (SLterminfo_Type
*, char *);
730 #if SLTT_HAS_NON_BCE_SUPPORT
731 extern int _pSLtt_get_bce_color_offset (void);
733 extern void (*_pSLtt_color_changed_hook
)(void);
735 extern unsigned char SLang_Input_Buffer
[SL_MAX_INPUT_BUFFER_LEN
];
737 typedef struct SL_OOBinary_Type
739 SLtype data_type
; /* partner type for binary op */
741 int (*binary_function
)_PROTO((int,
742 SLtype
, VOID_STAR
, unsigned int,
743 SLtype
, VOID_STAR
, unsigned int,
746 int (*binary_result
) _PROTO((int, SLtype
, SLtype
, SLtype
*));
747 struct SL_OOBinary_Type
*next
;
751 typedef struct _pSL_Typecast_Type
753 SLtype data_type
; /* to_type */
756 int (*typecast
)_PROTO((SLtype
, VOID_STAR
, unsigned int,
758 struct _pSL_Typecast_Type
*next
;
762 struct _pSLang_Class_Type
764 SLclass_Type cl_class_type
; /* vector, scalar, mmt, pointer */
766 unsigned int cl_data_type
; /* SLANG_INTEGER_TYPE, etc... */
767 char *cl_name
; /* slstring type */
769 size_t cl_sizeof_type
;
770 VOID_STAR cl_transfer_buf
; /* cl_sizeof_type bytes*/
774 /* Most of the method functions are prototyped:
775 * int method (SLtype type, VOID_STAR addr);
776 * Here, @type@ represents the type of object that the method is asked
777 * to deal with. The second parameter @addr@ will contain the ADDRESS of
778 * the object. For example, if type is SLANG_INT_TYPE, then @addr@ will
779 * actually be int *. Similary, if type is SLANG_STRING_TYPE,
780 * then @addr@ will contain the address of the string, i.e., char **.
783 void (*cl_destroy
)_PROTO((SLtype
, VOID_STAR
));
784 /* Prototype: void destroy(unsigned type, VOID_STAR val)
785 * Called to delete/free the object */
787 char *(*cl_string
)_PROTO((SLtype
, VOID_STAR
));
788 /* Prototype: char *to_string (SLtype t, VOID_STAR p);
789 * Here p is a pointer to the object for which a string representation
790 * is to be returned. The returned pointer is to be a MALLOCED string.
793 /* Prototype: void push(SLtype type, VOID_STAR v);
794 * Push a copy of the object of type @type@ at address @v@ onto the
797 int (*cl_push
)_PROTO((SLtype
, VOID_STAR
));
799 /* Prototype: int pop(SLtype type, VOID_STAR v);
800 * Pops value from stack and assign it to object, whose address is @v@.
802 int (*cl_pop
)_PROTO((SLtype
, VOID_STAR
));
804 /* mul2, sign, etc... */
805 int (*cl_unary_op_result_type
)_PROTO((int, SLtype
, SLtype
*));
806 int (*cl_unary_op
)_PROTO((int, SLtype
, VOID_STAR
, unsigned int, VOID_STAR
));
809 int (*cl_arith_unary_op_result_type
)_PROTO((int, SLtype
, SLtype
*));
810 int (*cl_arith_unary_op
)_PROTO((int, SLtype
, VOID_STAR
, unsigned int, VOID_STAR
));
812 int (*cl_app_unary_op_result_type
)_PROTO((int, SLtype
, SLtype
*));
813 int (*cl_app_unary_op
)_PROTO((int, SLtype
, VOID_STAR
, unsigned int, VOID_STAR
));
815 /* If this function is non-NULL, it will be called for sin, cos, etc... */
817 int (*cl_math_op
)_PROTO((int, SLtype
, VOID_STAR
, unsigned int, VOID_STAR
));
818 int (*cl_math_op_result_type
)_PROTO((int, SLtype
, SLtype
*));
820 SL_OOBinary_Type
*cl_binary_ops
;
821 SL_Typecast_Type
*cl_typecast_funs
;
823 void (*cl_byte_code_destroy
)_PROTO((SLtype
, VOID_STAR
));
824 void (*cl_user_destroy_fun
)_PROTO((SLtype
, VOID_STAR
));
825 int (*cl_init_array_object
)_PROTO((SLtype
, VOID_STAR
));
826 int (*cl_datatype_deref
)_PROTO((SLtype
));
827 SLang_Struct_Type
*cl_struct_def
;
828 int (*cl_dereference
) _PROTO((SLtype
, VOID_STAR
));
829 int (*cl_acopy
) (SLtype
, VOID_STAR
, VOID_STAR
);
830 int (*cl_apop
) _PROTO((SLtype
, VOID_STAR
));
831 int (*cl_apush
) _PROTO((SLtype
, VOID_STAR
));
832 int (*cl_push_literal
) _PROTO((SLtype
, VOID_STAR
));
833 void (*cl_adestroy
)_PROTO((SLtype
, VOID_STAR
));
834 int (*cl_push_intrinsic
)_PROTO((SLtype
, VOID_STAR
));
835 int (*cl_void_typecast
)_PROTO((SLtype
, VOID_STAR
, unsigned int, SLtype
, VOID_STAR
));
837 int (*cl_anytype_typecast
)_PROTO((SLtype
, VOID_STAR
, unsigned int, SLtype
, VOID_STAR
));
839 /* Array access functions */
840 int (*cl_aput
) (SLtype
, unsigned int);
841 int (*cl_aget
) (SLtype
, unsigned int);
842 int (*cl_anew
) (SLtype
, unsigned int);
845 int (*cl_length
) (SLtype
, VOID_STAR
, unsigned int *);
848 SLang_Foreach_Context_Type
*(*cl_foreach_open
) (SLtype
, unsigned int);
849 void (*cl_foreach_close
) (SLtype
, SLang_Foreach_Context_Type
*);
850 int (*cl_foreach
) (SLtype
, SLang_Foreach_Context_Type
*);
852 /* Structure access: get and put (assign to) fields */
853 int (*cl_sput
) (SLtype
, char *);
854 int (*cl_sget
) (SLtype
, char *);
857 int (*cl_fread
) (SLtype
, FILE *, VOID_STAR
, unsigned int, unsigned int *);
858 int (*cl_fwrite
) (SLtype
, FILE *, VOID_STAR
, unsigned int, unsigned int *);
859 int (*cl_fdread
) (SLtype
, int, VOID_STAR
, unsigned int, unsigned int *);
860 int (*cl_fdwrite
) (SLtype
, int, VOID_STAR
, unsigned int, unsigned int *);
862 int (*cl_to_bool
) (SLtype
, int *);
864 int (*cl_cmp
)(SLtype
, VOID_STAR
, VOID_STAR
, int *);
865 int (*cl_eqs
)(SLtype
, VOID_STAR
, SLtype
, VOID_STAR
);
866 SL_OOBinary_Type
*cl_void_binary_this
;
867 SL_OOBinary_Type
*cl_this_binary_void
;
871 extern int _pSLregister_types (void);
872 extern SLang_Class_Type
*_pSLclass_get_class (SLtype
);
873 extern VOID_STAR
_pSLclass_get_ptr_to_value (SLang_Class_Type
*, SLang_Object_Type
*);
874 extern void _pSLclass_type_mismatch_error (SLtype
, SLtype
);
875 extern int _pSLclass_init (void);
876 extern int _pSLclass_copy_class (SLtype
, SLtype
);
878 extern int (*_pSLclass_get_typecast (SLtype
, SLtype
, int))
879 (SLtype
, VOID_STAR
, unsigned int,
882 extern int (*_pSLclass_get_binary_fun (int, SLang_Class_Type
*, SLang_Class_Type
*, SLang_Class_Type
**, int))
884 SLtype
, VOID_STAR
, unsigned int,
885 SLtype
, VOID_STAR
, unsigned int,
888 extern int (*_pSLclass_get_unary_fun (int, SLang_Class_Type
*, SLang_Class_Type
**, int))
889 (int, SLtype
, VOID_STAR
, unsigned int, VOID_STAR
);
892 extern int _pSLclass_add_arith_unary_op (SLtype type
,
894 SLtype
, VOID_STAR
, unsigned int,
896 int (*r
)(int, SLtype
, SLtype
*));
899 extern int _pSLclass_get_unary_opcode (char *name
);
900 extern int _pSLclass_get_binary_opcode (char *name
);
901 extern int _pSLclass_is_same_obj (SLang_Object_Type
*a
, SLang_Object_Type
*b
);
902 extern int _pSLclass_obj_eqs (SLang_Object_Type
*a
, SLang_Object_Type
*b
);
904 extern int _pSLarith_register_types (void);
905 extern SLtype _pSLarith_Arith_Types
[];
907 extern int _pSLang_ref_is_callable (SLang_Ref_Type
*);
908 extern int _pSLang_is_arith_type (SLtype
);
909 extern void _pSLang_set_arith_type (SLtype
, unsigned char);
910 #if SLANG_OPTIMIZE_FOR_SPEED
911 extern SLclass_Type
_pSLang_get_class_type (SLtype
);
912 extern void _pSLang_set_class_info (SLtype
, SLang_Class_Type
*);
914 extern int _pSLarith_bin_op (SLang_Object_Type
*, SLang_Object_Type
*, int);
916 extern int _pSLarray_add_bin_op (SLtype
);
921 SLang_Name_Type
*next
;
926 SLang_Arith_Unary_Type
;
927 extern int _pSLadd_arith_unary_table (SLang_Arith_Unary_Type
*tbl
, char *);
932 SLang_Name_Type
*next
;
937 SLang_Arith_Binary_Type
;
938 extern int _pSLadd_arith_binary_table (SLang_Arith_Binary_Type
*tbl
, char *);
940 extern int _pSLang_call_funptr (SLang_Name_Type
*);
941 extern void _pSLset_double_format (char *);
942 extern SLang_Name_Type
*_pSLlocate_global_name (char *);
943 extern SLang_Name_Type
*_pSLlocate_name (char *);
945 extern char *_pSLdefines
[];
947 #define SL_ERRNO_NOT_IMPLEMENTED 0x7FFF
948 extern int _pSLerrno_errno
;
949 extern int _pSLerrno_init (void);
951 extern int _pSLstdio_fdopen (char *, int, char *);
953 extern void _pSLstruct_pop_args (int *);
954 extern void _pSLstruct_push_args (SLang_Array_Type
*);
956 extern int _pSLang_init_sllist (void);
957 extern int _pSLlist_inline_list (void);
959 extern int _pSLarray_aput1 (unsigned int);
960 extern int _pSLarray_aput (void);
961 extern int _pSLarray_aget (void);
962 extern int _pSLarray_aget1 (unsigned int);
963 extern int _pSLarray_inline_implicit_array (void);
964 extern int _pSLarray_inline_array (void);
965 extern int _pSLarray_wildcard_array (void);
968 _pSLarray_typecast (SLtype
, VOID_STAR
, unsigned int,
969 SLtype
, VOID_STAR
, int);
971 extern int _pSLarray_aput_transfer_elem (SLang_Array_Type
*, SLindex_Type
*,
972 VOID_STAR
, size_t, int);
973 extern int _pSLarray_aget_transfer_elem (SLang_Array_Type
*, SLindex_Type
*,
974 VOID_STAR
, size_t, int);
975 extern void _pSLarray_free_array_elements (SLang_Class_Type
*, VOID_STAR
, SLuindex_Type
);
977 extern SLang_Foreach_Context_Type
*
978 _pSLarray_cl_foreach_open (SLtype
, unsigned int);
979 extern void _pSLarray_cl_foreach_close (SLtype
, SLang_Foreach_Context_Type
*);
980 extern int _pSLarray_cl_foreach (SLtype
, SLang_Foreach_Context_Type
*);
982 extern int _pSLarray_matrix_multiply (void);
983 extern void (*_pSLang_Matrix_Multiply
)(void);
985 extern int _pSLarray_next_index (SLindex_Type
*, SLindex_Type
*, unsigned int);
987 extern int _pSLarray_init_slarray (void);
988 extern SLang_Array_Type
*
989 SLang_create_array1 (SLtype
, int, VOID_STAR
, SLindex_Type
*, unsigned int, int);
991 extern int _pSLassoc_aput (SLtype
, unsigned int);
992 extern int _pSLassoc_aget (SLtype
, unsigned int);
994 extern int _pSLcompile_push_context (SLang_Load_Type
*);
995 extern int _pSLcompile_pop_context (void);
996 extern int _pSLang_Auto_Declare_Globals
;
998 typedef struct _pSLang_Token_Type
1003 unsigned long ulong_val
;
1005 long long llong_val
;
1006 unsigned long long ullong_val
;
1008 /* Note that it is not wise to put a double field in the union because
1009 * when reading a preparsed file, I want to keep the user-specified
1010 * form to preserve the precision. Using a union member would mean
1011 * converting the double to a string when creating a preparsed file.
1012 * We can avoid the issues associated with this by just storing
1013 * floating point values as strings.
1015 char *s_val
; /* Used for IDENT_TOKEN, DOUBLE_TOKEN, etc... */
1017 SLang_BString_Type
*b_val
;
1020 unsigned int num_refs
;
1022 #if SLANG_HAS_DEBUG_CODE
1025 struct _pSLang_Token_Type
*next
; /* used for token lists */
1030 extern void _pSLcompile (_pSLang_Token_Type
*);
1031 extern void (*_pSLcompile_ptr
)(_pSLang_Token_Type
*);
1034 extern char *_pSLskip_whitespace (char *s
);
1037 extern char *_pSLpath_find_file (char *); /* slstring returned */
1039 /* Read but do not set this variable. */
1040 extern volatile int _pSLang_Error
;
1042 extern int _pSLutf8_mode
;
1043 extern int _pSLinterp_UTF8_Mode
; /* non-zero for interpreter */
1044 extern int _pSLtt_UTF8_Mode
;
1046 extern SLuchar_Type
*_pSLinterp_decode_wchar (SLuchar_Type
*u
,
1050 extern SLuchar_Type
*_pSLinterp_encode_wchar (SLwchar_Type wch
,
1052 unsigned int *encoded_lenp
);
1054 /* *** TOKENS *** */
1056 /* Note that that tokens corresponding to ^J, ^M, and ^Z should not be used.
1057 * This is because a file that contains any of these characters will
1058 * have an OS dependent interpretation, e.g., ^Z is EOF on MSDOS.
1061 /* Special tokens */
1062 #define ILLEGAL_TOKEN 0x00 /* no token has this value */
1063 #define EOF_TOKEN 0x01
1064 #define RPN_TOKEN 0x02
1065 #define NL_TOKEN 0x03
1066 #define NOP_TOKEN 0x05
1067 #define FARG_TOKEN 0x06
1068 #define TMP_TOKEN 0x07
1070 #define RESERVED1_TOKEN 0x0A /* \n */
1071 #define RESERVED2_TOKEN 0x0D /* \r */
1073 /* Literal tokens */
1074 #define CHAR_TOKEN 0x10
1075 #define UCHAR_TOKEN 0x11
1076 #define SHORT_TOKEN 0x12
1077 #define USHORT_TOKEN 0x13
1078 #define INT_TOKEN 0x14
1079 #define UINT_TOKEN 0x15
1080 #define LONG_TOKEN 0x16
1081 #define ULONG_TOKEN 0x17
1082 #define IS_INTEGER_TOKEN(x) ((x >= CHAR_TOKEN) && (x <= ULONG_TOKEN))
1083 #define FLOAT_TOKEN 0x18
1084 #define DOUBLE_TOKEN 0x19
1085 #define RESERVED3_TOKEN 0x1A /* ^Z */
1086 #define COMPLEX_TOKEN 0x1B
1087 #define STRING_TOKEN 0x1C
1088 #define BSTRING_TOKEN 0x1D
1089 #define _BSTRING_TOKEN 0x1E /* byte-compiled BSTRING */
1090 #define STRING_DOLLAR_TOKEN 0x1F
1092 /* Tokens that can be LVALUES */
1093 #define IDENT_TOKEN 0x20
1094 #define ARRAY_TOKEN 0x21
1095 #define DOT_TOKEN 0x22
1096 #define IS_LVALUE_TOKEN (((t) <= DOT_TOKEN) && ((t) >= IDENT_TOKEN))
1097 #define DOT_METHOD_CALL_TOKEN 0x23
1099 #define ESC_STRING_TOKEN 0x24
1100 #define ESC_BSTRING_TOKEN 0x25
1102 /* Flags for struct fields */
1103 #define STATIC_TOKEN 0x26
1104 #define READONLY_TOKEN 0x27
1105 #define PRIVATE_TOKEN 0x28
1106 #define PUBLIC_TOKEN 0x29
1108 /* Punctuation tokens */
1109 #define OBRACKET_TOKEN 0x2a
1110 #define CBRACKET_TOKEN 0x2b
1111 #define OPAREN_TOKEN 0x2c
1112 #define CPAREN_TOKEN 0x2d
1113 #define OBRACE_TOKEN 0x2e
1114 #define CBRACE_TOKEN 0x2f
1116 #define COMMA_TOKEN 0x31
1117 #define SEMICOLON_TOKEN 0x32
1118 #define COLON_TOKEN 0x33
1119 #define NAMESPACE_TOKEN 0x34
1122 #define POW_TOKEN 0x38
1124 /* The order here must match the order in the Binop_Level table in slparse.c */
1125 #define FIRST_BINARY_OP 0x39
1126 #define ADD_TOKEN 0x39
1127 #define SUB_TOKEN 0x3a
1128 #define TIMES_TOKEN 0x3b
1129 #define DIV_TOKEN 0x3c
1130 #define LT_TOKEN 0x3d
1131 #define LE_TOKEN 0x3e
1132 #define GT_TOKEN 0x3f
1133 #define GE_TOKEN 0x40
1134 #define EQ_TOKEN 0x41
1135 #define NE_TOKEN 0x42
1136 #define AND_TOKEN 0x43
1137 #define OR_TOKEN 0x44
1138 #define MOD_TOKEN 0x45
1139 #define BAND_TOKEN 0x46
1140 #define SHL_TOKEN 0x47
1141 #define SHR_TOKEN 0x48
1142 #define BXOR_TOKEN 0x49
1143 #define BOR_TOKEN 0x4a
1144 #define POUND_TOKEN 0x4b /* matrix multiplication */
1146 #define LAST_BINARY_OP 0x4b
1147 #define IS_BINARY_OP(t) ((t >= FIRST_BINARY_OP) && (t <= LAST_BINARY_OP))
1149 /* unary tokens -- but not all of them (see grammar) */
1150 #define DEREF_TOKEN 0x4d
1151 #define NOT_TOKEN 0x4e
1152 #define BNOT_TOKEN 0x4f
1154 #define IS_INTERNAL_FUNC(t) ((t >= 0x50) && (t <= 0x52))
1155 #define POP_TOKEN 0x50
1156 #define CHS_TOKEN 0x51
1157 #define EXCH_TOKEN 0x52
1159 #define LLONG_TOKEN 0x53
1160 #define ULLONG_TOKEN 0x54
1161 #define LDOUBLE_TOKEN 0x55
1163 /* Assignment tokens. Note: these must appear with sequential values.
1164 * The order here must match the specific lvalue assignments below.
1165 * These tokens are used by rpn routines in slang.c. slparse.c maps them
1166 * onto the specific lvalue tokens while parsing infix.
1167 * Also the assignment SLANG_BCST_ assumes this order
1169 #define ASSIGN_TOKEN 0x57
1170 #define PLUSEQS_TOKEN 0x58
1171 #define MINUSEQS_TOKEN 0x59
1172 #define TIMESEQS_TOKEN 0x5A
1173 #define DIVEQS_TOKEN 0x5B
1174 #define BOREQS_TOKEN 0x5C
1175 #define BANDEQS_TOKEN 0x5D
1176 #define PLUSPLUS_TOKEN 0x5E
1177 #define POST_PLUSPLUS_TOKEN 0x5F
1178 #define MINUSMINUS_TOKEN 0x60
1179 #define POST_MINUSMINUS_TOKEN 0x61
1182 #define FIRST_DIRECTIVE_TOKEN 0x62
1183 #define IFNOT_TOKEN 0x62
1184 #define IF_TOKEN 0x63
1185 #define ELSE_TOKEN 0x64
1186 #define FOREVER_TOKEN 0x65
1187 #define WHILE_TOKEN 0x66
1188 #define FOR_TOKEN 0x67
1189 #define _FOR_TOKEN 0x68
1190 #define LOOP_TOKEN 0x69
1191 #define SWITCH_TOKEN 0x6A
1192 #define DOWHILE_TOKEN 0x6B
1193 #define ANDELSE_TOKEN 0x6C
1194 #define ORELSE_TOKEN 0x6D
1195 #define ERRBLK_TOKEN 0x6E
1196 #define EXITBLK_TOKEN 0x6F
1197 /* These must be sequential */
1198 #define USRBLK0_TOKEN 0x70
1199 #define USRBLK1_TOKEN 0x71
1200 #define USRBLK2_TOKEN 0x72
1201 #define USRBLK3_TOKEN 0x73
1202 #define USRBLK4_TOKEN 0x74
1204 #define CONT_TOKEN 0x75
1205 #define BREAK_TOKEN 0x76
1206 #define RETURN_TOKEN 0x77
1208 #define CASE_TOKEN 0x78
1209 #define DEFINE_TOKEN 0x79
1210 #define DO_TOKEN 0x7a
1211 #define VARIABLE_TOKEN 0x7b
1212 #define GVARIABLE_TOKEN 0x7c
1213 #define _REF_TOKEN 0x7d
1214 #define PUSH_TOKEN 0x7e
1215 #define STRUCT_TOKEN 0x7f
1216 #define TYPEDEF_TOKEN 0x80
1217 #define NOTELSE_TOKEN 0x81
1218 #define DEFINE_STATIC_TOKEN 0x82
1219 #define FOREACH_TOKEN 0x83
1220 #define USING_TOKEN 0x84
1221 #define DEFINE_PRIVATE_TOKEN 0x85
1222 #define DEFINE_PUBLIC_TOKEN 0x86
1224 #define TRY_TOKEN 0x87
1225 #define CATCH_TOKEN 0x88
1226 #define THROW_TOKEN 0x89
1227 #define FINALLY_TOKEN 0x8a
1229 /* Note: the order here must match the order of the generic assignment tokens.
1230 * Also, the first token of each group must be the ?_ASSIGN_TOKEN.
1231 * slparse.c exploits this order, as well as slang.h.
1233 #define FIRST_ASSIGN_TOKEN 0x90
1234 #define _STRUCT_ASSIGN_TOKEN 0x90
1235 #define _STRUCT_PLUSEQS_TOKEN 0x91
1236 #define _STRUCT_MINUSEQS_TOKEN 0x92
1237 #define _STRUCT_TIMESEQS_TOKEN 0x93
1238 #define _STRUCT_DIVEQS_TOKEN 0x94
1239 #define _STRUCT_BOREQS_TOKEN 0x95
1240 #define _STRUCT_BANDEQS_TOKEN 0x96
1241 #define _STRUCT_PLUSPLUS_TOKEN 0x97
1242 #define _STRUCT_POST_PLUSPLUS_TOKEN 0x98
1243 #define _STRUCT_MINUSMINUS_TOKEN 0x99
1244 #define _STRUCT_POST_MINUSMINUS_TOKEN 0x9A
1246 #define _ARRAY_ASSIGN_TOKEN 0xA0
1247 #define _ARRAY_PLUSEQS_TOKEN 0xA1
1248 #define _ARRAY_MINUSEQS_TOKEN 0xA2
1249 #define _ARRAY_TIMESEQS_TOKEN 0xA3
1250 #define _ARRAY_DIVEQS_TOKEN 0xA4
1251 #define _ARRAY_BOREQS_TOKEN 0xA5
1252 #define _ARRAY_BANDEQS_TOKEN 0xA6
1253 #define _ARRAY_PLUSPLUS_TOKEN 0xA7
1254 #define _ARRAY_POST_PLUSPLUS_TOKEN 0xA8
1255 #define _ARRAY_MINUSMINUS_TOKEN 0xA9
1256 #define _ARRAY_POST_MINUSMINUS_TOKEN 0xAA
1258 #define _SCALAR_ASSIGN_TOKEN 0xB0
1259 #define _SCALAR_PLUSEQS_TOKEN 0xB1
1260 #define _SCALAR_MINUSEQS_TOKEN 0xB2
1261 #define _SCALAR_TIMESEQS_TOKEN 0xB3
1262 #define _SCALAR_DIVEQS_TOKEN 0xB4
1263 #define _SCALAR_BOREQS_TOKEN 0xB5
1264 #define _SCALAR_BANDEQS_TOKEN 0xB6
1265 #define _SCALAR_PLUSPLUS_TOKEN 0xB7
1266 #define _SCALAR_POST_PLUSPLUS_TOKEN 0xB8
1267 #define _SCALAR_MINUSMINUS_TOKEN 0xB9
1268 #define _SCALAR_POST_MINUSMINUS_TOKEN 0xBA
1270 #define _DEREF_ASSIGN_TOKEN 0xC0
1271 #define _DEREF_PLUSEQS_TOKEN 0xC1
1272 #define _DEREF_MINUSEQS_TOKEN 0xC2
1273 #define _DEREF_TIMESEQS_TOKEN 0xC3
1274 #define _DEREF_DIVEQS_TOKEN 0xC4
1275 #define _DEREF_BOREQS_TOKEN 0xC5
1276 #define _DEREF_BANDEQS_TOKEN 0xC6
1277 #define _DEREF_PLUSPLUS_TOKEN 0xC7
1278 #define _DEREF_POST_PLUSPLUS_TOKEN 0xC8
1279 #define _DEREF_MINUSMINUS_TOKEN 0xC9
1280 #define _DEREF_POST_MINUSMINUS_TOKEN 0xCA
1282 #define LAST_ASSIGN_TOKEN 0xCA
1283 #define IS_ASSIGN_TOKEN(t) (((t)>=FIRST_ASSIGN_TOKEN)&&((t)<=LAST_ASSIGN_TOKEN))
1285 #define _INLINE_ARRAY_TOKEN 0xE0
1286 #define _INLINE_IMPLICIT_ARRAY_TOKEN 0xE1
1287 #define _NULL_TOKEN 0xE2
1288 #define _INLINE_WILDCARD_ARRAY_TOKEN 0xE3
1289 #define _INLINE_LIST_TOKEN 0xE4
1291 #define BOS_TOKEN 0xFA
1292 #define EOS_TOKEN 0xFB
1293 #define LINE_NUM_TOKEN 0xFC
1294 #define ARG_TOKEN 0xFD
1295 #define EARG_TOKEN 0xFE
1296 #define NO_OP_LITERAL 0xFF
1301 /* SLang_eval_object */
1302 SLang_Load_Type
*llt
;
1303 SLprep_Type
*this_slpp
;
1304 /* prep_get_char() */
1311 _pSLang_Token_Type ctok
;
1313 int assignment_expression
;
1315 /* slang.c : SLcompile() */
1316 _pSLang_Token_Type save_token
;
1317 _pSLang_Token_Type next_token
;
1318 void (*slcompile_ptr
)(_pSLang_Token_Type
*);
1322 extern int _pSLget_token (_pSLang_Token_Type
*);
1323 extern void _pSLparse_error (int, char *, _pSLang_Token_Type
*, int);
1324 extern void _pSLparse_start (SLang_Load_Type
*);
1325 extern int _pSLget_rpn_token (_pSLang_Token_Type
*);
1326 extern void _pSLcompile_byte_compiled (void);
1328 extern int (*_pSLprep_eval_hook
) (char *);
1330 extern int _pSLsecure_issetugid (void);
1331 extern char *_pSLsecure_getenv (char *);
1333 /* Error Handling */
1334 extern int _pSLang_init_exceptions (void);
1335 extern int _pSLerr_init (void);
1336 extern void _pSLerr_deinit (void);
1337 extern int _pSLerr_suspend_messages (void);
1338 extern int _pSLerr_resume_messages (void);
1339 extern int _pSLerr_traceback_msg (char *, ...) SLATTRIBUTE_PRINTF(1,2);
1340 extern void _pSLerr_dump_msg (char *, ...) SLATTRIBUTE_PRINTF(1,2);
1341 extern void _pSLerr_clear_error (void);
1342 extern void _pSLerr_print_message_queue (void);
1344 extern int _pSLerr_set_line_info (char *, int, char *);
1345 extern int _pSLang_pop_error_context (void);
1346 extern int _pSLang_push_error_context (void);
1347 extern void (*_pSLinterpreter_Error_Hook
)(int);
1348 extern int _pSLerr_init_interp_exceptions (void);
1349 extern int _pSLerr_get_last_error (void);
1350 extern int _pSLerr_pop_exception (int *);
1351 extern void _pSLerr_free_queued_messages (void);
1352 extern char *_pSLerr_get_error_from_queue (void);
1353 extern int _pSLerr_throw (void);
1354 extern int (*_pSLerr_New_Exception_Hook
)(char *name
, char *desc
, int error_code
);
1356 #if SLANG_HAS_DEBUGGER_SUPPORT
1360 unsigned int nlocals
;
1366 _pSLang_Frame_Info_Type
;
1368 extern int _pSLang_get_frame_fun_info (int depth
, _pSLang_Frame_Info_Type
*info
);
1369 extern int _pSLang_set_frame_variable (int depth
, char *name
);
1370 extern int _pSLang_get_frame_variable (int depth
, char *name
);
1371 extern void _pSLang_use_frame_namespace (int depth
);
1372 extern int _pSLang_get_frame_depth (void);
1376 extern int _pSLmath_isnan (double x
);
1379 #if SLANG_HAS_SIGNALS
1380 extern void _pSLang_signal_interrupt (void);
1381 extern int _pSLsig_block_and_call (int (*)(VOID_STAR
), VOID_STAR
);
1382 extern int _pSLsig_handle_signals (void);
1383 extern int _pSLang_check_signals_hook (VOID_STAR
);
1385 #define _pSLsig_block_and_call(f,v) f(v)
1389 #if defined(__GNUC__) && SLANG_USE_INLINE_CODE
1390 # define _INLINE_ __inline__
1395 /* This is a macro that permits:
1397 * extern fun (void **addr);
1399 * fun ((void **) &x); <--- warning
1400 * fun (VOID_STAR_STAR(&x));
1402 * Otherwise a type-punning warning could result due to strict-aliasing.
1404 #define VOID_STAR_STAR(addr) (VOID_STAR *)(VOID_STAR)(addr)
1406 #endif /* PRIVATE_SLANG_H_ */