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. */ 5 /* 6 Copyright (C) 2004-2017,2018 John E. Davis 7 8 This file is part of the S-Lang Library. 9 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. 14 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. 19 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, 23 USA. 24 */ 25 26 /* #include "config.h" */ 27 #include "jdmacros.h" 28 #include "sllimits.h" 29 #include "_slint.h" 30 31 #ifdef VMS 32 # define SLANG_SYSTEM_NAME "_VMS" 33 #else 34 # if defined (IBMPC_SYSTEM) 35 # define SLANG_SYSTEM_NAME "_IBMPC" 36 # else 37 # define SLANG_SYSTEM_NAME "_UNIX" 38 # endif 39 #endif /* VMS */ 40 41 /* These quantities are main_types for byte-compiled code. They are used 42 * by the inner_interp routine. The _BC_ means byte-code. 43 */ 44 45 /* Nametype byte-codes --- these must correspond to those in slang.h */ 46 typedef enum 47 { 48 SLANG_BC_LAST_BLOCK = 0, 49 SLANG_BC_LVARIABLE = SLANG_LVARIABLE, /* 0x01 */ 50 SLANG_BC_GVARIABLE = SLANG_GVARIABLE, /* 0x02 */ 51 SLANG_BC_IVARIABLE = SLANG_IVARIABLE, /* 0x03 */ 52 SLANG_BC_RVARIABLE = SLANG_RVARIABLE, /* 0x04 */ 53 SLANG_BC_INTRINSIC = SLANG_INTRINSIC, /* 0x05 */ 54 SLANG_BC_FUNCTION = SLANG_FUNCTION, /* 0x06 */ 55 SLANG_BC_MATH_UNARY = SLANG_MATH_UNARY, /* 0x07 */ 56 SLANG_BC_APP_UNARY = SLANG_APP_UNARY, /* 0x08 */ 57 SLANG_BC_ARITH_UNARY = SLANG_ARITH_UNARY, /* 0x09 */ 58 SLANG_BC_ARITH_BINARY = SLANG_ARITH_BINARY, /* 0x0A */ 59 SLANG_BC_ICONST = SLANG_ICONSTANT, /* 0x0B */ 60 SLANG_BC_DCONST = SLANG_DCONSTANT, /* 0x0C */ 61 SLANG_BC_FCONST = SLANG_FCONSTANT, /* 0x0D */ 62 SLANG_BC_LLCONST = SLANG_LLCONSTANT, /* 0x0E */ 63 SLANG_BC_PVARIABLE = SLANG_PVARIABLE, /* 0x0F */ 64 SLANG_BC_PFUNCTION = SLANG_PFUNCTION, /* 0x10 */ 65 SLANG_BC_HCONST = SLANG_HCONSTANT, /* 0x11 */ 66 SLANG_BC_LCONST = SLANG_LCONSTANT, /* 0x12 */ 67 SLANG_BC_UNUSED_0x12 = 0x12, 68 SLANG_BC_UNUSED_0x13 = 0x13, 69 SLANG_BC_UNUSED_0x14 = 0x14, 70 SLANG_BC_UNUSED_0x15 = 0x15, 71 SLANG_BC_UNUSED_0x16 = 0x16, 72 SLANG_BC_UNUSED_0x17 = 0x17, 73 SLANG_BC_UNUSED_0x18 = 0x18, 74 SLANG_BC_UNUSED_0x19 = 0x19, 75 SLANG_BC_UNUSED_0x1A = 0x1A, 76 SLANG_BC_UNUSED_0x1B = 0x1B, 77 SLANG_BC_UNUSED_0x1C = 0x1C, 78 SLANG_BC_UNUSED_0x1D = 0x1D, 79 SLANG_BC_UNUSED_0x1E = 0x1E, 80 SLANG_BC_UNUSED_0x1F = 0x1F, 81 82 /* bytes codes for setting/assigning variables/arrays/structures/refs */ 83 SLANG_BC_SET_LOCAL_LVALUE = 0x20, 84 SLANG_BC_SET_GLOBAL_LVALUE = 0x21, 85 SLANG_BC_SET_INTRIN_LVALUE = 0x22, 86 SLANG_BC_SET_STRUCT_LVALUE = 0x23, 87 SLANG_BC_SET_ARRAY_LVALUE = 0x24, 88 SLANG_BC_SET_DEREF_LVALUE = 0x25, 89 SLANG_BC_FIELD = 0x26, 90 SLANG_BC_METHOD = 0x27, 91 SLANG_BC_LVARIABLE_AGET = 0x28, 92 SLANG_BC_LVARIABLE_APUT = 0x29, 93 SLANG_BC_LOBJPTR = 0x2A, 94 SLANG_BC_GOBJPTR = 0x2B, 95 SLANG_BC_FIELD_REF = 0x2C, 96 SLANG_BC_OBSOLETE_DEREF_FUN_CALL = 0x2D, 97 SLANG_BC_DEREF_FUN_CALL = 0x2E, 98 SLANG_BC_UNUSED_0x2F = 0x2F, 99 SLANG_BC_UNUSED_0x30 = 0x30, 100 SLANG_BC_UNUSED_0x31 = 0x31, 101 SLANG_BC_UNUSED_0x32 = 0x32, 102 SLANG_BC_UNUSED_0x33 = 0x33, 103 SLANG_BC_UNUSED_0x34 = 0x34, 104 SLANG_BC_UNUSED_0x35 = 0x35, 105 SLANG_BC_UNUSED_0x36 = 0x36, 106 SLANG_BC_UNUSED_0x37 = 0x37, 107 SLANG_BC_UNUSED_0x38 = 0x38, 108 SLANG_BC_UNUSED_0x39 = 0x39, 109 SLANG_BC_UNUSED_0x3A = 0x3A, 110 SLANG_BC_UNUSED_0x3B = 0x3B, 111 SLANG_BC_UNUSED_0x3C = 0x3C, 112 SLANG_BC_UNUSED_0x3D = 0x3D, 113 SLANG_BC_UNUSED_0x3E = 0x3E, 114 SLANG_BC_UNUSED_0x3F = 0x3F, 115 116 /* byte codes for literals */ 117 SLANG_BC_LITERAL = 0x40, /* constant objects */ 118 SLANG_BC_LITERAL_INT = 0x41, 119 SLANG_BC_LITERAL_DBL = 0x42, 120 SLANG_BC_LITERAL_STR = 0x43, 121 SLANG_BC_DOLLAR_STR = 0x44, 122 SLANG_BC_LITERAL_SHORT = 0x45, 123 SLANG_BC_LITERAL_LONG = 0x46, 124 SLANG_BC_UNUSED_0x45 = 0x45, 125 SLANG_BC_UNUSED_0x46 = 0x46, 126 SLANG_BC_UNUSED_0x47 = 0x47, 127 SLANG_BC_UNUSED_0x48 = 0x48, 128 SLANG_BC_UNUSED_0x49 = 0x49, 129 SLANG_BC_UNUSED_0x4A = 0x4A, 130 SLANG_BC_UNUSED_0x4B = 0x4B, 131 SLANG_BC_UNUSED_0x4C = 0x4C, 132 SLANG_BC_UNUSED_0x4D = 0x4D, 133 SLANG_BC_UNUSED_0x4E = 0x4E, 134 SLANG_BC_UNUSED_0x4F = 0x4F, 135 136 /* Unary/Binary operation codes */ 137 SLANG_BC_UNARY = 0x50, 138 SLANG_BC_BINARY = 0x51, 139 SLANG_BC_INTEGER_PLUS = 0x52, 140 SLANG_BC_INTEGER_MINUS = 0x53, 141 SLANG_BC_UNUSED_0x54 = 0x54, 142 SLANG_BC_UNUSED_0x55 = 0x55, 143 SLANG_BC_UNUSED_0x56 = 0x56, 144 SLANG_BC_UNUSED_0x57 = 0x57, 145 SLANG_BC_UNUSED_0x58 = 0x58, 146 SLANG_BC_UNUSED_0x59 = 0x59, 147 SLANG_BC_UNUSED_0x5A = 0x5A, 148 SLANG_BC_UNUSED_0x5B = 0x5B, 149 SLANG_BC_UNUSED_0x5C = 0x5C, 150 SLANG_BC_UNUSED_0x5D = 0x5D, 151 SLANG_BC_UNUSED_0x5E = 0x5E, 152 SLANG_BC_UNUSED_0x5F = 0x5F, 153 154 /* byte codes associated with keywords and blocks */ 155 SLANG_BC_TMP = 0x60, 156 SLANG_BC_EXCH = 0x61, 157 SLANG_BC_LABEL = 0x62, 158 SLANG_BC_BLOCK = 0x63, 159 SLANG_BC_RETURN = 0x64, 160 SLANG_BC_BREAK = 0x65, 161 SLANG_BC_CONTINUE = 0x66, 162 SLANG_BC_UNUSED_0x67 = 0x67, 163 SLANG_BC_CONTINUE_N = 0x68, 164 SLANG_BC_BREAK_N = 0x69, 165 SLANG_BC_X_ERROR = 0x6A, 166 SLANG_BC_X_USER0 = 0x6B, 167 SLANG_BC_X_USER1 = 0x6C, 168 SLANG_BC_X_USER2 = 0x6D, 169 SLANG_BC_X_USER3 = 0x6E, 170 SLANG_BC_X_USER4 = 0x6F, 171 172 /* byte codes for dealing with the frame pointer and arg list */ 173 SLANG_BC_CALL_DIRECT = 0x70, 174 SLANG_BC_CALL_DIRECT_FRAME = 0x71, 175 SLANG_BC_CALL_DIRECT_NARGS = 0x72, 176 SLANG_BC_EARG_LVARIABLE = 0x73, 177 #define USE_BC_LINE_NUM 0 /* used in slang.c */ 178 /* SLANG_BC_LINE_NUM = 0x74, */ 179 SLANG_BC_UNUSED_0x74 = 0x74, 180 SLANG_BC_BOS = 0x75, 181 SLANG_BC_EOS = 0x76, 182 SLANG_BC_UNUSED_0x77 = 0x77, 183 SLANG_BC_UNUSED_0x78 = 0x78, 184 SLANG_BC_UNUSED_0x79 = 0x79, 185 SLANG_BC_UNUSED_0x7A = 0x7A, 186 SLANG_BC_UNUSED_0x7B = 0x7B, 187 SLANG_BC_UNUSED_0x7C = 0x7C, 188 SLANG_BC_UNUSED_0x7D = 0x7D, 189 SLANG_BC_UNUSED_0x7E = 0x7E, 190 SLANG_BC_UNUSED_0x7F = 0x7F, 191 192 /* These are used only when compiled with USE_COMBINED_BYTECODES */ 193 SLANG_BC_CALL_DIRECT_INTRINSIC= 0x80, 194 SLANG_BC_INTRINSIC_CALL_DIRECT= 0x81, 195 SLANG_BC_CALL_DIRECT_LSTR = 0x82, 196 SLANG_BC_CALL_DIRECT_SLFUN = 0x83, 197 SLANG_BC_CALL_DIRECT_RETINTR = 0x84, 198 SLANG_BC_RET_INTRINSIC = 0x85, 199 SLANG_BC_CALL_DIRECT_EARG_LVAR= 0x86, 200 SLANG_BC_CALL_DIRECT_LINT = 0x87, 201 SLANG_BC_CALL_DIRECT_LVAR = 0x88, 202 SLANG_BC_LLVARIABLE_BINARY = 0x89, 203 SLANG_BC_LGVARIABLE_BINARY = 0x8A, 204 SLANG_BC_GLVARIABLE_BINARY = 0x8B, 205 SLANG_BC_GGVARIABLE_BINARY = 0x8C, 206 SLANG_BC_LIVARIABLE_BINARY = 0x8D, 207 SLANG_BC_LDVARIABLE_BINARY = 0x8E, 208 SLANG_BC_ILVARIABLE_BINARY = 0x8F, 209 SLANG_BC_DLVARIABLE_BINARY = 0x90, 210 SLANG_BC_LVARIABLE_BINARY = 0x91, 211 SLANG_BC_GVARIABLE_BINARY = 0x92, 212 SLANG_BC_LITERAL_INT_BINARY = 0x93, 213 SLANG_BC_LITERAL_DBL_BINARY = 0x94, 214 SLANG_BC_LASSIGN_LLBINARY = 0x95, 215 SLANG_BC_LASSIGN_LIBINARY = 0x96, 216 SLANG_BC_LASSIGN_ILBINARY = 0x97, 217 SLANG_BC_LASSIGN_LDBINARY = 0x98, 218 SLANG_BC_LASSIGN_DLBINARY = 0x99, 219 SLANG_BC_RET_LVARIABLE = 0x9A, 220 SLANG_BC_RET_LITERAL_INT = 0x9B, 221 SLANG_BC_MANY_LVARIABLE = 0x9C, 222 SLANG_BC_MANY_LVARIABLE_DIR = 0x9D, 223 SLANG_BC_LVARIABLE_AGET1 = 0x9E, 224 SLANG_BC_LITERAL_AGET1 = 0x9F, 225 SLANG_BC_LVAR_LVAR_APUT1 = 0xA0, 226 SLANG_BC_LVARIABLE_APUT1 = 0xA1, 227 SLANG_BC_LITERAL_APUT1 = 0xA2, 228 SLANG_BC_LLVARIABLE_BINARY2 = 0xA3, 229 SLANG_BC_SET_LOCLV_LIT_INT = 0xA4, 230 SLANG_BC_SET_LOCLV_LIT_AGET1 = 0xA5, 231 SLANG_BC_SET_LOCLV_LVAR = 0xA6, 232 SLANG_BC_SET_LOCLV_LASTBLOCK = 0xA7, 233 SLANG_BC_LVAR_EARG_LVAR = 0xA8, 234 SLANG_BC_LVAR_FIELD = 0xA9, 235 SLANG_BC_BINARY_LASTBLOCK = 0xAA, 236 SLANG_BC_EARG_LVARIABLE_INTRINSIC = 0xAB, 237 SLANG_BC_LVAR_LITERAL_INT = 0xAC, 238 SLANG_BC_BINARY_SET_LOCLVAL = 0xAD, 239 SLANG_BC_LVAR_AGET_SET_LOCLVAL = 0xAE, 240 SLANG_BC_LLVAR_BINARY_IF = 0xAF, 241 242 SLANG_BC_IF_BLOCK = 0xB0, 243 SLANG_BC_LVAR_SET_FIELD = 0xB1, 244 SLANG_BC_PVAR_SET_GLOB_LVAL = 0xB2, 245 SLANG_BC_LVAR_SET_GLOB_LVAL = 0xB3, 246 SLANG_BC_LIT_AGET1_INT_BINARY= 0xB4, 247 SLANG_BC_BINARY2 = 0xB5, 248 SLANG_BC_LVAR_LIT_AGET1 = 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 259 /* The following do not actually occur in inner_interp. They used 260 * to signify the bytecode has been combined with another. 261 */ 262 SLANG_BC_LVARIABLE_COMBINED = 0xC0, 263 SLANG_BC_GVARIABLE_COMBINED = 0xC1, 264 SLANG_BC_LITERAL_COMBINED = 0xC2, 265 SLANG_BC_CALL_DIRECT_COMB = 0xC3, 266 SLANG_BC_COMBINED = 0xC4, 267 SLANG_BC_BLOCK_COMBINED = 0xC5, 268 #define SLANG_IS_BC_COMBINED(b) ((0xC0 <= (b)) && ((b) <= 0xC5)) 269 SLANG_BC_UNUSED_0xC6 = 0xC6, 270 SLANG_BC_UNUSED_0xC7 = 0xC7, 271 SLANG_BC_UNUSED_0xC8 = 0xC8, 272 SLANG_BC_UNUSED_0xC9 = 0xC9, 273 SLANG_BC_UNUSED_0xCA = 0xCA, 274 SLANG_BC_UNUSED_0xCB = 0xCB, 275 SLANG_BC_UNUSED_0xCC = 0xCC, 276 SLANG_BC_UNUSED_0xCD = 0xCD, 277 SLANG_BC_UNUSED_0xCE = 0xCE, 278 SLANG_BC_UNUSED_0xCF = 0xCF, 279 SLANG_BC_UNUSED_0xD0 = 0xD0, 280 SLANG_BC_UNUSED_0xD1 = 0xD1, 281 SLANG_BC_UNUSED_0xD2 = 0xD2, 282 SLANG_BC_UNUSED_0xD3 = 0xD3, 283 SLANG_BC_UNUSED_0xD4 = 0xD4, 284 SLANG_BC_UNUSED_0xD5 = 0xD5, 285 SLANG_BC_UNUSED_0xD6 = 0xD6, 286 SLANG_BC_UNUSED_0xD7 = 0xD7, 287 SLANG_BC_UNUSED_0xD8 = 0xD8, 288 SLANG_BC_UNUSED_0xD9 = 0xD9, 289 SLANG_BC_UNUSED_0xDA = 0xDA, 290 SLANG_BC_UNUSED_0xDB = 0xDB, 291 SLANG_BC_UNUSED_0xDC = 0xDC, 292 SLANG_BC_UNUSED_0xDD = 0xDD, 293 SLANG_BC_UNUSED_0xDE = 0xDE, 294 SLANG_BC_UNUSED_0xDF = 0xDF, 295 SLANG_BC_UNUSED_0xE0 = 0xE0, 296 SLANG_BC_UNUSED_0xE1 = 0xE1, 297 SLANG_BC_UNUSED_0xE2 = 0xE2, 298 SLANG_BC_UNUSED_0xE3 = 0xE3, 299 SLANG_BC_UNUSED_0xE4 = 0xE4, 300 SLANG_BC_UNUSED_0xE5 = 0xE5, 301 SLANG_BC_UNUSED_0xE6 = 0xE6, 302 SLANG_BC_UNUSED_0xE7 = 0xE7, 303 SLANG_BC_UNUSED_0xE8 = 0xE8, 304 SLANG_BC_UNUSED_0xE9 = 0xE9, 305 SLANG_BC_UNUSED_0xEA = 0xEA, 306 SLANG_BC_UNUSED_0xEB = 0xEB, 307 SLANG_BC_UNUSED_0xEC = 0xEC, 308 SLANG_BC_UNUSED_0xED = 0xED, 309 SLANG_BC_UNUSED_0xEE = 0xEE, 310 SLANG_BC_UNUSED_0xEF = 0xEF, 311 SLANG_BC_UNUSED_0xF0 = 0xF0, 312 SLANG_BC_UNUSED_0xF1 = 0xF1, 313 SLANG_BC_UNUSED_0xF2 = 0xF2, 314 SLANG_BC_UNUSED_0xF3 = 0xF3, 315 SLANG_BC_UNUSED_0xF4 = 0xF4, 316 SLANG_BC_UNUSED_0xF5 = 0xF5, 317 SLANG_BC_UNUSED_0xF6 = 0xF6, 318 SLANG_BC_UNUSED_0xF7 = 0xF7, 319 SLANG_BC_UNUSED_0xF8 = 0xF8, 320 SLANG_BC_UNUSED_0xF9 = 0xF9, 321 SLANG_BC_UNUSED_0xFA = 0xFA, 322 SLANG_BC_UNUSED_0xFB = 0xFB, 323 SLANG_BC_UNUSED_0xFC = 0xFC, 324 SLANG_BC_UNUSED_0xFD = 0xFD, 325 SLANG_BC_UNUSED_0xFE = 0xFE, 326 SLANG_BC_UNUSED_0xFF = 0xFF 327 } 328 _pSLang_BC_Type; 329 330 /* Byte-Code Sub Types (_BCST_) */ 331 332 /* These are sub_types of SLANG_BC_BLOCK */ 333 #define SLANG_BCST_ERROR_BLOCK 0x01 334 #define SLANG_BCST_EXIT_BLOCK 0x02 335 #define SLANG_BCST_USER_BLOCK0 0x03 336 #define SLANG_BCST_USER_BLOCK1 0x04 337 #define SLANG_BCST_USER_BLOCK2 0x05 338 #define SLANG_BCST_USER_BLOCK3 0x06 339 #define SLANG_BCST_USER_BLOCK4 0x07 340 /* The user blocks MUST be in the above order */ 341 #define SLANG_BCST_LOOP 0x10 342 #define SLANG_BCST_WHILE 0x11 343 #define SLANG_BCST_FOR 0x12 344 #define SLANG_BCST_FOREVER 0x13 345 #define SLANG_BCST_CFOR 0x14 346 #define SLANG_BCST_DOWHILE 0x15 347 #define SLANG_BCST_FOREACH 0x16 /* obsolete */ 348 #define SLANG_BCST_TRY 0x17 349 #define SLANG_BCST_FOREACH_EARGS 0x18 350 351 #define SLANG_BCST_IF 0x20 352 #define SLANG_BCST_IFNOT 0x21 353 #define SLANG_BCST_ELSE 0x22 354 #define SLANG_BCST_ANDELSE 0x23 355 #define SLANG_BCST_ORELSE 0x24 356 #define SLANG_BCST_SWITCH 0x25 357 #define SLANG_BCST_NOTELSE 0x26 358 #define SLANG_BCST_SC_OR 0x27 359 #define SLANG_BCST_SC_AND 0x28 360 361 #define SLANG_BCST_LOOP_ELSE 0x29 362 #define SLANG_BCST_LOOP_THEN 0x30 363 #define SLANG_BCST_COMPARE 0x31 364 365 /* assignment (SLANG_BC_SET_*_LVALUE) subtypes. The order MUST correspond 366 * to the assignment token order with the ASSIGN_TOKEN as the first! 367 */ 368 #define SLANG_BCST_ASSIGN 0x01 369 #define SLANG_BCST_PLUSEQS 0x02 370 #define SLANG_BCST_MINUSEQS 0x03 371 #define SLANG_BCST_TIMESEQS 0x04 372 #define SLANG_BCST_DIVEQS 0x05 373 #define SLANG_BCST_BOREQS 0x06 374 #define SLANG_BCST_BANDEQS 0x07 375 #define SLANG_BCST_PLUSPLUS 0x08 376 #define SLANG_BCST_POST_PLUSPLUS 0x09 377 #define SLANG_BCST_MINUSMINUS 0x0A 378 #define SLANG_BCST_POST_MINUSMINUS 0x0B 379 380 typedef union 381 { 382 #if SLANG_HAS_FLOAT 383 double double_val; 384 float float_val; 385 #endif 386 #ifdef HAVE_LONG_LONG 387 long long llong_val; 388 unsigned long long ullong_val; 389 #endif 390 long long_val; 391 unsigned long ulong_val; 392 VOID_STAR ptr_val; 393 char *s_val; 394 int int_val; 395 unsigned int uint_val; 396 SLang_MMT_Type *ref; 397 SLang_Name_Type *n_val; 398 struct _pSLang_Struct_Type *struct_val; 399 struct _pSLang_Array_Type *array_val; 400 short short_val; 401 unsigned short ushort_val; 402 signed char char_val; 403 unsigned char uchar_val; 404 SLindex_Type index_val; 405 _pSLint16_Type int16_val; 406 _pSLuint16_Type uint16_val; 407 _pSLint32_Type int32_val; 408 _pSLuint32_Type uint32_val; 409 #if _pSLANG_INT64_TYPE 410 _pSLint64_Type int64_val; 411 _pSLuint64_Type uint64_val; 412 #endif 413 } 414 _pSL_Object_Union_Type; 415 416 typedef struct _pSLang_Object_Type 417 { 418 SLtype o_data_type; /* SLANG_INT_TYPE, ... */ 419 _pSL_Object_Union_Type v; 420 } 421 SLang_Object_Type; 422 423 typedef struct 424 { 425 char *name; 426 SLang_Name_Type *next; 427 char name_type; 428 429 SLang_Object_Type obj; 430 } 431 SLang_Global_Var_Type; 432 433 struct _pSLang_MMT_Type 434 { 435 SLtype data_type; /* int, string, etc... */ 436 VOID_STAR user_data; /* address of user structure */ 437 unsigned int count; /* number of references */ 438 }; 439 440 extern int _pSLang_pop_object_of_type (SLtype, SLang_Object_Type *, int); 441 442 typedef struct 443 { 444 SLFUTURE_CONST char *name; /* slstring */ 445 SLang_Object_Type obj; 446 } 447 _pSLstruct_Field_Type; 448 449 typedef struct _pSLang_Struct_Type 450 { 451 _pSLstruct_Field_Type *fields; 452 unsigned int nfields; /* number used */ 453 unsigned int num_refs; 454 /* user-defined methods */ 455 SLang_Name_Type *destroy_method; 456 } 457 _pSLang_Struct_Type; 458 459 extern int _pSLstruct_init (void); 460 extern int _pSLstruct_define_struct (void); 461 extern int _pSLstruct_define_struct2 (void); 462 extern int _pSLstruct_define_typedef (void); 463 464 extern SLang_Object_Type *_pSLstruct_get_field_value (SLang_Struct_Type *, SLCONST char *); 465 extern int _pSLstruct_push_field_ref (SLFUTURE_CONST char *); 466 extern int _pSLstruct_push_field (SLang_Struct_Type *s, SLFUTURE_CONST char *name, int do_free); 467 extern int _pSLstruct_pop_field (SLang_Struct_Type *s, SLFUTURE_CONST char *name, int do_free); 468 469 extern int _pSLang_get_qualifiers_intrin (SLang_Struct_Type **); 470 471 struct _pSLang_Ref_Type 472 { 473 int num_refs; 474 VOID_STAR data; 475 unsigned int sizeof_data; 476 int data_is_nametype; /* used for optimization */ 477 int (*deref_assign)(VOID_STAR); 478 int (*deref) (VOID_STAR); 479 char *(*string)(VOID_STAR); /* returns a malloced string */ 480 void (*destroy) (VOID_STAR); 481 int (*is_initialized) (VOID_STAR); 482 int (*uninitialize) (VOID_STAR); 483 }; 484 485 extern int _pSLang_dereference_ref (SLang_Ref_Type *); 486 extern int _pSLang_deref_assign (SLang_Ref_Type *); 487 extern int SLang_push_ref (SLang_Ref_Type *); 488 extern int _pSLang_push_nt_as_ref (SLang_Name_Type *); 489 extern SLang_Ref_Type *_pSLang_new_ref (unsigned int); 490 491 extern int _pSL_increment_frame_pointer (void); 492 extern int _pSL_decrement_frame_pointer (void); 493 494 extern int SLang_pop(SLang_Object_Type *); 495 extern void SLang_free_object (SLang_Object_Type *); 496 extern int _pSLanytype_typecast (SLtype, VOID_STAR, SLuindex_Type, 497 SLtype, VOID_STAR); 498 extern void _pSLstring_intrinsic (void); 499 extern int _pSLformat_as_binary (unsigned int min_num_bits, int use_binary_prefix); 500 501 #if 0 502 /* NULL not allowed here */ 503 extern char *_pSLmalloced_to_slstring (char *, unsigned int); 504 /* But here it is ok */ 505 extern int _pSLpush_malloced_string (char *, unsigned int); 506 #endif 507 508 /* These functions are used to create slstrings of a fixed length. Be 509 * very careful how they are used. In particular, if len bytes are allocated, 510 * then the string must be len characters long, no more and no less. 511 */ 512 extern char *_pSLallocate_slstring (size_t); 513 extern char *_pSLcreate_via_alloced_slstring (char *, size_t); 514 extern void _pSLunallocate_slstring (char *, size_t); 515 extern int _pSLpush_alloced_slstring (char *, size_t); 516 517 extern size_t _pSLstring_bytelen (SLCONST SLstr_Type *); 518 extern void _pSLang_free_slstring (SLstr_Type *); /* slstring required and assumed */ 519 extern SLstr_Hash_Type _pSLstring_get_hash (SLstr_Type *s); /* slstring required */ 520 521 typedef struct 522 { 523 char **buf; 524 unsigned int max_num; 525 unsigned int num; 526 unsigned int delta_num; 527 int is_malloced; /* non-zero if object was malloced */ 528 } 529 _pSLString_List_Type; 530 531 /* Note that _pSLstring_list_append makes no copy of the object-- it steals it. 532 * For a copy, use _pSLstring_list_append_copy */ 533 extern int _pSLstring_list_append (_pSLString_List_Type *, char *); 534 extern int _pSLstring_list_append_copy (_pSLString_List_Type *, char *); 535 extern int _pSLstring_list_init (_pSLString_List_Type *, unsigned int, unsigned int); 536 extern _pSLString_List_Type *_pSLstring_list_new (unsigned int, unsigned int); 537 extern void _pSLstring_list_delete (_pSLString_List_Type *); 538 extern int _pSLstring_list_push (_pSLString_List_Type *, int); 539 extern SLang_Array_Type *_pSLstrings_to_array (char **strs, unsigned int n); 540 541 /* This function assumes that s is an slstring. */ 542 extern SLCONST char *_pSLstring_dup_slstring (SLCONST char *); 543 extern int _pSLang_dup_and_push_slstring (SLCONST char *); 544 545 extern int _pSLang_init_import (void); 546 extern int _pSLinit_exceptions (void); 547 548 /* This function checks to see if the referenced object is initialized */ 549 extern int _pSLang_is_ref_initialized (SLang_Ref_Type *); 550 extern int _pSLcheck_identifier_syntax (SLCONST char *); 551 extern int _pSLang_uninitialize_ref (SLang_Ref_Type *); 552 553 extern int _pSLpush_slang_obj (SLang_Object_Type *); 554 extern int _pSLslang_copy_obj (SLang_Object_Type *obja, SLang_Object_Type *objb); 555 556 extern char *_pSLexpand_escaped_char(char *, char *, SLwchar_Type *, int *); 557 extern void _pSLexpand_escaped_string (char *, char *, char *); 558 559 extern int _pSLpush_dollar_string (SLFUTURE_CONST char *); 560 561 /* returns a pointer to an SLstring string-- use SLang_free_slstring */ 562 extern char *_pSLstringize_object (SLang_Object_Type *); 563 extern int _pSLdump_objects (char *, SLang_Object_Type *, unsigned int, int); 564 565 extern SLang_Object_Type *_pSLang_get_run_stack_pointer (void); 566 extern SLang_Object_Type *_pSLang_get_run_stack_base (void); 567 extern int _pSLang_dump_stack (void); 568 extern int _pSLang_peek_at_stack2 (SLtype *); 569 extern int _pSLang_restart_arg_list (int nargs); 570 571 struct _pSLang_NameSpace_Type 572 { 573 struct _pSLang_NameSpace_Type *next; 574 SLFUTURE_CONST char *name; /* this is the load_type name */ 575 SLFUTURE_CONST char *namespace_name;/* this name is assigned by implements */ 576 SLFUTURE_CONST char *private_name; 577 unsigned int table_size; 578 SLang_Name_Type **table; 579 }; 580 581 extern int _pSLns_check_name (SLFUTURE_CONST char *); 582 extern SLang_NameSpace_Type *_pSLns_new_namespace (SLFUTURE_CONST char *, unsigned int); 583 extern SLang_NameSpace_Type *_pSLns_allocate_namespace (SLFUTURE_CONST char *, unsigned int); 584 extern void _pSLns_deallocate_namespace (SLang_NameSpace_Type *); 585 extern SLang_NameSpace_Type *_pSLns_find_namespace (SLCONST char *); 586 extern int _pSLns_set_namespace_name (SLang_NameSpace_Type *, SLFUTURE_CONST char *); 587 extern SLang_Array_Type *_pSLnspace_apropos (SLang_NameSpace_Type *, SLFUTURE_CONST char *, unsigned int); 588 extern void _pSLang_use_namespace_intrinsic (char *name); 589 extern SLFUTURE_CONST char *_pSLang_cur_namespace_intrinsic (void); 590 extern SLang_Array_Type *_pSLang_apropos (SLFUTURE_CONST char *, SLFUTURE_CONST char *, unsigned int); 591 extern void _pSLang_implements_intrinsic (SLFUTURE_CONST char *); 592 extern SLang_Array_Type *_pSLns_list_namespaces (void); 593 extern SLang_Name_Type *_pSLns_locate_hashed_name (SLang_NameSpace_Type *, SLCONST char *, SLstr_Hash_Type); 594 extern int _pSLns_add_hashed_name (SLang_NameSpace_Type *, SLang_Name_Type *, SLstr_Hash_Type); 595 extern SLang_NameSpace_Type *_pSLns_find_object_namespace (SLang_Name_Type *nt); 596 extern SLang_Name_Type *_pSLns_locate_name (SLang_NameSpace_Type *, SLCONST char *); 597 extern SLang_NameSpace_Type *_pSLns_get_private_namespace (SLFUTURE_CONST char *name, SLFUTURE_CONST char *nsname); 598 extern SLang_NameSpace_Type *_pSLns_create_namespace2 (SLFUTURE_CONST char *name, SLFUTURE_CONST char *nsname); 599 extern void _pSLns_delete_namespaces (void); 600 601 /* The long-long constants functions need to be fixed in slang.h. This will 602 * have to wait for a major version change. 603 */ 604 #ifdef HAVE_LONG_LONG 605 typedef struct 606 { 607 SLFUTURE_CONST char *name; 608 SLang_Name_Type *next; 609 char name_type; 610 611 SLtype data_type; 612 long long value; 613 } 614 _pSLang_LLConstant_Type; 615 SL_EXTERN int _pSLns_add_llconstant_table (SLang_NameSpace_Type *, _pSLang_LLConstant_Type *, SLFUTURE_CONST char *); 616 SL_EXTERN int _pSLadd_llconstant_table (_pSLang_LLConstant_Type *, SLFUTURE_CONST char *); 617 SL_EXTERN int _pSLns_add_llconstant (SLang_NameSpace_Type *, SLFUTURE_CONST char *, SLtype, long long); 618 # define _pMAKE_LLCONSTANT_T(n,val,T) \ 619 {(n),NULL, SLANG_LLCONSTANT, T, (long long)(val)} 620 # define _pSLANG_END_LLCONST_TABLE _pMAKE_LLCONSTANT_T(NULL,0,0) 621 #endif 622 623 extern int _pSLang_Trace; 624 extern char SLCONST *_pSLang_current_function_name (void); 625 626 extern int _pSLang_trace_fun(SLFUTURE_CONST char *); 627 628 /* This is a bitmapped variable */ 629 /* extern int _pSLang_Compile_Line_Num_Info; */ 630 #if SLANG_HAS_BOSEOS 631 extern int _pSLang_Compile_BOSEOS; 632 #define SLANG_BOSEOS_VALUE_BITS 0x0FF 633 #define SLANG_BOSEOS_PREPROC 0x100 634 extern int _pSLang_Compile_BOFEOF; 635 extern int _pSLang_init_boseos (void); 636 extern int _pSLcall_bos_handler (SLFUTURE_CONST char *, int); 637 extern int _pSLcall_eos_handler (void); 638 extern int _pSLcall_bof_handler (SLFUTURE_CONST char *, SLFUTURE_CONST char *); 639 extern int _pSLcall_eof_handler (void); 640 extern int _pSLcall_debug_hook (SLFUTURE_CONST char *file, int linenum); 641 /* extern int _pSLcall_debug_hook (char *file, int linenum, char *funct); */ 642 #endif 643 644 extern char *_pSLstring_dup_hashed_string (SLCONST char *, SLstr_Hash_Type); 645 extern char *_pSLstring_make_hashed_string (SLCONST char *, SLstrlen_Type, SLstr_Hash_Type *); 646 extern void _pSLfree_hashed_string (SLCONST char *, size_t, SLstr_Hash_Type); 647 SLstr_Hash_Type _pSLstring_hash (SLCONST unsigned char *, SLCONST unsigned char *); 648 extern int _pSLinit_slcomplex (void); 649 650 extern int _pSLang_init_slstrops (void); 651 extern int _pSLstrops_do_sprintf_n (int); 652 extern int _pSLang_sscanf (void); 653 extern double _pSLang_atof (SLFUTURE_CONST char *); 654 655 extern int _pSLang_init_bstring (void); 656 extern SLang_Foreach_Context_Type *_pSLbstring_foreach_open (SLtype type, unsigned int num); 657 extern void _pSLbstring_foreach_close (SLtype type, SLang_Foreach_Context_Type *c); 658 extern int _pSLbstring_foreach (SLtype type, SLang_Foreach_Context_Type *c); 659 660 extern int _pSLang_init_sltime (void); 661 extern int _pSLusleep (unsigned long); 662 663 #define _pSLANG_BYTEORDER_NATIVE 0 664 #define _pSLANG_BYTEORDER_BIGE 1 665 #define _pSLANG_BYTEORDER_LILE 2 666 extern void _pSLpack (void); 667 extern void _pSLunpack (char *, SLang_BString_Type *); 668 extern void _pSLpack_pad_format (char *); 669 extern SLstrlen_Type _pSLpack_compute_size (char *); 670 extern SLang_Array_Type *_pSLpack_byteswap_array (SLang_Array_Type *at, int from, int to); 671 672 /* frees upon error. NULL __NOT__ ok. */ 673 extern int _pSLang_push_slstring (char *); 674 675 extern SLtype _pSLarith_promote_type (SLtype); 676 extern int _pSLarith_get_precedence (SLtype); 677 extern int _pSLarith_typecast (SLtype, VOID_STAR, SLuindex_Type, 678 SLtype, VOID_STAR); 679 680 extern int SLang_push(SLang_Object_Type *); 681 extern int SLadd_global_variable (SLCONST char *); 682 683 extern int _pSLdo_pop (void); 684 extern unsigned int _pSLsys_getkey (void); 685 extern int _pSLsys_input_pending (int); 686 #ifdef IBMPC_SYSTEM 687 extern unsigned int _pSLpc_convert_scancode (unsigned int, unsigned int, int); 688 #define _pSLTT_KEY_SHIFT 1 689 #define _pSLTT_KEY_CTRL 2 690 #define _pSLTT_KEY_ALT 4 691 #endif 692 693 typedef struct _pSLterminfo_Type SLterminfo_Type; 694 extern SLterminfo_Type *_pSLtt_tigetent (SLCONST char *); 695 extern void _pSLtt_tifreeent (SLterminfo_Type *); 696 extern char *_pSLtt_tigetstr (SLterminfo_Type *, SLCONST char *); 697 extern int _pSLtt_tigetnum (SLterminfo_Type *, SLCONST char *); 698 extern int _pSLtt_tigetflag (SLterminfo_Type *, SLCONST char *); 699 700 #if defined(REAL_UNIX_SYSTEM) || defined(VMS) 701 extern void SLtt_init_keypad (void); 702 extern void SLtt_deinit_keypad (void); 703 #endif 704 705 #if SLTT_HAS_NON_BCE_SUPPORT 706 extern int _pSLtt_get_bce_color_offset (void); 707 #endif 708 extern void (*_pSLtt_color_changed_hook)(void); 709 extern int _pSLtt_init_cmdline_mode (void); 710 extern void _pSLtt_cmdline_mode_reset (void); 711 712 extern int _pSLsmg_init_smg_cmdline (void); 713 714 extern unsigned char SLang_Input_Buffer [SL_MAX_INPUT_BUFFER_LEN]; 715 716 typedef struct SL_OOBinary_Type 717 { 718 SLtype data_type; /* partner type for binary op */ 719 720 int (*binary_function)_PROTO((int, 721 SLtype, VOID_STAR, SLuindex_Type, 722 SLtype, VOID_STAR, SLuindex_Type, 723 VOID_STAR)); 724 725 int (*binary_result) _PROTO((int, SLtype, SLtype, SLtype *)); 726 struct SL_OOBinary_Type *next; 727 } 728 SL_OOBinary_Type; 729 730 typedef struct _pSL_Typecast_Type 731 { 732 SLtype data_type; /* to_type */ 733 int allow_implicit; 734 735 int (*typecast)_PROTO((SLtype, VOID_STAR, SLuindex_Type, 736 SLtype, VOID_STAR)); 737 struct _pSL_Typecast_Type *next; 738 } 739 SL_Typecast_Type; 740 741 struct _pSLang_Class_Type 742 { 743 SLclass_Type cl_class_type; /* vector, scalar, mmt, pointer */ 744 745 unsigned int cl_data_type; /* SLANG_INTEGER_TYPE, etc... */ 746 char *cl_name; /* slstring type */ 747 748 size_t cl_sizeof_type; 749 VOID_STAR cl_transfer_buf; /* cl_sizeof_type bytes*/ 750 751 /* Methods */ 752 753 /* Most of the method functions are prototyped: 754 * int method (SLtype type, VOID_STAR addr); 755 * Here, @type@ represents the type of object that the method is asked 756 * to deal with. The second parameter @addr@ will contain the ADDRESS of 757 * the object. For example, if type is SLANG_INT_TYPE, then @addr@ will 758 * actually be int *. Similary, if type is SLANG_STRING_TYPE, 759 * then @addr@ will contain the address of the string, i.e., char **. 760 */ 761 762 void (*cl_destroy)_PROTO((SLtype, VOID_STAR)); 763 /* Prototype: void destroy(unsigned type, VOID_STAR val) 764 * Called to delete/free the object */ 765 766 char *(*cl_string)_PROTO((SLtype, VOID_STAR)); 767 /* Prototype: char *to_string (SLtype t, VOID_STAR p); 768 * Here p is a pointer to the object for which a string representation 769 * is to be returned. The returned pointer is to be a MALLOCED string. 770 */ 771 772 /* Prototype: void push(SLtype type, VOID_STAR v); 773 * Push a copy of the object of type @type@ at address @v@ onto the 774 * stack. 775 */ 776 int (*cl_push)_PROTO((SLtype, VOID_STAR)); 777 778 /* Prototype: int pop(SLtype type, VOID_STAR v); 779 * Pops value from stack and assign it to object, whose address is @v@. 780 */ 781 int (*cl_pop)_PROTO((SLtype, VOID_STAR)); 782 783 /* mul2, sign, etc... */ 784 int (*cl_unary_op_result_type)_PROTO((int, SLtype, SLtype *)); 785 int (*cl_unary_op)_PROTO((int, SLtype, VOID_STAR, SLuindex_Type, VOID_STAR)); 786 787 #if 0 788 int (*cl_arith_unary_op_result_type)_PROTO((int, SLtype, SLtype *)); 789 int (*cl_arith_unary_op)_PROTO((int, SLtype, VOID_STAR, SLuindex_Type, VOID_STAR)); 790 #endif 791 int (*cl_app_unary_op_result_type)_PROTO((int, SLtype, SLtype *)); 792 int (*cl_app_unary_op)_PROTO((int, SLtype, VOID_STAR, SLuindex_Type, VOID_STAR)); 793 794 /* If this function is non-NULL, it will be called for sin, cos, etc... */ 795 796 int (*cl_math_op)_PROTO((int, SLtype, VOID_STAR, SLuindex_Type, VOID_STAR)); 797 int (*cl_math_op_result_type)_PROTO((int, SLtype, SLtype *)); 798 799 SL_OOBinary_Type *cl_binary_ops; 800 SL_Typecast_Type *cl_typecast_funs; 801 802 void (*cl_byte_code_destroy)_PROTO((SLtype, VOID_STAR)); 803 void (*cl_user_destroy_fun)_PROTO((SLtype, VOID_STAR)); 804 int (*cl_init_array_object)_PROTO((SLtype, VOID_STAR)); 805 int (*cl_datatype_deref)_PROTO((SLtype)); 806 SLang_Struct_Type *cl_struct_def; 807 int (*cl_dereference) _PROTO((SLtype, VOID_STAR)); 808 809 /* cl_a* functions deal with functions that have array addresses. For 810 * scalar and vector types, there is no difference. However, for vector 811 * types such as Complex, which is stored as double[2], the address is 812 * the address of the first byte, and not the object itself. 813 */ 814 int (*cl_acopy) (SLtype, VOID_STAR, VOID_STAR); 815 int (*cl_apop) _PROTO((SLtype, VOID_STAR)); 816 int (*cl_apush) _PROTO((SLtype, VOID_STAR)); 817 int (*cl_push_literal) _PROTO((SLtype, VOID_STAR)); 818 void (*cl_adestroy)_PROTO((SLtype, VOID_STAR)); 819 int (*cl_push_intrinsic)_PROTO((SLtype, VOID_STAR)); 820 int (*cl_void_typecast)_PROTO((SLtype, VOID_STAR, SLuindex_Type, SLtype, VOID_STAR)); 821 822 int (*cl_anytype_typecast)_PROTO((SLtype, VOID_STAR, SLuindex_Type, SLtype, VOID_STAR)); 823 824 /* Array access functions */ 825 int (*cl_aput) (SLtype, unsigned int); 826 int (*cl_aget) (SLtype, unsigned int); 827 int (*cl_anew) (SLtype, unsigned int); 828 829 /* length method */ 830 int (*cl_length) (SLtype, VOID_STAR, SLuindex_Type *); 831 832 /* foreach */ 833 SLang_Foreach_Context_Type *(*cl_foreach_open) (SLtype, unsigned int); 834 void (*cl_foreach_close) (SLtype, SLang_Foreach_Context_Type *); 835 int (*cl_foreach) (SLtype, SLang_Foreach_Context_Type *); 836 837 /* Structure access: get and put (assign to) fields */ 838 int (*cl_sput) (SLtype, SLFUTURE_CONST char *); 839 int (*cl_sget) (SLtype, SLFUTURE_CONST char *); 840 841 /* File I/O */ 842 int (*cl_fread) (SLtype, FILE *, VOID_STAR, SLstrlen_Type, SLstrlen_Type *); 843 int (*cl_fwrite) (SLtype, FILE *, VOID_STAR, SLstrlen_Type, SLstrlen_Type *); 844 int (*cl_fdread) (SLtype, int, VOID_STAR, SLstrlen_Type, SLstrlen_Type *); 845 int (*cl_fdwrite) (SLtype, int, VOID_STAR, SLstrlen_Type, SLstrlen_Type *); 846 847 int (*cl_to_bool) (SLtype, int *); 848 849 int (*cl_cmp)(SLtype, VOID_STAR, VOID_STAR, int *); 850 int (*cl_eqs)(SLtype, VOID_STAR, SLtype, VOID_STAR); 851 852 /* required for any object that takes advantage of __tmp optimization */ 853 void (*cl_inc_ref)(SLtype, VOID_STAR, int); 854 855 SL_OOBinary_Type *cl_void_binary_this; 856 SL_OOBinary_Type *cl_this_binary_void; 857 858 int is_container; 859 int is_struct; 860 }; 861 #define SLANG_CLASS_IS_SLSTRUCT(cl) ((cl)->is_struct != 0) 862 863 extern int _pSLregister_types (void); 864 extern SLang_Class_Type *_pSLclass_get_class (SLtype); 865 extern VOID_STAR _pSLclass_get_ptr_to_value (SLang_Class_Type *, SLang_Object_Type *); 866 extern void _pSLclass_type_mismatch_error (SLtype, SLtype); 867 extern int _pSLclass_init (void); 868 extern int _pSLclass_copy_class (SLtype, SLtype); 869 870 extern int (*_pSLclass_get_typecast (SLtype, SLtype, int)) 871 (SLtype, VOID_STAR, SLuindex_Type, 872 SLtype, VOID_STAR); 873 874 extern int (*_pSLclass_get_binary_fun (int, SLang_Class_Type *, SLang_Class_Type *, SLang_Class_Type **, int)) 875 (int, 876 SLtype, VOID_STAR, SLuindex_Type, 877 SLtype, VOID_STAR, SLuindex_Type, 878 VOID_STAR); 879 880 extern int (*_pSLclass_get_unary_fun (int, SLang_Class_Type *, SLang_Class_Type **, int)) 881 (int, SLtype, VOID_STAR, SLuindex_Type, VOID_STAR); 882 883 #if 0 884 extern int _pSLclass_add_arith_unary_op (SLtype type, 885 int (*f)(int, 886 SLtype, VOID_STAR, unsigned int, 887 VOID_STAR), 888 int (*r)(int, SLtype, SLtype *)); 889 #endif 890 891 extern int _pSLclass_get_unary_opcode (SLCONST char *name); 892 extern int _pSLclass_get_binary_opcode (SLCONST char *name); 893 extern int _pSLclass_is_same_obj (SLang_Object_Type *a, SLang_Object_Type *b); 894 extern int _pSLclass_obj_eqs (SLang_Object_Type *a, SLang_Object_Type *b); 895 896 extern int _pSLarith_register_types (void); 897 extern SLtype _pSLarith_Arith_Types []; 898 899 extern int _pSLang_ref_is_callable (SLang_Ref_Type *); 900 extern int _pSLang_is_arith_type (SLtype); 901 extern void _pSLang_set_arith_type (SLtype, unsigned char); 902 #if SLANG_OPTIMIZE_FOR_SPEED 903 extern SLclass_Type _pSLang_get_class_type (SLtype); 904 extern void _pSLang_set_class_info (SLtype, SLang_Class_Type *); 905 extern int _pSLarray_bin_op (SLang_Object_Type *, SLang_Object_Type *, int); 906 extern int _pSLarray1d_push_elem (SLang_Array_Type *at, SLindex_Type idx); 907 #endif 908 extern int _pSLarith_bin_op (SLang_Object_Type *, SLang_Object_Type *, int); 909 910 /* Does not perform any range checking. It is up to the caller. 911 * If *atp!=NULL, then it is an array of indices. 912 */ 913 extern int _pSLarray_pop_index (unsigned int num_elements, SLang_Array_Type **ind_atp, SLindex_Type *ind); 914 915 /* Special treatment for signed chars */ 916 extern int _pSLang_pop_wchar (SLwchar_Type *wcp); 917 918 extern int _pSLarray_add_bin_op (SLtype); 919 extern int _pSLarray_push_elem_ref (void); 920 extern int _pSLang_push_array (SLang_Array_Type *, int); /* NULL not allowed */ 921 922 typedef struct 923 { 924 SLCONST char *name; 925 SLang_Name_Type *next; 926 char name_type; 927 928 int unary_op; 929 } 930 SLang_Arith_Unary_Type; 931 extern int _pSLadd_arith_unary_table (SLang_Arith_Unary_Type *tbl, SLFUTURE_CONST char *); 932 933 typedef struct 934 { 935 SLCONST char *name; 936 SLang_Name_Type *next; 937 char name_type; 938 939 int binary_op; 940 } 941 SLang_Arith_Binary_Type; 942 extern int _pSLadd_arith_binary_table (SLang_Arith_Binary_Type *tbl, SLFUTURE_CONST char *); 943 944 extern int _pSLang_do_binary_ab (int op, SLang_Object_Type *obja, SLang_Object_Type *objb); 945 946 extern int _pSLang_call_funptr (SLang_Name_Type *); 947 extern void _pSLset_double_format (SLCONST char *); 948 extern SLCONST char *_pSLget_double_format (void); 949 extern SLang_Name_Type *_pSLlocate_global_name (SLCONST char *); 950 extern SLang_Name_Type *_pSLlocate_name (SLCONST char *); 951 952 extern SLFUTURE_CONST char *_pSLdefines[]; 953 954 #define SL_ERRNO_NOT_IMPLEMENTED 0x7FFF 955 extern int _pSLerrno_errno; 956 extern int _pSLerrno_init (void); 957 extern SLFUTURE_VOID *_SLcalloc (SLstrlen_Type, SLstrlen_Type); 958 extern SLFUTURE_VOID *_SLrecalloc (SLFUTURE_VOID *, SLstrlen_Type, SLstrlen_Type); 959 960 extern int _pSLstdio_fdopen (char *, int, char *); 961 extern void _pSLfclose_fdopen_fp (SLang_MMT_Type *); 962 963 extern void _pSLstruct_pop_args (int *); 964 extern void _pSLstruct_push_args (SLang_Array_Type *); 965 966 extern int _pSLang_init_sllist (void); 967 extern int _pSLlist_inline_list (void); 968 969 extern int _pSLarray_aput1 (unsigned int); 970 extern int _pSLarray_aput (void); 971 extern int _pSLarray_aget (void); 972 extern int _pSLarray_aget1 (unsigned int); 973 extern int _pSLarray_inline_implicit_array (void); 974 extern int _pSLarray_inline_implicit_arrayn (void); 975 extern int _pSLarray_inline_array (void); 976 extern int _pSLarray_wildcard_array (void); 977 978 extern int 979 _pSLarray_typecast (SLtype, VOID_STAR, SLuindex_Type, 980 SLtype, VOID_STAR, int); 981 982 extern int _pSLarray_aput_transfer_elem (SLang_Array_Type *, SLindex_Type *, 983 VOID_STAR, size_t, int); 984 extern int _pSLarray_aget_transfer_elem (SLang_Array_Type *, SLindex_Type *, 985 VOID_STAR, size_t, int); 986 extern void _pSLarray_free_array_elements (SLang_Class_Type *, VOID_STAR, SLuindex_Type); 987 988 extern SLang_Foreach_Context_Type * 989 _pSLarray_cl_foreach_open (SLtype, unsigned int); 990 extern void _pSLarray_cl_foreach_close (SLtype, SLang_Foreach_Context_Type *); 991 extern int _pSLarray_cl_foreach (SLtype, SLang_Foreach_Context_Type *); 992 993 extern int _pSLarray_matrix_multiply (void); 994 extern void (*_pSLang_Matrix_Multiply)(void); 995 996 extern int _pSLarray_next_index (SLindex_Type *, SLindex_Type *, unsigned int); 997 998 extern int _pSLarray_init_slarray (void); 999 1000 extern int _pSLassoc_aput (SLtype, unsigned int); 1001 extern int _pSLassoc_aget (SLtype, unsigned int); 1002 extern int _pSLassoc_inc_value (unsigned int, int val); 1003 1004 extern int _pSLcompile_push_context (SLang_Load_Type *); 1005 extern int _pSLcompile_pop_context (void); 1006 extern int _pSLang_Auto_Declare_Globals; 1007 extern int _pSLang_Load_File_Verbose; 1008 1009 typedef struct _pSLtoken_String_List_Type 1010 { 1011 struct _pSLtoken_String_List_Type *next; 1012 unsigned int len; 1013 char buf[1]; /* rest of bytes follow */ 1014 } 1015 _pSLtoken_String_List_Type; 1016 1017 typedef unsigned char _pSLtok_Type; 1018 typedef struct 1019 { 1020 _pSLtok_Type type; /* [b]string_token */ 1021 unsigned int num; 1022 1023 _pSLtoken_String_List_Type *list; 1024 union 1025 { 1026 SLFUTURE_CONST char *s_val; /* (SLstring) concatenated strings */ 1027 SLang_BString_Type *b_val; /* concatenated bstrings */ 1028 } v; 1029 SLstr_Hash_Type hash; /* for v.s_val */ 1030 unsigned int len; /* length of v.?_val */ 1031 } 1032 _pSLang_Multiline_String_Type; 1033 1034 typedef struct _pSLang_Token_Type 1035 { 1036 union 1037 { 1038 long long_val; 1039 unsigned long ulong_val; 1040 #ifdef HAVE_LONG_LONG 1041 long long llong_val; 1042 unsigned long long ullong_val; 1043 #endif 1044 /* Note that it is not wise to put a double field in the union because 1045 * when reading a preparsed file, I want to keep the user-specified 1046 * form to preserve the precision. Using a union member would mean 1047 * converting the double to a string when creating a preparsed file. 1048 * We can avoid the issues associated with this by just storing 1049 * floating point values as strings. 1050 */ 1051 SLFUTURE_CONST char *s_val; /* Used for IDENT_TOKEN, DOUBLE_TOKEN, etc... */ 1052 1053 SLang_BString_Type *b_val; 1054 _pSLang_Multiline_String_Type *multistring_val; 1055 } v; 1056 void (*free_val_func)(struct _pSLang_Token_Type *); 1057 unsigned int num_refs; 1058 unsigned long hash; /* hash for slstring, and length for _BSTRING */ 1059 #define SLTOKEN_IS_NEGATIVE 0x001 1060 #define SLTOKEN_OVERFLOW_CHECKED 0x002 1061 #define SLTOKEN_IS_HEX 0x004 1062 #define SLTOKEN_IS_BINARY 0x008 1063 #define SLTOKEN_TYPE_INTEGER 0x100 1064 #define SLTOKEN_TYPE_FLOAT 0x200 1065 #define SLTOKEN_TYPE_NUMBER (SLTOKEN_TYPE_INTEGER|SLTOKEN_TYPE_FLOAT) 1066 #define SLTOKEN_VALUE_IS_RESERVED 0x400 1067 int flags; 1068 1069 #if SLANG_HAS_DEBUG_CODE 1070 int line_number; 1071 #endif 1072 struct _pSLang_Token_Type *next; /* used for token lists */ 1073 _pSLtok_Type type; 1074 } 1075 _pSLang_Token_Type; 1076 1077 /* return token type or EOF_TOKEN upon error */ 1078 extern _pSLtok_Type _pSLtoken_init_slstring_token (_pSLang_Token_Type *, _pSLtok_Type, 1079 SLCONST char *, SLstrlen_Type); 1080 1081 extern void _pSLcompile (_pSLang_Token_Type *); 1082 extern void (*_pSLcompile_ptr)(_pSLang_Token_Type *); 1083 1084 /* slmisc.c */ 1085 extern char *_pSLskip_whitespace (SLCONST char *s); 1086 1087 /* slospath.c */ 1088 extern char *_pSLpath_find_file (SLFUTURE_CONST char *, int); /* slstring returned */ 1089 1090 /* Read but do not set this variable. */ 1091 extern volatile int _pSLang_Error; 1092 1093 extern int _pSLutf8_mode; 1094 extern int _pSLinterp_UTF8_Mode; /* non-zero for interpreter */ 1095 extern int _pSLtt_UTF8_Mode; 1096 1097 extern SLuchar_Type *_pSLinterp_decode_wchar (SLuchar_Type *u, 1098 SLuchar_Type *umax, 1099 SLwchar_Type *chp); 1100 1101 extern SLuchar_Type *_pSLinterp_encode_wchar (SLwchar_Type wch, 1102 SLuchar_Type *buf, 1103 unsigned int *encoded_lenp); 1104 1105 /* *** TOKENS *** */ 1106 1107 /* Note that that tokens corresponding to ^J, ^M, and ^Z should not be used. 1108 * This is because a file that contains any of these characters will 1109 * have an OS dependent interpretation, e.g., ^Z is EOF on MSDOS. 1110 */ 1111 1112 /* Special tokens */ 1113 #define ILLEGAL_TOKEN 0x00 /* no token has this value */ 1114 #define EOF_TOKEN 0x01 1115 #define RPN_TOKEN 0x02 1116 #define NL_TOKEN 0x03 1117 #define NOP_TOKEN 0x05 1118 #define FARG_TOKEN 0x06 1119 #define TMP_TOKEN 0x07 1120 #define QUALIFIER_TOKEN 0x08 1121 1122 #define RESERVED1_TOKEN 0x0A /* \n */ 1123 #define RESERVED2_TOKEN 0x0D /* \r */ 1124 1125 /* Literal tokens */ 1126 #define CHAR_TOKEN 0x10 1127 #define UCHAR_TOKEN 0x11 1128 #define SHORT_TOKEN 0x12 1129 #define USHORT_TOKEN 0x13 1130 #define INT_TOKEN 0x14 1131 #define UINT_TOKEN 0x15 1132 #define LONG_TOKEN 0x16 1133 #define ULONG_TOKEN 0x17 1134 #define IS_INTEGER_TOKEN(x) ((x >= CHAR_TOKEN) && (x <= ULONG_TOKEN)) 1135 #define FLOAT_TOKEN 0x18 1136 #define DOUBLE_TOKEN 0x19 1137 #define RESERVED3_TOKEN 0x1A /* ^Z */ 1138 #define COMPLEX_TOKEN 0x1B 1139 #define STRING_TOKEN 0x1C 1140 #define BSTRING_TOKEN 0x1D 1141 #define _BSTRING_TOKEN 0x1E /* byte-compiled BSTRING */ 1142 #define STRING_DOLLAR_TOKEN 0x1F 1143 1144 /* Tokens that can be LVALUES */ 1145 #define IDENT_TOKEN 0x20 1146 #define ARRAY_TOKEN 0x21 1147 #define DOT_TOKEN 0x22 1148 #define IS_LVALUE_TOKEN (((t) <= DOT_TOKEN) && ((t) >= IDENT_TOKEN)) 1149 #define DOT_METHOD_CALL_TOKEN 0x23 1150 1151 #define ESC_STRING_TOKEN 0x24 /* only appears in slc file */ 1152 #define ESC_BSTRING_TOKEN 0x25 /* only appears in slc file */ 1153 1154 /* Flags for struct fields */ 1155 #define STATIC_TOKEN 0x26 1156 #define READONLY_TOKEN 0x27 1157 #define PRIVATE_TOKEN 0x28 1158 #define PUBLIC_TOKEN 0x29 1159 1160 /* Punctuation tokens */ 1161 #define OBRACKET_TOKEN 0x2a 1162 #define CBRACKET_TOKEN 0x2b 1163 #define OPAREN_TOKEN 0x2c 1164 #define CPAREN_TOKEN 0x2d 1165 #define OBRACE_TOKEN 0x2e 1166 #define CBRACE_TOKEN 0x2f 1167 1168 #define COMMA_TOKEN 0x31 1169 #define SEMICOLON_TOKEN 0x32 1170 #define COLON_TOKEN 0x33 1171 #define NAMESPACE_TOKEN 0x34 1172 #define QUESTION_TOKEN 0x35 1173 1174 /* Operators */ 1175 /* The order here must match the order in the Binop_Level table in slparse.c */ 1176 #define FIRST_BINARY_OP 0x36 1177 #define SC_AND_TOKEN 0x36 1178 #define SC_OR_TOKEN 0x37 1179 #define POW_TOKEN 0x38 1180 #define ADD_TOKEN 0x39 1181 #define SUB_TOKEN 0x3a 1182 #define TIMES_TOKEN 0x3b 1183 #define DIV_TOKEN 0x3c 1184 1185 #define LT_TOKEN 0x3d 1186 #define LE_TOKEN 0x3e 1187 #define GT_TOKEN 0x3f 1188 #define GE_TOKEN 0x40 1189 #define EQ_TOKEN 0x41 1190 #define NE_TOKEN 0x42 1191 #define IS_COMPARE_OP(x) (((x) >= LT_TOKEN) && ((x) <= NE_TOKEN)) 1192 1193 #define AND_TOKEN 0x43 1194 #define OR_TOKEN 0x44 1195 #define MOD_TOKEN 0x45 1196 #define BAND_TOKEN 0x46 1197 #define SHL_TOKEN 0x47 1198 #define SHR_TOKEN 0x48 1199 #define BXOR_TOKEN 0x49 1200 #define BOR_TOKEN 0x4a 1201 #define POUND_TOKEN 0x4b /* matrix multiplication */ 1202 #define LAST_BINARY_OP 0x4b 1203 #define IS_BINARY_OP(t) ((t >= FIRST_BINARY_OP) && (t <= LAST_BINARY_OP)) 1204 1205 /* unary tokens -- but not all of them (see grammar) */ 1206 #define DEREF_TOKEN 0x4d 1207 #define NOT_TOKEN 0x4e 1208 #define BNOT_TOKEN 0x4f 1209 1210 #define IS_INTERNAL_FUNC(t) ((t >= 0x50) && (t <= 0x52)) 1211 #define POP_TOKEN 0x50 1212 #define CHS_TOKEN 0x51 1213 #define EXCH_TOKEN 0x52 1214 1215 #define LLONG_TOKEN 0x53 1216 #define ULLONG_TOKEN 0x54 1217 #define LDOUBLE_TOKEN 0x55 1218 1219 /* Assignment tokens. Note: these must appear with sequential values. 1220 * The order here must match the specific lvalue assignments below. 1221 * These tokens are used by rpn routines in slang.c. slparse.c maps them 1222 * onto the specific lvalue tokens while parsing infix. 1223 * Also the assignment SLANG_BCST_ assumes this order 1224 */ 1225 #define ASSIGN_TOKEN 0x57 1226 #define PLUSEQS_TOKEN 0x58 1227 #define MINUSEQS_TOKEN 0x59 1228 #define TIMESEQS_TOKEN 0x5A 1229 #define DIVEQS_TOKEN 0x5B 1230 #define BOREQS_TOKEN 0x5C 1231 #define BANDEQS_TOKEN 0x5D 1232 #define PLUSPLUS_TOKEN 0x5E 1233 #define POST_PLUSPLUS_TOKEN 0x5F 1234 #define MINUSMINUS_TOKEN 0x60 1235 #define POST_MINUSMINUS_TOKEN 0x61 1236 1237 /* Directives */ 1238 #define IFNOT_TOKEN 0x62 1239 #define IF_TOKEN 0x63 1240 #define ELSE_TOKEN 0x64 1241 #define FOREVER_TOKEN 0x65 1242 #define WHILE_TOKEN 0x66 1243 #define FOR_TOKEN 0x67 1244 #define _FOR_TOKEN 0x68 1245 #define LOOP_TOKEN 0x69 1246 #define SWITCH_TOKEN 0x6A 1247 #define DOWHILE_TOKEN 0x6B 1248 #define ANDELSE_TOKEN 0x6C 1249 #define ORELSE_TOKEN 0x6D 1250 #define ERRBLK_TOKEN 0x6E 1251 #define EXITBLK_TOKEN 0x6F 1252 /* These must be sequential */ 1253 #define USRBLK0_TOKEN 0x70 1254 #define USRBLK1_TOKEN 0x71 1255 #define USRBLK2_TOKEN 0x72 1256 #define USRBLK3_TOKEN 0x73 1257 #define USRBLK4_TOKEN 0x74 1258 1259 #define CONT_TOKEN 0x75 1260 #define BREAK_TOKEN 0x76 1261 #define RETURN_TOKEN 0x77 1262 1263 #define CASE_TOKEN 0x78 1264 #define DEFINE_TOKEN 0x79 1265 #define DO_TOKEN 0x7a 1266 #define VARIABLE_TOKEN 0x7b 1267 #define GVARIABLE_TOKEN 0x7c 1268 #define _REF_TOKEN 0x7d 1269 #define PUSH_TOKEN 0x7e 1270 #define STRUCT_TOKEN 0x7f 1271 #define TYPEDEF_TOKEN 0x80 1272 #define NOTELSE_TOKEN 0x81 1273 #define DEFINE_STATIC_TOKEN 0x82 1274 #define FOREACH_TOKEN 0x83 1275 #define USING_TOKEN 0x84 1276 #define DEFINE_PRIVATE_TOKEN 0x85 1277 #define DEFINE_PUBLIC_TOKEN 0x86 1278 1279 #define TRY_TOKEN 0x87 1280 #define CATCH_TOKEN 0x88 1281 #define THROW_TOKEN 0x89 1282 #define FINALLY_TOKEN 0x8a 1283 1284 #define BREAK_N_TOKEN 0x8b 1285 #define CONT_N_TOKEN 0x8c 1286 #define THEN_TOKEN 0x8d 1287 #define STRUCT_WITH_ASSIGN_TOKEN 0x8e 1288 #define FOREACH_EARGS_TOKEN 0x8f 1289 1290 /* Note: the order here must match the order of the generic assignment tokens. 1291 * Also, the first token of each group must be the ?_ASSIGN_TOKEN. 1292 * slparse.c exploits this order, as well as slang.h. 1293 */ 1294 #define FIRST_ASSIGN_TOKEN 0x90 1295 #define _STRUCT_ASSIGN_TOKEN 0x90 1296 #define _STRUCT_PLUSEQS_TOKEN 0x91 1297 #define _STRUCT_MINUSEQS_TOKEN 0x92 1298 #define _STRUCT_TIMESEQS_TOKEN 0x93 1299 #define _STRUCT_DIVEQS_TOKEN 0x94 1300 #define _STRUCT_BOREQS_TOKEN 0x95 1301 #define _STRUCT_BANDEQS_TOKEN 0x96 1302 #define _STRUCT_PLUSPLUS_TOKEN 0x97 1303 #define _STRUCT_POST_PLUSPLUS_TOKEN 0x98 1304 #define _STRUCT_MINUSMINUS_TOKEN 0x99 1305 #define _STRUCT_POST_MINUSMINUS_TOKEN 0x9A 1306 1307 #define _ARRAY_ASSIGN_TOKEN 0xA0 1308 #define _ARRAY_PLUSEQS_TOKEN 0xA1 1309 #define _ARRAY_MINUSEQS_TOKEN 0xA2 1310 #define _ARRAY_TIMESEQS_TOKEN 0xA3 1311 #define _ARRAY_DIVEQS_TOKEN 0xA4 1312 #define _ARRAY_BOREQS_TOKEN 0xA5 1313 #define _ARRAY_BANDEQS_TOKEN 0xA6 1314 #define _ARRAY_PLUSPLUS_TOKEN 0xA7 1315 #define _ARRAY_POST_PLUSPLUS_TOKEN 0xA8 1316 #define _ARRAY_MINUSMINUS_TOKEN 0xA9 1317 #define _ARRAY_POST_MINUSMINUS_TOKEN 0xAA 1318 1319 #define _SCALAR_ASSIGN_TOKEN 0xB0 1320 #define _SCALAR_PLUSEQS_TOKEN 0xB1 1321 #define _SCALAR_MINUSEQS_TOKEN 0xB2 1322 #define _SCALAR_TIMESEQS_TOKEN 0xB3 1323 #define _SCALAR_DIVEQS_TOKEN 0xB4 1324 #define _SCALAR_BOREQS_TOKEN 0xB5 1325 #define _SCALAR_BANDEQS_TOKEN 0xB6 1326 #define _SCALAR_PLUSPLUS_TOKEN 0xB7 1327 #define _SCALAR_POST_PLUSPLUS_TOKEN 0xB8 1328 #define _SCALAR_MINUSMINUS_TOKEN 0xB9 1329 #define _SCALAR_POST_MINUSMINUS_TOKEN 0xBA 1330 1331 #define _DEREF_ASSIGN_TOKEN 0xC0 1332 #define _DEREF_PLUSEQS_TOKEN 0xC1 1333 #define _DEREF_MINUSEQS_TOKEN 0xC2 1334 #define _DEREF_TIMESEQS_TOKEN 0xC3 1335 #define _DEREF_DIVEQS_TOKEN 0xC4 1336 #define _DEREF_BOREQS_TOKEN 0xC5 1337 #define _DEREF_BANDEQS_TOKEN 0xC6 1338 #define _DEREF_PLUSPLUS_TOKEN 0xC7 1339 #define _DEREF_POST_PLUSPLUS_TOKEN 0xC8 1340 #define _DEREF_MINUSMINUS_TOKEN 0xC9 1341 #define _DEREF_POST_MINUSMINUS_TOKEN 0xCA 1342 1343 #define LAST_ASSIGN_TOKEN 0xCA 1344 #define IS_ASSIGN_TOKEN(t) (((t)>=FIRST_ASSIGN_TOKEN)&&((t)<=LAST_ASSIGN_TOKEN)) 1345 1346 #define _DEREF_OBSOLETE_FUNCALL_TOKEN 0xCE 1347 #define _DEREF_FUNCALL_TOKEN 0xCF 1348 1349 #define LOOP_THEN_TOKEN 0xD0 1350 /* #define LOOP_ELSE_TOKEN 0xD1 */ 1351 1352 #define _COMPARE_TOKEN 0xD8 /* (a < b < c ...) */ 1353 #define _ARRAY_ELEM_REF_TOKEN 0xD9 /* &X[i] */ 1354 #define _STRUCT_FIELD_REF_TOKEN 0xDA /* &S.a */ 1355 1356 #define _INLINE_ARRAY_TOKEN 0xE0 1357 #define _INLINE_IMPLICIT_ARRAY_TOKEN 0xE1 /* [a:b:c] */ 1358 #define _NULL_TOKEN 0xE2 1359 #define _INLINE_WILDCARD_ARRAY_TOKEN 0xE3 1360 #define _INLINE_LIST_TOKEN 0xE4 1361 #define _INLINE_IMPLICIT_ARRAYN_TOKEN 0xE5 /* [a:b:#n] */ 1362 1363 #define ESC_STRING_DOLLAR_TOKEN 0xF0 /* appears only in .slc files */ 1364 #define MULTI_STRING_TOKEN 0xF1 1365 1366 #define BOS_TOKEN 0xFA 1367 #define EOS_TOKEN 0xFB 1368 #define LINE_NUM_TOKEN 0xFC 1369 #define ARG_TOKEN 0xFD 1370 #define EARG_TOKEN 0xFE 1371 #define NO_OP_LITERAL 0xFF 1372 1373 typedef struct 1374 { 1375 /* sltoken.c */ 1376 /* SLang_eval_object */ 1377 SLang_Load_Type *llt; 1378 SLprep_Type *this_slpp; 1379 /* prep_get_char() */ 1380 char *input_line; 1381 char cchar; 1382 /* get_token() */ 1383 int want_nl_token; 1384 1385 /* slparse.c */ 1386 _pSLang_Token_Type ctok; 1387 int block_depth; 1388 int assignment_expression; 1389 1390 /* slang.c : SLcompile() */ 1391 _pSLang_Token_Type save_token; 1392 _pSLang_Token_Type next_token; 1393 void (*slcompile_ptr)(_pSLang_Token_Type *); 1394 } 1395 _pSLEval_Context; 1396 1397 extern int _pSLget_token (_pSLang_Token_Type *); 1398 extern void _pSLparse_error (int, SLCONST char *, _pSLang_Token_Type *, int); 1399 extern void _pSLparse_start (SLang_Load_Type *); 1400 extern int _pSLget_rpn_token (_pSLang_Token_Type *); 1401 extern void _pSLcompile_byte_compiled (void); 1402 1403 extern int (*_pSLprep_eval_hook) (SLFUTURE_CONST char *); 1404 1405 extern int _pSLsecure_issetugid (void); 1406 extern char *_pSLsecure_getenv (SLCONST char *); 1407 1408 /* Error Handling */ 1409 extern int _pSLang_init_exceptions (void); 1410 extern int _pSLerr_init (void); 1411 extern void _pSLerr_deinit (void); 1412 extern int _pSLerr_suspend_messages (void); 1413 extern int _pSLerr_resume_messages (void); 1414 extern int _pSLerr_traceback_msg (SLFUTURE_CONST char *, ...) SLATTRIBUTE_PRINTF(1,2); 1415 extern void _pSLerr_dump_msg (SLFUTURE_CONST char *, ...) SLATTRIBUTE_PRINTF(1,2); 1416 extern void _pSLerr_clear_error (int); 1417 extern void _pSLang_verror (int, SLCONST char *, ...) SLATTRIBUTE_PRINTF(2,3); 1418 extern int _pSLsnprintf (char *, unsigned int, SLFUTURE_CONST char *, ...) SLATTRIBUTE_PRINTF(3,4); 1419 1420 typedef struct _pSLerr_Error_Queue_Type _pSLerr_Error_Queue_Type; 1421 extern _pSLerr_Error_Queue_Type *_pSLerr_new_error_queue (int); 1422 extern int _pSLerr_set_error_queue (_pSLerr_Error_Queue_Type *); 1423 extern void _pSLerr_delete_error_queue (_pSLerr_Error_Queue_Type *); 1424 1425 extern void _pSLerr_print_message_queue (void); 1426 1427 extern int _pSLerr_set_line_info (SLFUTURE_CONST char *, int, SLFUTURE_CONST char *); 1428 extern int _pSLang_pop_error_context (int); 1429 extern int _pSLang_push_error_context (void); 1430 extern void (*_pSLinterpreter_Error_Hook)(int); 1431 extern int _pSLerr_init_interp_exceptions (void); 1432 extern int _pSLerr_get_last_error (void); 1433 extern int _pSLerr_pop_exception (int *); 1434 extern void _pSLerr_free_queued_messages (void); 1435 1436 #define _SLERR_MSG_ERROR 1 1437 #define _SLERR_MSG_WARNING 2 1438 #define _SLERR_MSG_TRACEBACK 3 1439 extern char *_pSLerr_get_error_from_queue (_pSLerr_Error_Queue_Type *, int); 1440 1441 extern int _pSLerr_throw (void); 1442 extern int (*_pSLerr_New_Exception_Hook)(SLFUTURE_CONST char *name, SLFUTURE_CONST char *desc, int error_code); 1443 1444 #if SLANG_HAS_DEBUGGER_SUPPORT 1445 typedef struct 1446 { 1447 char **locals; 1448 unsigned int nlocals; 1449 SLCONST char *file; 1450 unsigned int line; 1451 SLCONST char *function; 1452 SLCONST char *ns; 1453 } 1454 _pSLang_Frame_Info_Type; 1455 1456 extern int _pSLang_get_frame_fun_info (int depth, _pSLang_Frame_Info_Type *info); 1457 extern int _pSLang_set_frame_variable (int depth, char *name); 1458 extern int _pSLang_get_frame_variable (int depth, char *name); 1459 extern void _pSLang_use_frame_namespace (int depth); 1460 extern int _pSLang_get_frame_depth (void); 1461 #endif 1462 1463 #if SLANG_HAS_FLOAT 1464 extern int _pSLmath_isnan (double x); 1465 extern int _pSLmath_isinf (double x); 1466 extern double _pSLang_NaN; 1467 extern double _pSLang_Inf; 1468 1469 # ifdef HAVE_LOG1P 1470 # define LOG1P_FUNC log1p 1471 # else 1472 extern double _pSLmath_log1p (double); 1473 # define LOG1P_FUNC _pSLmath_log1p 1474 # endif 1475 1476 # ifdef HAVE_EXPM1 1477 # define EXPM1_FUNC expm1 1478 # else 1479 extern double _pSLmath_expm1 (double); 1480 # define EXPM1_FUNC _pSLmath_expm1 1481 # endif 1482 1483 # if SLANG_HAS_COMPLEX 1484 extern double *_pSLcomplex_expm1 (double *f, double *z); 1485 extern double *_pSLcomplex_log1p (double *f, double *z); 1486 # endif 1487 #endif 1488 1489 #if SLANG_HAS_SIGNALS 1490 extern void _pSLang_signal_interrupt (void); 1491 extern int _pSLsig_block_and_call (int (*)(VOID_STAR), VOID_STAR); 1492 extern int _pSLsig_handle_signals (void); 1493 extern int _pSLang_check_signals_hook (VOID_STAR); 1494 #else 1495 #define _pSLsig_block_and_call(f,v) f(v) 1496 #endif 1497 1498 #undef _INLINE_ 1499 /* clang defines GNUC on the mac, but used c99 sematics for extern inline. This implementation 1500 * assume GNU semantics. 1501 */ 1502 #if defined (SLANG_USE_INLINE_CODE) && defined(__GNUC__) && !defined(__clang__) 1503 # if !defined __GNUC_STDC_INLINE__ && !defined __GNUC_GNU_INLINE__ 1504 # define _INLINE_ __inline__ /* older compilers */ 1505 # else 1506 # define _INLINE_ __inline__ __attribute__((gnu_inline)) /* newer ones */ 1507 # endif 1508 #else 1509 # define _INLINE_ 1510 #endif 1511 1512 #if SLANG_OPTIMIZE_FOR_SPEED && defined(__GNUC__) && (__GNUC__ >= 3) 1513 # define IF_LIKELY(x) if (__builtin_expect((x),1)) 1514 # define IF_UNLIKELY(x) if (__builtin_expect ((x), 0)) 1515 #else 1516 # define IF_LIKELY(x) if (x) 1517 # define IF_UNLIKELY(x) if (x) 1518 #endif 1519 1520 /* This is a macro that permits: 1521 * 1522 * extern fun (void **addr); 1523 * double x; 1524 * fun ((void **) &x); <--- warning 1525 * fun (VOID_STAR_STAR(&x)); 1526 * 1527 * Otherwise a type-punning warning could result due to strict-aliasing. 1528 */ 1529 #define VOID_STAR_STAR(addr) (VOID_STAR *)(VOID_STAR)(addr) 1530 1531 #endif /* PRIVATE_SLANG_H_ */ 1532