1 /****************************************************************/ 2 /* file common.h 3 4 ARIBAS interpreter for Arithmetic 5 Copyright (C) 1996-2007 O.Forster 6 7 This program is free software; you can redistribute it and/or modify 8 it under the terms of the GNU General Public License as published by 9 the Free Software Foundation; either version 2 of the License, or 10 (at your option) any later version. 11 12 This program is distributed in the hope that it will be useful, 13 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 GNU General Public License for more details. 16 17 You should have received a copy of the GNU General Public License 18 along with this program; if not, write to the Free Software 19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 21 Address of the author 22 23 Otto Forster 24 Math. Institut der LMU 25 Theresienstr. 39 26 D-80333 Muenchen, Germany 27 28 Email forster@mathematik.uni-muenchen.de 29 WWW http://www.mathematik.uni-muenchen.de/~forster 30 31 The latest version of ARIBAS can be obtained by anonymous ftp from 32 33 ftp.mathematik.uni-muenchen.de 34 35 directory 36 37 pub/forster/aribas 38 */ 39 /****************************************************************/ 40 /* 41 ** common.h 42 ** header definitions and macros which are used 43 ** by more than one C-file 44 ** 45 ** date of last change 46 ** 1997-02-11 moved defn of ARIBUFSIZE to alloc.c 47 ** 1997-04-13 reorg (newintsym) 48 ** 1997-07-04 new #define READLNINPUT 49 ** 1997-11-08 some defines for DjGPP changed 50 ** 2001-03-30 Win32GUI, genWinGUI 51 ** 2002-03-27 WORKnpush, VECSTRUCTPTR 52 ** 2002-10-01 deleted some superfluous #define's 53 */ 54 55 #include <stdio.h> 56 #include <stdlib.h> 57 #include <string.h> 58 59 /* 60 ** to compile ARIBAS, one of the following symbols 61 ** must be defined 62 */ 63 /************ 64 #define ATARIST 65 66 #define MsDOS 67 68 #define Dos386 69 70 #define Dos286 71 72 #define Win32GUI 73 74 #define Win32CON 75 76 #define DjGPP 77 78 #define UNiX 79 80 #define UNiX64 81 82 #define SCOUNiX 83 84 #define LiNUX 85 #define GtK 86 87 #define MacGtK 88 ************/ 89 90 91 92 /*-----------------------------------------------------------------*/ 93 94 #ifdef UNiX64 95 #define ARCHITEC "UNiX64" 96 #define genUNiX 97 #define ALIGN8 98 #endif 99 100 #ifdef UNiX 101 #define ARCHITEC "UNIX" 102 #define genUNiX 103 #endif 104 105 #ifdef SCOUNiX 106 #define ARCHITEC "SCO-UNIX" 107 #define genUNiX 108 #define M_3264 109 #endif 110 111 #ifdef LiNUX 112 #ifdef GtK 113 #define genWinGUI 114 #define ARCHITEC "LINUX-GTK" 115 #else 116 #define ARCHITEC "LINUX386" 117 #endif 118 #define genUNiX 119 #define M_3264 120 #endif 121 122 #ifdef MacGtK 123 #define GtK 124 #define genUNiX 125 #define genWinGUI 126 #define ARCHITEC "MacOSX-GTK" 127 #endif 128 129 #ifdef genUNiX 130 #define DOSorUNiX 131 #define UNiXorGCC 132 #define M_LARGE 133 #endif 134 135 #ifdef Win32GUI 136 #define ARCHITEC "Win32GUI" 137 #define MsWIN32 138 #define genWinGUI 139 #endif 140 141 #ifdef Win32CON 142 #define ARCHITEC "Win32Console" 143 #define MsWIN32 144 #define LINEINPUT 145 #endif 146 147 #ifdef MsWIN32 148 #ifndef NO_ASSEMB 149 #define M_3264 150 #endif 151 #define M_LARGE 152 #endif 153 154 #ifdef Dos386 155 #define ARCHITEC "MS-DOS 386" 156 #define MsDOS 157 #define M_3264 158 #endif 159 160 #ifdef Dos286 161 #define ARCHITEC "MS-DOS 286" 162 #define MsDOS 163 #endif 164 165 #ifdef MsDOS 166 #ifndef ARCHITEC 167 #define ARCHITEC "MS-DOS 086" 168 #endif 169 #define DOSorUNiX 170 #define DOSorTOS 171 #define M_SMALL 172 #endif 173 174 #ifdef DjGPP 175 #define ARCHITEC "DJGPP386" 176 #define DOSorUNiX 177 #define UNiXorGCC 178 #define M_3264 179 #define M_LARGE 180 #endif 181 182 #ifdef ATARIST 183 #define ARCHITEC "ATARI-ST" 184 #define DOSorTOS 185 #define M_SMALL 186 #endif 187 188 #ifdef M_LARGE 189 #define FPREC_HIGH 190 #endif 191 192 #define VERSION_STRING "V 1.64, Jan. 2010" 193 #define VERSION_YEAR "2010" 194 #define VERSION_NO 164 195 196 /*-----------------------------------------------------------------*/ 197 #ifdef PROTO 198 #define _(x) x 199 #else 200 #define _(x) () 201 #endif 202 203 204 #define PRIVATE static 205 #define PUBLIC 206 207 /*-----------------------------------------------------------------*/ 208 #ifdef MsDOS 209 #define SHIFTSTAT (*(unsigned char *)0x00000417) 210 #endif 211 #ifdef ATARIST 212 #include <tos.h> 213 #define SHIFTSTAT Kbshift(-1) 214 #endif 215 #ifdef DOSorTOS 216 #define SHIFT 2 /* linke Shift-Taste */ 217 #define CONTROL 4 218 #define SHCTRL (CONTROL | SHIFT) 219 #ifndef INTERRUPT 220 #define INTERRUPT ((SHIFTSTAT & SHCTRL) == SHCTRL) 221 #endif 222 #endif 223 224 #ifdef UNiXorGCC 225 #define INTERRUPT Unterbrech 226 #endif 227 #ifdef MsWIN32 228 #define INTERRUPT Unterbrech 229 #endif 230 /*-----------------------------------------------------------------*/ 231 232 #define PRIMTABSIZE 2048 /* size of prime bitvector (word2's) */ 233 #define MAXCOLS 80 /* max no. of columns on the screen */ 234 #define ARGCMAX 64 /* maximal length of ARGV */ 235 236 #ifdef M_LARGE 237 #define IOBUFSIZE 1024 /* size of output buffer */ 238 #define MAXPFADLEN 256 /* avoid name collision with MAXPATHLEN */ 239 #else 240 #define IOBUFSIZE 256 /* size of output buffer */ 241 #define MAXPFADLEN 128 242 #endif 243 244 #ifdef genUNiX 245 #define SEPPATH ':' 246 #else 247 #define SEPPATH ';' 248 #endif 249 #ifdef UNiXorGCC 250 #define SEPDIR '/' 251 #else 252 #define SEPDIR '\\' 253 #endif 254 #ifdef genUNiX 255 #define SEP_DIR "/" 256 #endif 257 #ifdef DOSorTOS 258 #define SEP_DIR "\\" 259 #endif 260 #ifdef DjGPP 261 #define SEP_DIR "/\\" 262 #endif 263 #ifndef SEP_DIR 264 #define SEP_DIR "\\/" 265 #endif 266 /*-----------------------------------------------------------------*/ 267 /* values for flag in symbol structure */ 268 /* all values are even, odd values reserved */ 269 #define sUNBOUND 0x00 /* unbound symbol */ 270 #define sVARIABLE 0x02 /* bound variable */ 271 #define sCONSTANT 0x04 /* user defined constant */ 272 #define sFUNCTION 0x06 /* user defined function */ 273 #define sVFUNCTION 0x08 /* user defined function with var args */ 274 275 #define sTYPEDEF 0x0C /* user defined type */ 276 277 #define sGCMOVEBIND 0x0E /* mask used during garbage collection */ 278 279 #define sSYSTEM 0x10 /* all following are system symbols */ 280 #define sFBINARY 0x10 /* builtin function */ 281 #define sSBINARY 0x20 /* builtin special form */ 282 #define sINFIX 0x30 /* infix operator */ 283 #define sSCONSTANT 0x40 /* system constant */ 284 #define sSYMBCONST 0x50 /* symbolic constant */ 285 #define sSYSSYMBOL 0x60 /* system symbol */ 286 #define sPARSAUX 0x70 /* special treatment during parsing */ 287 #define sTYPESPEC 0x80 /* type specifier */ 288 #define sDELIM 0xA0 /* delimiter do, then, else, .., end */ 289 #define sINTERNAL 0xE0 /* internal symbol */ 290 #define sINTERNVAR 0xE2 /* internal var, moved during gc */ 291 #define sSYSTEMVAR 0x12 /* system var, moved during gc */ 292 293 #define sEXTFUNCTION (0x100 | sFUNCTION) /* used during parsing */ 294 295 #define mGLOBAL 0x8000 /* to mark external variable */ 296 #define mLOCCONST 0x7000 /* to mark local constants */ 297 298 /* values for flag of trucs */ 299 /* odd values are fixed during garbage collection */ 300 #define fSYMBOL 1 301 #define fLSYMBOL 3 /* local symbol */ 302 #define fRSYMBOL 5 /* reference to symbol */ 303 #define fLRSYMBOL 7 /* reference to local symbol */ 304 #define fTMPCONST 9 /* temporary reference to local const */ 305 306 #define fFUNEXPR 10 /* until fSELFEVAL are kind of functions */ 307 #define fSPECIAL0 11 /* special form, no argument */ 308 #define fSPECIAL1 10 /* special form, 1 argument */ 309 #define fSPECIAL2 12 /* special form, 2 arguments */ 310 #define fSPECIALn 14 /* special form, n arguments */ 311 #define fBUILTIN1 16 /* built-in function, 1 argument */ 312 #define fBUILTIN2 18 /* built-in function, 2 arguments */ 313 #define fBUILTINn 20 /* built-in function, n arguments */ 314 #define fFUNCALL 22 /* call of user defined function */ 315 #define fCOMPEXPR 24 /* compound expression */ 316 #define fIFEXPR 26 /* if statement */ 317 #define fWHILEXPR 28 /* while statement */ 318 #define fFOREXPR 30 /* for statement */ 319 320 #define fSELFEVAL 32 /* all following are self evaluating */ 321 #define fFUNDEF 32 /* user function definition */ 322 323 #define fPOINTER 34 324 #define fTUPLE 36 325 #define fSTACK 38 326 #define fSTREAM 40 327 328 #define fRECORD 48 329 #define fVECTLIKE0 50 330 #define fVECTOR 50 331 #define fCONSTLIT 52 /* all following are literal objects */ 332 #define fSTRING 52 333 #define fBYTESTRING 54 334 #define fVECTLIKE1 54 335 336 #define fBOOL 57 337 #define fCHARACTER 59 338 #define fINTTYPE0 60 339 #define fGF2NINT 60 340 #define fFIXNUM 61 341 #define fBIGNUM 62 342 #define fINTTYPE1 62 343 #define fFLTOBJ 128 344 #define fHUGEFLOAT (fFLTOBJ + HUGEFLTBIT) 345 346 #define FIXMASK 0x01 /* mask for checking fixed objects */ 347 #define PRECMASK 0x3E /* mask for retrieving float precision */ 348 #define FLTZEROBIT 0x01 /* for floats = 0 */ 349 #define HUGEFLTBIT 0x40 /* huge floats */ 350 #define HUGEMASK 0x7F 351 #define FSIGNBIT 0x80 /* sign bit in signum of floats */ 352 #define GCMARK 0xFF /* used during garbage collection */ 353 #define MINUSBYTE 0xFF /* sign of negative numbers */ 354 355 /* streams */ 356 #define INSTREAM 1 /* input stream bit */ 357 #define OUTSTREAM 2 /* output stream bit */ 358 #define IOMASK 3 359 #define APPEND 8 360 #define BINARY 16 361 #define aTEXT 0 /* binary bit not set */ 362 /* avoid nameclash with TEXT in windows header */ 363 #define DEVICE 32 /* console, printer */ 364 #define NOSTREAM 0 /* unconnected stream */ 365 366 367 /* values used for reading and printing */ 368 #define EOL '\n' 369 #define FORMFEED '\014' 370 #define TABESC '\036' /* escape char for compression */ 371 #define ZESC '\177' 372 373 /* tokens for parser */ 374 375 #define EOFTOK -1 /* end-of-file token */ 376 #define EOLTOK 0 /* end-of-line token */ 377 378 #define Z1TOK -101 379 380 #define LPARENTOK 10 /* ( */ 381 #define RPARENTOK 11 /* ) */ 382 #define LBRACKTOK 12 /* [ */ 383 #define RBRACKTOK 13 /* ] */ 384 #define LBRACETOK 14 /* { */ 385 #define RBRACETOK 15 /* } */ 386 #define BEGCOMMTOK 18 /* (* */ 387 #define ENDCOMMTOK 19 /* *) */ 388 #define COMMATOK 20 389 #define COLONTOK 21 390 #define SEMICOLTOK 22 391 #define DOTTOK 30 392 #define DOTDOTTOK 31 393 #define RECDOTTOK 32 /* dot as record field separator */ 394 #define DEREFTOK 40 /* ^ for pointer dereferencing */ 395 #define DOLLARTOK 50 396 #define HISTORYTOK 60 /* !,!!,!!!,!a,!b,!c */ 397 #define QUESTIONTOK 70 /* ? */ 398 399 #define ASSIGNTOK 101 /* odd value means right associative */ 400 401 #define ORTOK 201 402 #define ANDTOK 211 403 #define NOTTOK 221 404 405 #define EQTOK 300 406 #define NETOK 310 407 #define LTTOK 320 408 #define LETOK 330 409 #define GTTOK 340 410 #define GETOK 350 411 412 #define PLUSTOK 400 413 #define MINUSTOK 410 414 415 #define TIMESTOK 500 416 #define DIVIDETOK 510 417 #define DIVTOK 520 418 #define MODTOK 540 419 420 #define UMINUSTOK 601 421 422 #define POWERTOK 701 423 424 #define BOOLTOK 2010 425 #define CHARTOK 2020 /* character token */ 426 #define INUMTOK 2030 /* integer number token */ 427 #define FLOATTOK 2040 428 #define GF2NTOK 2045 /* gf2n_int token */ 429 #define STRINGTOK 2050 /* string token */ 430 #define BSTRINGTOK 2052 /* byte_string token */ 431 #define SYMBOLTOK 2060 /* symbol token */ 432 #define VECTORTOK 2070 /* vector token */ 433 434 /* Lvals */ 435 #define vUNBOUND 0 436 #define vBOUND 1 437 #define vCONST 2 438 #define vVECTOR 10 439 #define vARRELE 11 440 #define vSUBARRAY 12 441 #define vRECFIELD 20 442 #define vPOINTREF 30 443 444 /* defines for diverse return values */ 445 #define EXITREQ -1 /* possible return value of loadaux */ 446 #define aERROR -32768 /* error return value for int functions */ 447 /* avoid nameclash with ERROR in windows header */ 448 #define LONGERROR -2147483647 /* error return value for int4 functions */ 449 #define RESET 0x1111 /* value handed by longjmp if reset */ 450 #define HALTRET 0x2222 /* value handed by longjmp if halt */ 451 452 453 #define MAXFLTLIM 0x3FFF80 454 #define MOSTNEGEX -0x400000 /* exponent for float number zero */ 455 456 /** used by scanner and parser **/ 457 #define TERMINALINP 1 458 #define FILEINPUT 2 459 #define STRINGINPUT 3 460 #define READLNINPUT 4 461 462 /*-----------------------------------------------------------------*/ 463 #ifdef M_LARGE 464 typedef int int4; /* 4-byte integer */ 465 typedef unsigned int word4; 466 #else 467 typedef long int4; /* 4-byte integer */ 468 typedef unsigned long word4; 469 #endif 470 typedef short int2; /* 2-byte integer */ 471 typedef unsigned short word2; 472 typedef unsigned char byte; 473 474 typedef word4 truc; 475 typedef void *wtruc; 476 477 typedef truc *trucptr; 478 479 typedef truc (* funptr) _((void)); 480 typedef truc (* funptr1) _((int k)); 481 typedef int (* ifun0) _((void)); 482 typedef int (* ifun) _((int x)); 483 typedef int (* ifunaa) _((word2 *arr1, int n1, word2 *arr2, int n2)); 484 typedef int (* ifuntt) _((truc *ptr1, truc *ptr2)); 485 486 typedef struct { 487 byte b0; 488 byte b1; 489 word2 ww; 490 } packet; 491 492 typedef struct { 493 word2 w0; 494 word2 ww; 495 } arr2; 496 497 typedef union { 498 word4 xx; 499 arr2 yy; 500 packet pp; 501 } variant; 502 503 typedef union { 504 truc t; 505 wtruc w; 506 } wvariant; 507 508 struct symbol { /* symbol structure */ 509 truc ident; 510 variant cc; /* information for syntax checking */ 511 wvariant bind; /* symbol binding */ 512 char *name; /* symbol name */ 513 truc *link; /* link to next symbol */ 514 }; 515 #define OFFSETcc 4 516 #define OFFSETcc1 6 517 #define OFFSETbind 8 518 #define OFFSETname (OFFSETbind + sizeof(wtruc)) 519 #define OFFSETlink (OFFSETbind + 2*sizeof(wtruc)) 520 #define SIZEOFSYMBOL (sizeof(struct symbol)/sizeof(truc)) 521 522 struct intsymbol { /* internal symbol structure */ 523 truc ident; 524 variant cc; 525 wvariant bind; /* symbol binding */ 526 char *name; /* symbol name */ 527 }; 528 #define SIZEOFINTSYMBOL (sizeof(struct intsymbol)/sizeof(truc)) 529 530 struct floatcell { /* float */ 531 byte flag; 532 byte signum; /* same position as in bigcell */ 533 int2 expo; 534 word2 digi0; 535 word2 digi1; 536 }; 537 #define OFFSETexpo 2 538 #define OFFSETflodig 4 539 #define SIZEOFFLOAT(prec) (unsigned)(1 + (prec>>1)) 540 541 struct bigcell { /* for big integers or gf2nint's */ 542 byte flag; /* = fBIGNUM or fGF2NINT */ 543 byte signum; /* same position as in floatcell */ 544 word2 len; /* same position as in vector */ 545 word2 digi0; 546 word2 digi1; 547 }; 548 /* 549 ** signum = 0 for nonnegative numbers, 550 ** signum = MINUSBYTE for negative numbers 551 */ 552 #define OFFSETsignum 1 553 #define OFFSETbiglen 2 554 #define OFFSETbigdig 4 555 #define SIZEOFBIG(len) (1 + (((unsigned)(len)+1)>>1)) 556 557 typedef struct { 558 long expo; 559 int sign; 560 int len; 561 word2 *digits; 562 } numdata; 563 564 struct strcell { /* string */ 565 byte flag; /* = fSTRING */ 566 byte flg2; 567 word2 len; /* same position as in struct vector */ 568 char ch0; 569 char ch1; 570 char ch2; 571 char ch3; 572 }; 573 #define OFFSETstrlen 2 574 #define OFFSETstring 4 575 #define SIZEOFSTRING(len) (2 + ((unsigned)(len)>>2)) /* includes '\0' */ 576 577 struct vector { 578 byte flag; /* = fVECTOR or = fTUPLE */ 579 byte flg2; 580 word2 len; /* same position as in bigcell */ 581 truc ele0; 582 }; 583 #define OFFSETveclen 2 584 #define OFFSETvector 4 585 #define SIZEOFTUPLE(len) (1 + (unsigned)(len)) 586 #define SIZEOFVECTOR(len) (unsigned)(len ? (1 + (len)) : 2) 587 /* for arrays of length 0, ele0 contains type */ 588 589 struct record { /* also used for pointers */ 590 byte flag; /* fRECORD or fPOINTER */ 591 byte flg2; 592 word2 len; /* same position as in vector */ 593 truc recdef; /* fTUPLE with field names and types */ 594 truc field1; 595 truc field2; 596 }; 597 #define SIZEOFRECORD(len) (2 + (unsigned)(len)) 598 #define OFFSETfield1 8 599 /* for pointers, len = 1, and field1 contains truc 600 ** designating the record pointed to, or nil 601 */ 602 603 struct stream { /* I/O stream structure */ 604 byte flag; 605 byte mode; /* one of INSTREAM,OUTSTREAM,NOSTREAM */ 606 int2 pos; /* current position in line */ 607 int4 lineno; /* current line number */ 608 int4 ch; /* current character */ 609 int4 tok; /* current token */ 610 FILE *file; /* the file associated with stream */ 611 }; 612 #define OFFSETmode 1 613 #define OFFSETpos 2 614 #define OFFSETlineno 4 615 #define OFFSETch 8 616 #define OFFSETtok 12 617 #define OFFSETfile 16 618 #define SIZEOFSTREAM (sizeof(struct stream)/sizeof(truc)) 619 620 struct stack { 621 byte flag; 622 byte line; 623 word2 pageno; 624 truc type; /* = zero in this implementation */ 625 truc page; 626 }; 627 628 #define OFFSETpage 8 629 #define SIZEOFSTACK 3 /* unit is sizeof(truc) */ 630 631 #define PAGELENBITS 5 632 #define PAGELEN 32 /* 2**PAGELENBITS */ 633 struct stackpage { 634 byte flag; /* fVECTOR */ 635 byte flg2; 636 word2 len; /* = PAGELEN + 1 */ 637 truc data[PAGELEN]; 638 truc prevpage; /* for tail rec elimination during gc */ 639 }; 640 641 struct opnode { 642 truc op; 643 truc arg0; 644 truc arg1; 645 }; 646 #define OFFSETarg0 4 647 #define OFFSETarg1 8 648 #define SIZEOFOPNODE(n) (1+(unsigned)(n)) /* unit is sizeof(truc) */ 649 650 struct funode { 651 truc op; 652 truc argno; /* number of args as FIXNUM */ 653 truc arg1; /* same position as in opnode */ 654 }; 655 #define OFFSETargcount 6 656 #define OFFSETargn(n) (4 + ((n)<<2)) 657 #define SIZEOFFUNODE(n) (2+(unsigned)(n)) /* unit is sizeof(truc) */ 658 659 struct fundef { 660 byte flag; /* = fFUNDEF */ 661 byte flg2; /* number of optional arguments */ 662 word2 argc; /* number of formal arguments */ 663 truc varno; /* number of local vars as FIXNUM */ 664 truc body; 665 truc parms; /* default initializations of formal args */ 666 truc vars; /* list of initializations of local vars */ 667 }; 668 #define OFFSETfargc 2 669 #define OFFSETvarcount 6 670 #define OFFSETbody 8 671 #define OFFSETparms 12 672 #define OFFSETvars 16 673 #define OFFS4body 2 674 #define SIZEOFFUNDEF 5 /* unit is sizeof(truc) */ 675 676 struct compnode { /* compound statement */ 677 byte flag; 678 byte flg2; 679 word2 len; 680 truc expr0; 681 truc expr1; 682 }; 683 #define SIZEOFCOMP(len) (1+(unsigned)(len)) /* unit is sizeof(truc) */ 684 #define OFFSETcomplen 2 685 686 struct fornode { 687 byte flag; 688 byte flg2; 689 word2 len; /* len = 4+bodylen, same position as in compnode */ 690 truc runvar; 691 truc start; 692 truc end; 693 truc inc; 694 truc body0; 695 truc body1; 696 }; 697 698 /*----------------------------------------------------------------*/ 699 /* 700 ** MACROS 701 */ 702 703 /* TAddress, SAddress, Taddress, Saddress defined in mem0.c */ 704 #define bTAddress(p) ((byte *)TAddress(p)) 705 #define bSAddress(p) ((byte *)SAddress(p)) 706 #define bTaddress(x) ((byte *)Taddress(x)) 707 #define bSaddress(x) ((byte *)Saddress(x)) 708 709 710 #define symptr(x) ((struct symbol *)Saddress(x)) 711 #define streamptr(x) ((struct stream *)Taddress(x)) 712 #define stringptr(x) ((struct strcell *)Taddress(x)) 713 #define recordptr(x) ((struct record *)Taddress(x)) 714 715 #define FLAG(x) *(byte *)&(x) 716 #define STRING(x) (char *)(bTaddress(x) + OFFSETstring) 717 #define STRlen(x) *(word2 *)(bTaddress(x) + OFFSETstrlen) 718 #define STRMlineno(x) *(int4 *)(bTaddress(x) + OFFSETlineno) 719 #define VECTOR(x) ((truc *)(bTaddress(x) + OFFSETvector)) 720 #define VEClen(x) *(word2 *)(bTaddress(x) + OFFSETveclen) 721 #define PTRtarget(x) *((truc *)(bTaddress(x) + OFFSETfield1)) 722 #define NODEarg0(x) *((truc *)(bTaddress(x) + OFFSETarg0)) 723 724 #define FLAGPTR(p) (byte *)(p) 725 #define SEGPTR(p) ((byte *)(p) + 1) 726 #define SIGNPTR(p) ((byte *)(p) + 1) 727 #define FLG2PTR(p) ((byte *)(p) + 1) 728 #define OFFSPTR(p) ((word2 *)(p) + 1) 729 #define WORD2PTR(p) ((word2 *)(p) + 1) 730 #define INT2PTR(p) ((int2 *)(p) + 1) 731 #define ARGCPTR(p) (word2 *)((byte *)(p) + OFFSETargcount) 732 #define VARCPTR(p) (word2 *)((byte *)(p) + OFFSETvarcount) 733 #define PARMSPTR(p) (truc *)((byte *)(p) + OFFSETparms) 734 #define VARSPTR(p) (truc *)((byte *)(p) + OFFSETvars) 735 736 #define STREAMPTR(p) ((struct stream *)TAddress(p)) 737 #define STREAMTOKPTR(p) ((int2 *)(bTAddress(p) + OFFSETtok)) 738 #define STRCELLPTR(p) ((struct strcell *)TAddress(p)) 739 #define RECORDPTR(p) ((struct record *)TAddress(p)) 740 #define VECSTRUCTPTR(p) ((struct vector *)TAddress(p)) 741 #define STRLENPTR(p) ((word2 *)(bTAddress(p) + OFFSETstrlen)) 742 #define STRINGPTR(p) ((char *)(bTAddress(p) + OFFSETstring)) 743 #define BYTEPTR(p) ((byte *)(bTAddress(p) + OFFSETstring)) 744 #define VECLENPTR(p) ((word2 *)(bTAddress(p) + OFFSETveclen)) 745 #define VECTORPTR(p) ((truc *)(bTAddress(p) + OFFSETvector)) 746 #define PTARGETPTR(p) ((truc *)(bTAddress(p) + OFFSETfield1)) 747 #define SIGNUMPTR(p) (bTAddress(p) + OFFSETsignum) 748 #define BIGLENPTR(p) ((word2 *)(bTAddress(p) + OFFSETbiglen)) 749 #define BIGNUMPTR(p) ((word2 *)(bTAddress(p) + OFFSETbigdig)) 750 #define FLTEXPOPTR(p) ((int2 *)(bTAddress(p) + OFFSETexpo)) 751 752 #define ARGCOUNTPTR(p) ((word2 *)(bTAddress(p) + OFFSETargcount)) 753 #define OPNODEPTR(p) (truc *)bTAddress(p) 754 #define ARG0PTR(p) ((truc *)(bTAddress(p) + OFFSETarg0)) 755 #define ARG1PTR(p) ((truc *)(bTAddress(p) + OFFSETarg1)) 756 #define ARGNPTR(p,n) ((truc *)(bTAddress(p) + OFFSETargn(n))) 757 758 #define COMPLENPTR(p) ((word2 *)(bTAddress(p) + OFFSETcomplen)) 759 #define FUNARGCPTR(p) ((word2 *)(bTAddress(p) + OFFSETfargc)) 760 #define FUNVARCPTR(p) ((word2 *)(bTAddress(p) + OFFSETvarcount)) 761 #define FUNVARSPTR(p) ((truc *)(bTAddress(p) + OFFSETvars)) 762 763 #define SYMPTR(p) ((struct symbol *)SAddress(p)) 764 #define SYMFLAGPTR(p) bSAddress(p) 765 #define SYMBINDPTR(p) ((truc *)(bSAddress(p) + OFFSETbind)) 766 #define SYMWBINDPTR(p) ((wtruc *)(bSAddress(p) + OFFSETbind)) 767 #define SYMNAMEPTR(p) (*(char **)(bSAddress(p) + OFFSETname)) 768 #define SYMCCPTR(p) ((word4 *)(bSAddress(p) + OFFSETcc)) 769 #define SYMCC0PTR(p) ((word2 *)(bSAddress(p) + OFFSETcc)) 770 #define SYMCC1PTR(p) ((word2 *)(bSAddress(p) + OFFSETcc1)) 771 #define LSYMBOLPTR(p) (basePtr + *WORD2PTR(p)) 772 #define LRSYMBOLPTR(p) (ArgStack + *WORD2PTR(p)) 773 #define LSYMFLAGPTR(p) (byte *)(basePtr + *WORD2PTR(p)) 774 775 #define STREAMtok(x) *(int2 *)(bTaddress(x) + OFFSETtok) 776 #define STREAMpos(x) *(int2 *)(bTaddress(x) + OFFSETpos) 777 #define STREAMfile(x) *(FILE **)(bTaddress(x) + OFFSETfile) 778 779 #define SYMflag(x) *bSaddress(x) 780 #define SYMname(x) *(char **)(bSaddress(x) + OFFSETname) 781 #define SYMbind(x) *(truc *)(bSaddress(x) + OFFSETbind) 782 #define SYMbind2(x) *(word2 *)(bSaddress(x) + OFFSETbind + 2) 783 #define SYMlink(x) *(truc **)(bSaddress(x) + OFFSETlink) 784 #define SYMcc(x) *(word4 *)(bSaddress(x) + OFFSETcc) 785 #define SYMcc0(x) *(word2 *)(bSaddress(x) + OFFSETcc) 786 #define SYMcc1(x) *(word2 *)(bSaddress(x) + OFFSETcc1) 787 788 /*----- pushes and pops ------------------------------------------*/ 789 790 #define EVALpush(obj) \ 791 if(--evalStkPtr > workStkPtr) *evalStkPtr = (obj); \ 792 else reset(err_evstk) 793 #define EVALpop() evalStkPtr++ 794 795 #define WORKpush(obj) \ 796 if(++workStkPtr < evalStkPtr) *workStkPtr = (obj); \ 797 else reset(err_wrkstk) 798 #define WORKpop() workStkPtr-- 799 #define WORKnpop(n) workStkPtr -= (n) 800 #define WORKretr() *workStkPtr-- 801 #define WORKnpush(n) \ 802 if(!((workStkPtr += (n)) < evalStkPtr)) reset(err_wrkstk) 803 #define WORKspace(n) \ 804 (workStkPtr < evalStkPtr-(n)-32 ? workStkPtr += (n) : NULL) 805 806 #define ARGpush(obj) \ 807 if(++argStkPtr < saveStkPtr) *argStkPtr = (obj); \ 808 else reset(err_astk) 809 #define ARGretr() *argStkPtr-- 810 #define ARGpop() argStkPtr-- 811 #define ARGnpop(n) argStkPtr -= (n) 812 813 #define SAVEpush(obj) \ 814 if(--saveStkPtr > argStkPtr) *saveStkPtr = (truc)(obj); \ 815 else reset(err_savstk) 816 #define SAVEretr() (trucptr)(*saveStkPtr++) 817 #define SAVEpop() saveStkPtr++ 818 #define SAVEtop() (trucptr)(*saveStkPtr) 819 #define SAVEnpop(n) saveStkPtr += (n) 820 #define SAVEspace(n) \ 821 (saveStkPtr > argStkPtr+(n) ? saveStkPtr -= (n) : NULL) 822 823 #define PARSpush(obj) \ 824 if(++argStkPtr < saveStkPtr) *argStkPtr = (obj); \ 825 else reset(err_pstk) 826 #define PARSpop() argStkPtr-- 827 #define PARSnpop(n) argStkPtr -= (n) 828 #define PARSretr() *argStkPtr-- 829 830 /*--------------------- external declarations -----------------------*/ 831 #ifdef Win32GUI 832 #include "ariwin.h" 833 #endif 834 #ifdef GtK 835 #include "gnariwin.h" 836 #endif 837 838 /* errtext.c */ 839 extern char *err_funest, *err_funame, *err_2ident, 840 *err_type, *err_btype, *err_mism, 841 *err_synt, *err_args, *err_pars, *err_parl, 842 *err_varl, *err_unvar, 843 *err_memory, *err_2large, *err_memev, *err_garb, 844 *err_evstk, *err_wrkstk, *err_astk, *err_savstk, *err_pstk, 845 *err_imp, *err_case, *err_rec, *err_intr, 846 *err_rparen, *err_0rparen, *err_0lparen, 847 *err_0brace, *err_0rbrack, 848 *err_brstr, *err_bchar, *err_inadm, 849 *err_stkv, *err_stke, *err_stkbig, *err_nil, *err_vpoint, 850 *err_filv, *err_outf, *err_tout, *err_bout, 851 *err_inpf, *err_tinp, *err_binp, 852 *err_then, *err_end, 853 *err_ovfl, *err_div, *err_2big, *err_float, *err_bool, 854 *err_int, *err_intt, *err_fix, *err_pfix, *err_pint, *err_p0int, *err_p4int, 855 *err_odd, *err_oddprim, 856 *err_char, *err_chr, *err_2long, *err_n2long, *err_iovfl, 857 *err_num, *err_pnum, *err_p0num, *err_intvar, 858 *err_pbase, *err_range, *err_irange, *err_var, *err_lval, 859 *err_vsym, *err_vasym, *err_sym, *err_gsym, *err_sym2, 860 *err_buf, *err_str, *err_bystr, *err_vbystr, 861 *err_arr, *err_syarr, *err_sarr, *err_vect, *err_field, *err_open, 862 *err_bltin, *err_ubound, *err_ufunc; 863 864 /* alloc.c */ 865 extern void inialloc _((void)); 866 extern int memalloc _((int mem)); 867 extern void dealloc _((void)); 868 extern void resetarr _((void)); 869 extern int initend _((void)); 870 extern int tempfree _((int flg)); 871 extern int inpack _((truc obj, truc pack)); 872 extern char *stringalloc _((unsigned int size)); 873 extern unsigned getblocksize _((void)); 874 extern size_t new0 _((unsigned int size)); 875 extern truc newobj _((int flg, unsigned int size, trucptr *ptraddr)); 876 extern truc new0obj _((int flg, unsigned int size, trucptr *ptraddr)); 877 extern unsigned obj4size _((int type, truc *ptr)); 878 extern void cpy4arr _((truc *ptr1, unsigned len, truc *ptr2)); 879 880 extern size_t hashtabSize, aribufSize, auxbufSize, scrbufSize; 881 882 extern truc *Symbol; 883 extern truc *Memory[]; 884 extern trucptr *Symtab; 885 extern truc *WorkStack, *evalStkPtr, *workStkPtr; 886 extern truc *ArgStack, *argStkPtr, *saveStkPtr; 887 extern truc *basePtr; 888 extern word2 *AriBuf, *AriScratch, *AuxBuf, *PrimTab; 889 890 /* array.c */ 891 extern void iniarray _((void)); 892 extern void iniargv _((int argc, char *argv[])); 893 extern int stringsplit _((char *str, char *trenn, word2 *offsets)); 894 extern int indrange _((truc *ptr, long len, long *pn0, long *pn1)); 895 extern truc arrassign _((truc *arr, truc obj)); 896 extern truc subarrassign _((truc *arr, truc obj)); 897 extern void sortarr _((truc *arr, unsigned len, ifuntt cmpfun)); 898 extern int bytestraddr _((truc *ptr, truc **ppbstr, byte **ppch, 899 unsigned *plen)); 900 extern truc recfassign _((truc *rptr, truc field, truc obj)); 901 extern truc fullrecassign _((truc *rptr, truc obj)); 902 extern truc Pdispose _((truc *ptr)); 903 904 extern truc arr_sym, subarrsym, arraysym; 905 extern truc stringsym, charsym, bitvecsym, stacksym; 906 extern truc bstringsym, bstr_sym, str_sym; 907 extern truc mkstrsym, mkbstrsym, mkarrsym, vectorsym, pairsym; 908 extern truc recordsym, mkrecsym, rec_sym, pointrsym, derefsym; 909 extern truc nullstring, nullbstring; 910 extern truc ofsym; 911 912 /* arith.c: */ 913 extern void iniarith _((void)); 914 extern truc addints _((truc *ptr, int minflg)); 915 extern unsigned random2 _((unsigned u)); 916 extern unsigned random4 _((unsigned u)); 917 extern int cmpnums _((truc *ptr1, truc *ptr2, int type)); 918 extern truc scalintvec _((truc *ptr1, truc *ptr2)); 919 920 extern truc integsym, int_sym, realsym; 921 extern truc zero, constone, flt0zero; 922 extern truc shfloatsym, sfloatsym, dfloatsym, lfloatsym, xfloatsym; 923 extern truc plussym, minussym, uminsym, 924 divsym, modsym, divfsym, timessym, powersym; 925 extern truc ariltsym, arigtsym, arilesym, arigesym, arieqsym, arinesym; 926 extern long maxfltex, maxdecex, exprange; 927 928 /* aritx.c */ 929 extern void iniaritx _((void)); 930 extern int prime16 _((unsigned u)); 931 extern int prime32 _((word4 u)); 932 extern unsigned fact16 _((word4 u)); 933 extern unsigned trialdiv _((word2 *x, int n, unsigned u0, unsigned u1)); 934 extern int jac _((unsigned x, unsigned y)); 935 extern int jacobi _((int sign, word2 *x, int n, word2 *y, int m, 936 word2 *hilf)); 937 extern int rabtest _((word2 *x, int n, word2 *aux)); 938 extern int nextprime32 _((word4 u, word2 *x)); 939 extern int pemult _((word2 *x, int n, word2 *ex, int exlen, 940 word2 *aa, int alen, 941 word2 *mm, int modlen, word2 *z, word2 *hilf)); 942 extern int modinverse _((word2 *x, int n, word2 *y, int m, word2 *zz, 943 word2 *hilf)); 944 extern int modinv _((int x, int mm)); 945 extern int modpower _((word2 *x, int n, word2 *ex, int exlen, 946 word2 *mm, int modlen, word2 *p, word2 *hilf)); 947 extern unsigned modpow _((unsigned x, unsigned n, unsigned mm)); 948 extern truc modpowsym; 949 950 /* arity.c */ 951 extern void iniarity _((void)); 952 extern void workmess _((void)); 953 extern void tick _((int c)); 954 extern int showvect _((FILE *f, word2 *xx, int len)); 955 956 /* aritz.c */ 957 extern void iniaritz _((void)); 958 extern truc gf2nzero, gf2none, gf2nintsym, gf2n_sym; 959 extern truc znXmultsym, znXsqsym, znXddivsym, znXdivsym, znXmodsym; 960 extern truc polmultsym, polNmultsym, polmodsym, polNmodsym, 961 poldivsym, polNdivsym; 962 extern truc addgf2ns _((truc *ptr)); 963 extern truc multgf2ns _((truc *ptr)); 964 extern truc divgf2ns _((truc *ptr)); 965 extern truc exptgf2n _((truc *ptr)); 966 extern int fpSqrt _((word2 *pp, int plen, word2 *aa, int alen, 967 word2 *zz, word2 *hilf)); 968 extern int fp2Sqrt _((word2 *pp, int plen, word2 *aa, int alen, 969 word2 *zz, word2 *hilf)); 970 extern unsigned fp_sqrt _((unsigned p, unsigned a)); 971 972 /* aritaux.c */ 973 extern int FltPrec[]; 974 extern int MaxFltLevel; 975 extern int setfltprec _((int prec)); 976 extern int deffltprec _((void)); 977 extern int maxfltprec _((void)); 978 extern int fltprec _((int type)); 979 extern int fltpreccode _((int prec)); 980 extern int refnumtrunc _((int prec, truc *ptr, numdata *nptr)); 981 extern int getnumtrunc _((int prec, truc *ptr, numdata *nptr)); 982 extern int getnumalign _((int prec, truc *ptr, numdata *nptr)); 983 extern int alignfloat _((int prec, numdata *nptr)); 984 extern int alignfix _((int prec, numdata *nptr)); 985 extern void adjustoffs _((numdata *npt1, numdata *npt2)); 986 extern int normfloat _((int prec, numdata *nptr)); 987 extern int multtrunc _((int prec, numdata *npt1, numdata *npt2, 988 word2 *hilf)); 989 extern int divtrunc _((int prec, numdata *npt1, numdata *npt2, 990 word2 *hilf)); 991 extern int pwrtrunc _((int prec, unsigned base, unsigned a, 992 numdata *nptr, word2 *hilf)); 993 extern int float2bcd _((int places, truc *p, numdata *nptr, 994 word2 *hilf)); 995 extern int roundbcd _((int prec, numdata *nptr)); 996 extern int flodec2bin _((int prec, numdata *nptr, word2 *hilf)); 997 extern void int2numdat _((int x, numdata *nptr)); 998 extern void cpynumdat _((numdata *npt1, numdata *npt2)); 999 extern int numposneg _((truc *ptr)); 1000 extern truc wipesign _((truc *ptr)); 1001 extern truc changesign _((truc *ptr)); 1002 extern long intretr _((truc *ptr)); 1003 extern int bigref _((truc *ptr, word2 **xp, int *sp)); 1004 extern int bigretr _((truc *ptr, word2 *x, int *sp)); 1005 extern int twocretr _((truc *ptr, word2 *x)); 1006 extern int and2arr _((word2 *x, int n, word2 *y, int m)); 1007 extern int or2arr _((word2 *x, int n, word2 *y, int m)); 1008 extern int xor2arr _((word2 *x, int n, word2 *y, int m)); 1009 extern int xorbitvec _((word2 *x, int n, word2 *y, int m)); 1010 extern long bit_length _((word2 *x, int n)); 1011 extern int chkintnz _((truc sym, truc *ptr)); 1012 extern int chkints _((truc sym, truc *argptr, int n)); 1013 extern int chkint _((truc sym, truc *ptr)); 1014 extern int chkintt _((truc sym, truc *ptr)); 1015 extern int chknums _((truc sym, truc *argptr, int n)); 1016 extern int chknum _((truc sym, truc *ptr)); 1017 extern int chkintvec _((truc sym, truc *vptr)); 1018 extern int chknumvec _((truc sym, truc *vptr)); 1019 1020 /* arito386.asm */ 1021 #ifdef M_3264 1022 extern int mult4arr _((word2 *x, int n, word4 a, word2 *y)); 1023 extern int div4arr _((word2 *x, int n, word4 a, word4 *restptr)); 1024 extern word4 mod4arr _((word2 *x, int n, word4 a)); 1025 #endif 1026 1027 /* aritool0.c */ 1028 extern int multarr _((word2 *x, int n, unsigned a, word2 *y)); 1029 extern int divarr _((word2 *x, int n, unsigned a, word2 *restptr)); 1030 extern unsigned modarr _((word2 *x, int n, unsigned a)); 1031 1032 extern int sumarr _((word2 *x, int n, word2 *y)); 1033 extern int diffarr _((word2 *x, int n, word2 *y)); 1034 extern int diff1arr _((word2 *x, int n, word2 *y)); 1035 extern int incarr _((word2 *x, int n, unsigned a)); 1036 extern int decarr _((word2 *x, int n, unsigned a)); 1037 extern void cpyarr _((word2 *x, int n, word2 *y)); 1038 extern void cpyarr1 _((word2 *x, int n, word2 *y)); 1039 extern int cmparr _((word2 *x, int n, word2 *y, int m)); 1040 extern int shrarr _((word2 *x, int n, int k)); 1041 extern int shlarr _((word2 *x, int n, int k)); 1042 extern void setarr _((word2 *x, int n, unsigned a)); 1043 extern void notarr _((word2 *x, int n)); 1044 extern void andarr _((word2 *x, int n, word2 *y)); 1045 extern void orarr _((word2 *x, int n, word2 *y)); 1046 extern void xorarr _((word2 *x, int n, word2 *y)); 1047 extern unsigned int2bcd _((unsigned x)); 1048 extern unsigned bcd2int _((unsigned x)); 1049 extern int big2bcd _((word2 *x, int n, word2 *y)); 1050 extern int long2big _((word4 u, word2 *x)); 1051 extern word4 big2long _((word2 *x, int n)); 1052 extern word4 intsqrt _((word4 u)); 1053 extern int bitlen _((unsigned x)); 1054 extern int niblen _((unsigned x)); 1055 extern int bitcount _((unsigned u)); 1056 1057 /* aritools.c */ 1058 extern int shiftarr _((word2 *x, int n, int sh)); 1059 extern int lshiftarr _((word2 *x, int n, long sh)); 1060 extern int addarr _((word2 *x, int n, word2 *y, int m)); 1061 extern int subarr _((word2 *x, int n, word2 *y, int m)); 1062 extern int sub1arr _((word2 *x, int n, word2 *y, int m)); 1063 extern int addsarr _((word2 *x, int n, int sign1, 1064 word2 *y, int m, int sing2, int *psign)); 1065 extern int multbig _((word2 *x, int n, word2 *y, int m, word2 *z, 1066 word2 *hilf)); 1067 extern int divbig _((word2 *x, int n, word2 *y, int m, word2 *quot, 1068 int *rlenptr, word2 *hilf)); 1069 extern int modbig _((word2 *x, int n, word2 *y, int m, word2 *hilf)); 1070 extern int modnegbig _((word2 *x, int n, word2 *y, int m, word2 *hilf)); 1071 extern int modmultbig _((word2 *xx, int xlen, word2 *yy, int ylen, 1072 word2 *mm, int mlen, word2 *zz, word2 *hilf)); 1073 extern int multfix _((int prec, word2 *x, int n, word2 *y, int m, 1074 word2 *z, word2 *hilf)); 1075 extern int divfix _((int prec, word2 *x, int n, word2 *y, int m, 1076 word2 *z, word2 *hilf)); 1077 extern unsigned shortgcd _((unsigned x, unsigned y)); 1078 extern int biggcd _((word2 *x, int n, word2 *y, int m, word2 *hilf)); 1079 extern int power _((word2 *x, int n, unsigned a, word2 *p, 1080 word2 *temp, word2 *hilf)); 1081 extern int bigsqrt _((word2 *x, int n, word2 *z, int *rlenptr, 1082 word2 *temp)); 1083 extern int lbitlen _((word4 x)); 1084 extern int bcd2big _((word2 *x, int n, word2 *y)); 1085 extern int str2int _((char *str, int *panz)); 1086 extern int str2big _((char *str, word2 *arr, word2 *hilf)); 1087 extern int bcd2str _((word2 *arr, int n, char *str)); 1088 extern int big2xstr _((word2 *arr, int n, char *str)); 1089 extern int digval _((int ch)); 1090 extern int xstr2big _((char *str, word2 *arr)); 1091 extern int ostr2big _((char *str, word2 *arr)); 1092 extern int bstr2big _((char *str, word2 *arr)); 1093 extern int nibdigit _((word2 *arr, int k)); 1094 extern int nibndigit _((int n, word2 *arr, long k)); 1095 extern int nibascii _((word2 *arr, int k)); 1096 extern int hexascii _((int n)); 1097 extern int shiftbcd _((word2 *arr, int n, int k)); 1098 extern int incbcd _((word2 *x, int n, unsigned a)); 1099 1100 /* analysis.c */ 1101 extern void inianalys _((void)); 1102 extern int lognum _((int prec, numdata *nptr, word2 *hilf)); 1103 extern int expnum _((int prec, numdata *nptr, word2 *hilf)); 1104 1105 /* eval.c: */ 1106 extern void inieval _((void)); 1107 extern truc eval _((truc *ptr)); 1108 extern truc ufunapply _((truc *fun, truc *arr, int n)); 1109 extern truc arreval _((truc *arr, int n)); 1110 1111 /* file.c */ 1112 extern void inifile _((void)); 1113 extern int fnextens _((char *str, char *name, char *extens)); 1114 extern int issepdir _((int ch)); 1115 extern int isoutfile _((truc *strom, int mode)); 1116 extern int isinpfile _((truc *strom, int mode)); 1117 extern int loadaux _((char *str, int verb, char *skipto)); 1118 extern long filelen _((truc *ptr)); 1119 extern char *ariExtens; 1120 extern truc filesym, eofsym; 1121 extern truc tstdout, tstdin, tstderr; 1122 1123 /* control.c: */ 1124 extern void inicont _((void)); 1125 extern int is_lval _((truc *ptr)); 1126 extern int Lvaladdr _((truc *ptr, trucptr *pvptr)); 1127 extern truc Lvalassign _((truc *ptr, truc obj)); 1128 extern truc Swhile _((void)); 1129 extern truc Sfor _((void)); 1130 extern void Sifaux _((void)); 1131 extern truc Sexit _((void)); 1132 extern truc brkerr _((void)); 1133 extern truc Lconsteval _((truc *ptr)); 1134 extern int Lconstini _((truc consts)); 1135 extern truc unbindsym _((truc *ptr)); 1136 extern truc unbinduser _((void)); 1137 1138 extern truc exitsym, exitfun, ret_sym, retsym; 1139 extern truc lpbrksym, lpbrkfun, lpcontsym, lpcontfun; 1140 extern truc equalsym, nequalsym; 1141 extern truc funcsym, procsym, beginsym, endsym; 1142 extern truc extrnsym, constsym, typesym; 1143 extern truc varsym, var_sym, inivarsym; 1144 extern truc whilesym, dosym, ifsym, thensym, elsifsym, elsesym; 1145 extern truc forsym, tosym, bysym; 1146 1147 extern truc not_sym, notsym; 1148 extern truc *brkbindPtr, *brkmodePtr; 1149 extern truc breaksym, errsym, nullsym, voidsym; 1150 extern truc contsym, contnsym; 1151 extern truc assignsym; 1152 extern truc boolsym, truesym, falsesym, true, false, nil; 1153 extern truc usersym, arisym, symbsym; 1154 1155 /* mainloop.c */ 1156 #ifdef DTRACE 1157 extern FILE *DTraceF; 1158 extern int DTraceWrite(char *mess); 1159 extern char DTraceZeile[80]; 1160 #endif 1161 extern truc helpsym; 1162 extern truc apathsym; 1163 extern truc *res1Ptr, *res2Ptr, *res3Ptr; 1164 extern int Unterbrech; 1165 1166 extern int error _((truc source, char *message, truc obj)); 1167 extern void setinterrupt _((int flg)); 1168 extern void reset _((char *message)); 1169 extern void faterr _((char *mess)); 1170 extern int findfile _((char *paths, char *fnam, char *buf)); 1171 extern int findarifile _((char *name, char *buf)); 1172 1173 #ifdef DOSorUNiX 1174 extern void ctrlcreset _((int sig)); 1175 #endif 1176 1177 #ifdef MYFUN 1178 extern void inimyfun _((void)); 1179 #endif 1180 1181 /* mem0.c */ 1182 extern truc *Taddress _((truc x)); 1183 extern truc *TAddress _((truc *p)); 1184 extern truc *Saddress _((truc x)); 1185 extern truc *SAddress _((truc *p)); 1186 extern int Tflag _((truc x)); 1187 extern int Symflag _((truc x)); 1188 1189 /* parser.c */ 1190 extern void iniparse _((void)); 1191 extern truc tread _((truc *strom, int mode)); 1192 extern void clearcompile _((void)); 1193 1194 extern truc parserrsym; 1195 1196 /* scanner.c */ 1197 extern void iniscan _((void)); 1198 extern int nexttok _((truc *strom, int skip)); 1199 extern int curtok _((truc *strom)); 1200 extern int fltreadprec _((void)); 1201 extern int skipeoltok _((truc *strom)); 1202 extern int isalfa _((int ch)); 1203 extern int isdigalfa _((int ch)); 1204 extern int isdecdigit _((int ch)); 1205 extern int ishexdigit _((int ch)); 1206 extern int isoctdigit _((int ch)); 1207 extern int isbindigit _((int ch)); 1208 extern int toupcase _((int ch)); 1209 extern int tolowcase _((int ch)); 1210 extern char *trimblanks _((char *str, int mode)); 1211 extern int rerror _((truc sym1, char *mess, truc sym2)); 1212 1213 extern numdata Curnum; 1214 extern char *StrBuf; /* string buffer */ 1215 extern char *SymBuf; /* buffer for symbol names */ 1216 extern truc Curop; /* currently processed operator */ 1217 1218 /* print.c */ 1219 extern void iniprint _((int cols)); 1220 extern int logout _((int ch)); 1221 extern void strlogout _((char *str)); 1222 extern void closelog _((void)); 1223 extern void flushlog _((void)); 1224 extern int setprnprec _((int prec)); 1225 extern void tprint _((truc strom, truc obj)); 1226 extern int strcopy _((char *tostr, char *fromstr)); 1227 extern int strncopy _((char *tostr, char *fromstr, int maxlen)); 1228 extern int fprintstr _((truc strom, char *str)); 1229 extern void fprintline _((truc strom, char *str)); 1230 extern void fnewline _((truc strom)); 1231 extern void ffreshline _((truc strom)); 1232 extern void flinepos0 _((truc strom)); 1233 extern int s1form _((char *buf, char *fmt, wtruc dat)); 1234 extern int s2form _((char *buf, char *fmt, wtruc dat1, wtruc dat2)); 1235 1236 extern truc writesym, writlnsym, formatsym; 1237 extern truc transcsym; 1238 extern char OutBuf[]; 1239 extern int Log_on; 1240 1241 /* storage.c */ 1242 extern void inistore _((void)); 1243 extern truc *nextsymptr _((int i)); 1244 extern truc symbobj _((truc *ptr)); 1245 extern int lookupsym _((char *name, truc *pobj)); 1246 extern truc mksym _((char *name, int *sflgptr)); 1247 extern truc scratch _((char *name)); 1248 extern truc newselfsym _((char *name, int flg)); 1249 extern truc newreflsym _((char *name, int flg)); 1250 extern truc newintsym _((char *name, int flg, wtruc bind)); 1251 extern int tokenvalue _((truc op)); 1252 extern truc newsym _((char *name, int flg, truc bind)); 1253 extern truc newsymsig _((char *name, int flg, wtruc bind, int sig)); 1254 extern truc new0symsig _((char *name, int flg, wtruc bind, int sig)); 1255 extern truc mkcopy _((truc *x)); 1256 extern truc mkcopy0 _((truc *x)); 1257 extern truc mkarrcopy _((truc *x)); 1258 extern truc mkinum _((long n)); 1259 extern truc mkarr2 _((unsigned w0, unsigned w1)); 1260 extern truc mklocsym _((int flg, unsigned u)); 1261 extern truc mkfixnum _((unsigned n)); 1262 extern truc mksfixnum _((int n)); 1263 extern truc mkint _((int sign, word2 *arr, int len)); 1264 extern truc mkgf2n _((word2 *arr, int len)); 1265 extern truc mk0gf2n _((word2 *arr, int len)); 1266 extern truc mkfloat _((int prec, numdata *nptr)); 1267 extern truc fltzero _((int prec)); 1268 extern truc mk0float _((numdata *nptr)); 1269 extern truc mkchar _((int ch)); 1270 extern truc mkbstr _((byte *arr, unsigned len)); 1271 extern truc mkstr _((char *str)); 1272 extern truc mkstr0 _((unsigned len)); 1273 extern truc mkbstr0 _((unsigned len)); 1274 extern truc mknullstr _((void)); 1275 extern truc mknullbstr _((void)); 1276 extern truc mkvect0 _((unsigned len)); 1277 extern truc mkrecord _((int flg, truc *ptr, unsigned len)); 1278 extern truc mkstack _((void)); 1279 extern truc mkstream _((FILE *file, int mode)); 1280 extern truc mk0stream _((FILE *file, int mode)); 1281 extern truc mk0fun _((truc op)); 1282 extern truc mkpair _((int flg, truc sym1, truc sym2)); 1283 extern truc mkunode _((truc op)); 1284 extern truc mkbnode _((truc op)); 1285 extern truc mkspecnode _((truc fun, truc *argptr, int k)); 1286 extern truc mkfunode _((truc fun, int n)); 1287 extern truc mkfundef _((int argc, int argoptc, int varc)); 1288 extern truc mkntuple _((int flg, truc *arr, int n)); 1289 extern truc mkcompnode _((int flg, int n)); 1290 1291 /* terminal.c */ 1292 extern void initerm _((void)); 1293 extern void inputprompt _((void)); 1294 extern void dumpinput _((void)); 1295 extern char *treadline _((void)); 1296 extern void historyout _((int flg)); 1297 1298 extern truc historsym, savinsym, bufovflsym; 1299 1300 /* sysdep.c */ 1301 extern void stacklimit _((void)); 1302 extern long stkcheck _((void)); 1303 extern long timer _((void)); 1304 extern long datetime _((int tim[6])); 1305 extern int sysrand _((void)); 1306 extern void prologue _((void)); 1307 extern int epilogue _((void)); 1308 extern char *getworkdir _((void)); 1309 extern int setworkdir _((char *pfad)); 1310 #ifdef ATARIST 1311 extern int VDI_handle; 1312 #endif 1313 1314 /* syntchk.c */ 1315 extern void inisyntchk _((void)); 1316 extern int chknargs _((truc fun, int n)); 1317 1318 extern int s_dum, s_0, s_01, s_02, s_0u, s_1, s_1u, s_12, s_bV, 1319 s_rr, s_vr, s_ii, s_iI, s_bs, s_nv, s_rrr, s_iii, 1320 s_12ii, s_12rn, s_13, s_14, s_2, s_23, s_3, s_0uii, 1321 s_iiii, s_4, s_Viiii, s_iiiII; 1322 1323 #define NARGS_FALSE 0 1324 #define NARGS_OK 1 1325 #define NARGS_VAR 255 1326 1327 /**************************************************************************/ 1328