home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume26 / veos-2.0 / part10 < prev    next >
Encoding:
Text File  |  1993-04-25  |  72.1 KB  |  2,560 lines

  1. Newsgroups: comp.sources.unix
  2. From: voodoo@hitl.washington.edu (Geoffery Coco)
  3. Subject: v26i193: veos-2.0 - The Virtual Environment Operating Shell, V2.0, Part10/16
  4. Sender: unix-sources-moderator@vix.com
  5. Approved: paul@vix.com
  6.  
  7. Submitted-By: voodoo@hitl.washington.edu (Geoffery Coco)
  8. Posting-Number: Volume 26, Issue 193
  9. Archive-Name: veos-2.0/part10
  10.  
  11. #! /bin/sh
  12. # This is a shell archive.  Remove anything before this line, then unpack
  13. # it by saving it into a file and typing "sh file".  To overwrite existing
  14. # files, type "sh file -c".  You can also feed this as standard input via
  15. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  16. # will see the following message at the end:
  17. #        "End of archive 10 (of 16)."
  18. # Contents:  src/kernel_current/shell/xv_native.c
  19. #   src/xlisp/xcore/c/xleval.c src/xlisp/xcore/c/xlftab.c
  20. # Wrapped by vixie@efficacy.home.vix.com on Sun Apr 25 23:10:42 1993
  21. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  22. if test -f 'src/kernel_current/shell/xv_native.c' -a "${1}" != "-c" ; then 
  23.   echo shar: Will not clobber existing file \"'src/kernel_current/shell/xv_native.c'\"
  24. else
  25. echo shar: Extracting \"'src/kernel_current/shell/xv_native.c'\" \(24300 characters\)
  26. sed "s/^X//" >'src/kernel_current/shell/xv_native.c' <<'END_OF_FILE'
  27. X/****************************************************************************************
  28. X *                                            *
  29. X * file: xv_native.c                                    *
  30. X *                                            *
  31. X * the xlisp wrappers for the VEOS native prims.                    *
  32. X *                                            *
  33. X * creation: December, 1991                                *
  34. X *                                            *
  35. X *                                            *
  36. X * by Geoffrey P. Coco at the HITLab, Seattle.                          *
  37. X *                                            *
  38. X ****************************************************************************************/
  39. X
  40. X
  41. X
  42. X/****************************************************************************************
  43. X * Copyright (C) 1992  Geoffrey P. Coco, Human Interface Technology Lab, Seattle    *
  44. X ****************************************************************************************/
  45. X
  46. X
  47. X
  48. X/****************************************************************************************
  49. X                      Preliminaries
  50. X ****************************************************************************************/
  51. X
  52. X#include <math.h>
  53. X#include "xlisp.h"
  54. X
  55. X/* VEOS definitions: */
  56. X#include "kernel.h"
  57. X
  58. X#define DEFINE_NATIVE_GLOBS
  59. X#include "xv_native.h"
  60. X#undef DEFINE_NATIVE_GLOBS
  61. X
  62. X/****************************************************************************************/
  63. X
  64. XTVeosErr Native_MessageToLSpace();
  65. Xvoid Native_ShowMatchArgs();
  66. Xvoid Native_ShowSite();
  67. XTVeosErr Native_XCopySiteMatches();
  68. XTVeosErr Native_XRemoveSiteMatches();
  69. XTVeosErr Native_XInsertEltAtSite();
  70. Xvoid Native_NextMsg();
  71. XTVeosErr Native_DoThrow();
  72. X
  73. X/****************************************************************************************/
  74. X
  75. X
  76. X
  77. X/****************************************************************************************
  78. X                 Veos Primitive Wrappers
  79. X ****************************************************************************************/
  80. X
  81. X
  82. X/****************************************************************************************/
  83. XLVAL Native_Init()
  84. X{    
  85. X    LVAL         pXReturn;
  86. X    int        iPort;
  87. X    TVeosErr    iErr;
  88. X    
  89. X    xlsave1(pXReturn);
  90. X
  91. X    if (!moreargs())
  92. X    iPort = TALK_BOGUS_FD;
  93. X    else
  94. X    iPort = getfixnum(xlgafixnum());
  95. X
  96. X    xllastarg();
  97. X
  98. X
  99. X    /** invoke veos kernel inialization **/
  100. X    
  101. X    iErr = Kernel_Init(iPort, Native_MessageToLSpace);
  102. X    if (iErr == VEOS_SUCCESS) {
  103. X
  104. X
  105. X    /** create a lisp based inspace for messages **/
  106. X
  107. X    s_InSpace = xlenter("VEOS_INSPACE");
  108. X    setvalue(s_InSpace, NIL);
  109. X    NATIVE_INSPACE = &getvalue(s_InSpace);
  110. X
  111. X
  112. X    /** create keyword symbols for nancy prims **/
  113. X
  114. X    k_TestTime = xlenter(":TEST-TIME"); /* use with copy only */
  115. X    k_Freq = xlenter(":FREQ");         /* use with copy, put or get */
  116. X
  117. X
  118. X    /** setup invariant matcher settings in global param blocks **/
  119. X
  120. X    Native_InitMatcherPBs();
  121. X
  122. X
  123. X    /** make a uid return value to signify success **/
  124. X
  125. X
  126. X    Uid2XVect(&IDENT_ADDR, &pXReturn);
  127. X    }
  128. X
  129. X
  130. X    xlpop();
  131. X
  132. X
  133. X    return(pXReturn);
  134. X
  135. X    }  /* Native_Init */
  136. X/****************************************************************************************/
  137. X
  138. X
  139. X
  140. X/****************************************************************************************/
  141. XLVAL Native_Close()
  142. X{    
  143. X    if (!KERNEL_INIT)
  144. X    Native_TrapErr(NATIVE_NOKERNEL, nil);
  145. X
  146. X    xllastarg();
  147. X
  148. X    Kernel_Shutdown();
  149. X
  150. X    return(true);
  151. X
  152. X    } /* Native_Close */
  153. X/****************************************************************************************/
  154. X
  155. X
  156. X
  157. X/****************************************************************************************/
  158. XLVAL Native_Task()
  159. X{    
  160. X#ifndef OPTIMAL
  161. X    if (!KERNEL_INIT)
  162. X    Native_TrapErr(NATIVE_NOKERNEL, nil);
  163. X
  164. X    xllastarg();
  165. X#endif
  166. X
  167. X    /** talk will call our message handler and stuff the inspace **/
  168. X
  169. X    Kernel_SystemTask();
  170. X
  171. X
  172. X    return(true);
  173. X
  174. X    } /* Native_Task */
  175. X/****************************************************************************************/
  176. X
  177. X
  178. X
  179. X
  180. X/****************************************************************************************/
  181. XLVAL Native_Put()
  182. X{
  183. X    TVeosErr    iErr;
  184. X    TTimeStamp    tNow;
  185. X
  186. X#ifndef OPTIMAL
  187. X    if (!KERNEL_INIT)
  188. X    Native_TrapErr(NATIVE_NOKERNEL, nil);
  189. X#endif
  190. X
  191. X
  192. X
  193. X    /** get mandatory data argument **/
  194. X
  195. X    native_putPB.pXReplaceElt = xlgetarg();
  196. X
  197. X    
  198. X    
  199. X    /** get pattern from xlisp args **/
  200. X
  201. X    iErr = Native_GetPatternArg(&native_putPB.pPatGr, NANCY_ReplaceMatch);
  202. X    if (iErr != VEOS_SUCCESS)
  203. X    Native_TrapErr(iErr, nil);
  204. X
  205. X
  206. X    /** get optional frequency argument **/
  207. X
  208. X    NATIVE_FREQ_ARG(native_putPB.iFreqFlag);
  209. X
  210. X
  211. X    /** set the data time-stamp **/
  212. X
  213. X    GET_TIME(tNow);
  214. X    native_putPB.pStampTime = &tNow;
  215. X
  216. X
  217. X    /** dispatch the matcher **/
  218. X
  219. X    xlsave1(native_putPB.pXResult);
  220. X    
  221. X    Native_XMandR(&native_putPB);
  222. X
  223. X    xlpop();
  224. X
  225. X
  226. X
  227. X    /** clean up **/
  228. X
  229. X    Nancy_DisposeGrouple(native_putPB.pPatGr);
  230. X
  231. X
  232. X
  233. X    return (native_putPB.pXResult);
  234. X
  235. X    } /* Native_Put */
  236. X/****************************************************************************************/
  237. X
  238. X
  239. X/****************************************************************************************/
  240. XLVAL Native_Get()
  241. X{
  242. X    TVeosErr    iErr;
  243. X
  244. X#ifndef OPTIMAL
  245. X    if (!KERNEL_INIT)
  246. X    Native_TrapErr(NATIVE_NOKERNEL, nil);
  247. X#endif
  248. X
  249. X    /** get pattern from xlisp args **/
  250. X
  251. X    iErr = Native_GetPatternArg(&native_getPB.pPatGr, NANCY_RemoveMatch);
  252. X    if (iErr != VEOS_SUCCESS)
  253. X    Native_TrapErr(iErr, nil);
  254. X
  255. X
  256. X    /** get optional frequency argument **/
  257. X
  258. X    NATIVE_FREQ_ARG(native_getPB.iFreqFlag);
  259. X
  260. X
  261. X    /** dispatch the matcher **/
  262. X    
  263. X    xlsave1(native_getPB.pXResult);
  264. X
  265. X    Native_XMandR(&native_getPB);
  266. X
  267. X    xlpop();
  268. X
  269. X
  270. X    /** clean up **/
  271. X
  272. X    Nancy_DisposeGrouple(native_getPB.pPatGr);
  273. X
  274. X
  275. X
  276. X    return (native_getPB.pXResult);
  277. X
  278. X    } /* Native_Get */
  279. X/****************************************************************************************/
  280. X
  281. X
  282. X/****************************************************************************************/
  283. XLVAL Native_Copy()
  284. X{
  285. X    TVeosErr    iErr;
  286. X    TTimeStamp    tTest;
  287. X
  288. X#ifndef OPTIMAL
  289. X    if (!KERNEL_INIT)
  290. X    Native_TrapErr(NATIVE_NOKERNEL, nil);
  291. X#endif
  292. X
  293. X
  294. X
  295. X    /** get pattern from xlisp args **/
  296. X
  297. X    iErr = Native_GetPatternArg(&native_copyPB.pPatGr, NANCY_CopyMatch);
  298. X    if (iErr != VEOS_SUCCESS)
  299. X    Native_TrapErr(iErr, nil);
  300. X
  301. X
  302. X    /** look for optional time-stamp-test **/
  303. X
  304. X    NATIVE_TIME_ARG(native_copyPB.pTestTime, tTest);
  305. X
  306. X
  307. X    /** get optional frequency argument **/
  308. X
  309. X    NATIVE_FREQ_ARG(native_copyPB.iFreqFlag);
  310. X
  311. X
  312. X    /** dispatch the matcher **/
  313. X
  314. X    xlsave1(native_copyPB.pXResult);
  315. X    
  316. X    Native_XMandR(&native_copyPB);
  317. X
  318. X    xlpop();
  319. X
  320. X
  321. X    /** clean up **/
  322. X
  323. X    Nancy_DisposeGrouple(native_copyPB.pPatGr);
  324. X
  325. X
  326. X
  327. X    return (native_copyPB.pXResult);
  328. X
  329. X    } /* Native_Copy */
  330. X/****************************************************************************************/
  331. X
  332. X
  333. X/****************************************************************************************/
  334. XLVAL Native_Throw()
  335. X{
  336. X    LVAL    pXData, pXDests;
  337. X    TVeosErr    iErr;
  338. X
  339. X#ifndef OPTIMAL
  340. X    if (!KERNEL_INIT)
  341. X    Native_TrapErr(NATIVE_NOKERNEL, nil);
  342. X#endif
  343. X
  344. X    /** get dests argument **/
  345. X
  346. X    pXDests = xlgalist();
  347. X
  348. X
  349. X    /** get data argument **/
  350. X
  351. X    pXData = xlgetarg();
  352. X
  353. X#ifndef OPTIMAL
  354. X    xllastarg();
  355. X#endif
  356. X
  357. X    iErr = Native_DoThrow(pXDests, pXData);
  358. X
  359. X    return(iErr == VEOS_SUCCESS ? true : NIL);
  360. X
  361. X    } /* Native_Throw */
  362. X/****************************************************************************************/
  363. X
  364. X
  365. X
  366. X/****************************************************************************************/
  367. XLVAL Native_Catch()
  368. X{
  369. X    LVAL    pSave;
  370. X    TPElt    pElt;
  371. X
  372. X#ifndef OPTIMAL
  373. X    if (!KERNEL_INIT)
  374. X    Native_TrapErr(NATIVE_NOKERNEL, nil);
  375. X
  376. X    xllastarg();
  377. X#endif
  378. X
  379. X    Native_NextMsg(&pSave);
  380. X
  381. X    return (pSave);
  382. X
  383. X    } /* Native_Catch */
  384. X/****************************************************************************************/
  385. X
  386. X
  387. X
  388. X/****************************************************************************************/
  389. XLVAL Native_MinTime()
  390. X{    
  391. X    TF2L    fTrans;
  392. X    
  393. X    /* guaranteed to be earlier than any system time */
  394. X
  395. X    fTrans.u.l = NANCY_MINTIME;
  396. X
  397. X    return(cvflonum(fTrans.u.f));
  398. X
  399. X    }  /* Native_MinTime */
  400. X/****************************************************************************************/
  401. X
  402. X
  403. X
  404. X/****************************************************************************************/
  405. XLVAL Native_NoSignals()
  406. X{    
  407. X    SIG_ENABLE = FALSE;
  408. X
  409. X    return(true);
  410. X
  411. X    }  /* Native_NoSignals */
  412. X/****************************************************************************************/
  413. X
  414. X
  415. X
  416. X/****************************************************************************************/
  417. XLVAL Native_Bugs()
  418. X{    
  419. X    LVAL    pXModule;
  420. X    char    *sName;
  421. X
  422. X    pXModule = xlgastring();
  423. X    sName = (char *) getstring(pXModule);
  424. X    
  425. X    if (strcmp(sName, "talk") == 0)
  426. X    TALK_BUGS = TALK_BUGS ? FALSE : TRUE;
  427. X
  428. X    else if (strcmp(sName, "nancy") == 0)
  429. X    NANCY_BUGS = NANCY_BUGS ? FALSE : TRUE;
  430. X
  431. X    else if (strcmp(sName, "shell") == 0)
  432. X    SHELL_BUGS = SHELL_BUGS ? FALSE : TRUE;
  433. X
  434. X    return(true);
  435. X
  436. X    }  /* Native_Bugs */
  437. X/****************************************************************************************/
  438. X
  439. Xextern int iEvals;
  440. X
  441. X/****************************************************************************************/
  442. XLVAL Native_Zoot()
  443. X{
  444. X    static int    iAlreadySeen = 0;
  445. X    int        iSinceLast;
  446. X
  447. X    iSinceLast = iEvals - iAlreadySeen;
  448. X    iAlreadySeen = iEvals;
  449. X
  450. X    return(cvfixnum(iSinceLast));
  451. X
  452. X    } /* Native_Zoot */
  453. X/****************************************************************************************/
  454. X
  455. X
  456. X
  457. X
  458. X/****************************************************************************************
  459. X             The Beuractratic Linkage Between Veos and XLISP
  460. X ****************************************************************************************/
  461. X
  462. X
  463. X/****************************************************************************************/
  464. XTVeosErr Shell_LoadNativePrims()
  465. X{
  466. X#define VEOS_NATIVE_LOAD
  467. X#include "xv_native_prims.h"
  468. X#undef VEOS_NATIVE_LOAD
  469. X
  470. X    return(VEOS_SUCCESS);
  471. X    }
  472. X/****************************************************************************************/
  473. X
  474. X
  475. X/****************************************************************************************/
  476. XTVeosErr Shell_BailOut(sErr)
  477. X    char        *sErr;
  478. X{
  479. X
  480. X    xlfatal(sErr);
  481. X
  482. X    /** not reached **/
  483. X
  484. X    return(VEOS_SUCCESS);
  485. X
  486. X    } /* Shell_BailOut */
  487. X/****************************************************************************************/
  488. X
  489. X
  490. X
  491. X/****************************************************************************************
  492. X             The Sticky Goo Just Beneath the Wrappers
  493. X ****************************************************************************************/
  494. X
  495. X
  496. X/****************************************************************************************/
  497. XTVeosErr Native_InitMatcherPBs()
  498. X{
  499. X    /** vget settings **/
  500. X    
  501. X    native_getPB.pSrcGr = WORK_SPACE;
  502. X    native_getPB.iDestroyFlag = NANCY_RemoveMatch;
  503. X    native_getPB.pXReplaceElt = nil;
  504. X    native_getPB.pStampTime = nil;
  505. X    native_getPB.pTestTime = nil;
  506. X    
  507. X    /** vcopy settings **/
  508. X    
  509. X    native_copyPB.pSrcGr = WORK_SPACE;
  510. X    native_copyPB.iDestroyFlag = NANCY_CopyMatch;
  511. X    native_copyPB.pXReplaceElt = nil;
  512. X    native_copyPB.pStampTime = nil;
  513. X
  514. X    /** vput settings **/
  515. X    
  516. X    native_putPB.pSrcGr = WORK_SPACE;
  517. X    native_putPB.iDestroyFlag = NANCY_ReplaceMatch;
  518. X    native_putPB.pTestTime = nil;
  519. X
  520. X
  521. X    return(VEOS_SUCCESS);
  522. X    
  523. X    } /* Native_InitMatcherPBs */
  524. X/****************************************************************************************/
  525. X
  526. X
  527. X
  528. X/****************************************************************************************/
  529. XTVeosErr Native_DoThrow(pXDests, pXData)
  530. X    LVAL    pXData, pXDests;
  531. X{
  532. X    TPUidNode    pDests;
  533. X    TVeosErr    iErr;
  534. X    TMsgRec    msgOut;
  535. X
  536. X
  537. X    /** convert host/port vectors to talk uids **/
  538. X
  539. X    iErr = Native_XVectsToUids(pXDests, &pDests);
  540. X    if (iErr != VEOS_SUCCESS) {
  541. X    Native_TrapErr(iErr, pXDests);
  542. X    }
  543. X
  544. X    /** convert data element to flat network format **/
  545. X
  546. X    iErr = Native_XEltToMsgRec(pXData, &msgOut);
  547. X    if (iErr != VEOS_SUCCESS) {
  548. X    Native_DisposeUids(pDests);
  549. X    Native_TrapErr(iErr, pXData);
  550. X    }
  551. X
  552. X    /** pass the flat message to veos kernel **/
  553. X
  554. X    iErr = Talk_SpeakToMany(pDests, &msgOut);
  555. X
  556. X
  557. X    Native_DisposeUids(pDests);
  558. X
  559. X    return(iErr);
  560. X
  561. X    } /* Native_DoThrow */
  562. X/****************************************************************************************/
  563. X
  564. X
  565. X
  566. X/****************************************************************************************/
  567. Xvoid Native_NextMsg(hMsg)
  568. X    LVAL          *hMsg;
  569. X{
  570. X    *hMsg = NIL;
  571. X
  572. X    if (!null(*NATIVE_INSPACE)) {
  573. X    
  574. X    /** get the oldest message **/
  575. X    
  576. X    *hMsg = car(*NATIVE_INSPACE);
  577. X    
  578. X    /** remove this msg from list immediately. 
  579. X     ** first cons cell in this list will thus be garbage collected. 
  580. X     ** pass back the new msg. 
  581. X     **/ 
  582. X    
  583. X    *NATIVE_INSPACE = cdr(*NATIVE_INSPACE); 
  584. X    }
  585. X    }
  586. X/****************************************************************************************/
  587. X
  588. X
  589. X
  590. X/****************************************************************************************/
  591. XTVeosErr Native_XMandR(pMandRPB)
  592. X    TPXMandRRec        pMandRPB;
  593. X{
  594. X    TVeosErr        iErr;
  595. X    TMatchRec        matchSpec;
  596. X    TPReplaceRec    pSite, pSave;
  597. X
  598. X    
  599. X    /** Initialize the match record.
  600. X     ** This record get passed through the entire match process.
  601. X     ** The matcher uses to record sites for removal and insertion.
  602. X     ** If the matcher returns success,
  603. X     ** we then perform any destructive operations on the gspace.
  604. X     **/
  605. X
  606. X    matchSpec.pPatGr = pMandRPB->pPatGr;
  607. X    matchSpec.pSrcGr = pMandRPB->pSrcGr;
  608. X    matchSpec.iDestroyFlag = pMandRPB->iDestroyFlag;
  609. X    matchSpec.iFreqFlag = pMandRPB->iFreqFlag;
  610. X    matchSpec.pReplaceList = nil;
  611. X    matchSpec.pTouchList = nil;
  612. X
  613. X#ifndef OPTIMAL
  614. X    if (NANCY_BUGS) 
  615. X    Native_ShowMatchArgs(pMandRPB);
  616. X#endif
  617. X
  618. X    /************************************/
  619. X
  620. X    iErr = Nancy_MatchGrouple(&matchSpec);
  621. X
  622. X    /************************************/
  623. X
  624. X#ifndef OPTIMAL
  625. X    if (NANCY_BUGS)
  626. X    fprintf(stderr, "nancy %s: match %s.\n", 
  627. X        WHOAMI, iErr == VEOS_SUCCESS ? "succeeded" : "failed");
  628. X#endif
  629. X        
  630. X    /** Perform any destructive operations on the gspace.
  631. X     ** These occur in on a per-site basis.
  632. X     ** A site is:
  633. X     **   an enclosing grouple,
  634. X     **   a set of element intervals,
  635. X     **   an element index at which to insert.
  636. X     ** Sites are generated by the matcher during matching.
  637. X     **/
  638. X
  639. X    /** perform destructive element retrieval
  640. X     **/
  641. X
  642. X    switch (pMandRPB->iDestroyFlag) {
  643. X
  644. X    case NANCY_CopyMatch:
  645. X    for (pSite = matchSpec.pReplaceList;
  646. X         pSite && iErr == VEOS_SUCCESS;
  647. X         pSite = pSite->pNext) {
  648. X#ifndef OPTIMAL
  649. X        if (NANCY_BUGS) 
  650. X        Native_ShowSite(pSite);
  651. X#endif
  652. X        iErr = Native_XCopySiteMatches(pSite, pMandRPB->pTestTime,
  653. X                       &pMandRPB->pXResult);
  654. X        }
  655. X    break;
  656. X        
  657. X    case NANCY_RemoveMatch:
  658. X    for (pSite = matchSpec.pReplaceList;
  659. X         pSite && iErr == VEOS_SUCCESS;
  660. X         pSite = pSite->pNext) {
  661. X
  662. X#ifndef OPTIMAL
  663. X        if (NANCY_BUGS) 
  664. X        Native_ShowSite(pSite);
  665. X#endif
  666. X        iErr = Native_XRemoveSiteMatches(pSite, pMandRPB->pTestTime,
  667. X                         &pMandRPB->pXResult);
  668. X        }
  669. X    break;
  670. X
  671. X    case NANCY_ReplaceMatch:
  672. X    for (pSite = matchSpec.pReplaceList;
  673. X         pSite && iErr == VEOS_SUCCESS;
  674. X         pSite = pSite->pNext) {
  675. X
  676. X#ifndef OPTIMAL
  677. X        if (NANCY_BUGS) 
  678. X        Native_ShowSite(pSite);
  679. X#endif
  680. X        iErr = Native_XRemoveSiteMatches(pSite, pMandRPB->pTestTime,
  681. X                         &pMandRPB->pXResult);
  682. X        if (iErr == VEOS_SUCCESS)
  683. X        iErr = Native_XInsertEltAtSite(pMandRPB->pXReplaceElt,
  684. X                           pMandRPB->pStampTime, pSite);
  685. X        }
  686. X    break;
  687. X        
  688. X    case NANCY_GimmeMatch:
  689. X    iErr = NANCY_NotSupported;
  690. X    break;
  691. X        
  692. X    } /* switch */
  693. X            
  694. X
  695. X    /** perform destructive element time stamping
  696. X     **/
  697. X
  698. X    if (pMandRPB->pStampTime) {
  699. X
  700. X    for (pSite = matchSpec.pTouchList;
  701. X         pSite && iErr == VEOS_SUCCESS;
  702. X         pSite = pSite->pNext) {
  703. X#ifndef OPTIMAL        
  704. X        if (NANCY_BUGS) 
  705. X        Native_ShowSite(pSite);
  706. X#endif        
  707. X        Native_TouchSiteMatches(pSite, *pMandRPB->pStampTime);
  708. X        
  709. X        }
  710. X    }
  711. X
  712. X    /** free all matcher memory (stays within veos kernel) **/
  713. X
  714. X    pSite = matchSpec.pReplaceList;
  715. X    while (pSite) {
  716. X    pSave = pSite;
  717. X    pSite = pSite->pNext;
  718. X    Shell_ReturnBlock(pSave, sizeof(TReplaceRec), "replace-bp");
  719. X    }
  720. X
  721. X    pSite = matchSpec.pTouchList;
  722. X    while (pSite) {
  723. X    pSave = pSite;
  724. X    pSite = pSite->pNext;
  725. X    Shell_ReturnBlock(pSave, sizeof(TReplaceRec), "replace-bp");
  726. X    }
  727. X    
  728. X
  729. X    if (iErr == VEOS_SUCCESS) {
  730. X
  731. X    /** check for successful insert (give caller appropriate feeback) **/
  732. X
  733. X    if (pMandRPB->iDestroyFlag == NANCY_ReplaceMatch &&
  734. X        pMandRPB->pXResult == NIL)
  735. X
  736. X        pMandRPB->pXResult = true;
  737. X    }
  738. X
  739. X#ifndef OPTIMAL
  740. X    else {
  741. X    if (NANCY_BUGS)
  742. X        Nancy_TrapErr(iErr);
  743. X    }
  744. X#endif
  745. X
  746. X    return(iErr);
  747. X
  748. X    } /* Native_MatchAndReplace */
  749. X/****************************************************************************************/
  750. X
  751. X    
  752. X
  753. X/****************************************************************************************/
  754. XTVeosErr Native_XCopySiteMatches(pSite, pTestTime, hXResult)
  755. X    TPReplaceRec    pSite;
  756. X    TPTimeStamp        pTestTime;
  757. X    LVAL        *hXResult;
  758. X{
  759. X    int            iZone, iToKill, iElt, iLeft, iRight;
  760. X    LVAL        pXElt;
  761. X    TPElt        pVElt;
  762. X    TVeosErr        iErr;
  763. X
  764. X    xlsave1(pXElt);
  765. X
  766. X    /** convert outgoing data into supplanted language format.
  767. X     ** lisp is the current control language
  768. X     **/
  769. X    
  770. X    if (pTestTime == nil) {
  771. X    
  772. X    for (iZone = pSite->iZones - 1; iZone >= 0; iZone --) {
  773. X        iLeft = pSite->pWipeList[iZone].iLeft;
  774. X        iRight = pSite->pWipeList[iZone].iRight;
  775. X        iToKill = iRight - iLeft + 1;
  776. X
  777. X#ifndef OPTIMAL        
  778. X        if (NANCY_BUGS) {
  779. X        fprintf(stderr, "nancy %s: left: %d right: %d\n",
  780. X            WHOAMI, iLeft, iRight);
  781. X        }
  782. X#endif        
  783. X        for (iElt = iRight, pVElt = &pSite->pEnviron->pEltList[iRight];
  784. X         iElt >= iLeft;
  785. X         iElt--, pVElt --) {
  786. X
  787. X        if (Native_VEltToXElt(pVElt, &pXElt) == VEOS_SUCCESS)
  788. X            
  789. X            /** assume caller protected *hXResult **/
  790. X            *hXResult = cons(pXElt, *hXResult);
  791. X        }
  792. X        }
  793. X    }
  794. X    else {
  795. X
  796. X    for (iZone = pSite->iZones - 1; iZone >= 0; iZone --) {
  797. X        iLeft = pSite->pWipeList[iZone].iLeft;
  798. X        iRight = pSite->pWipeList[iZone].iRight;
  799. X        iToKill = iRight - iLeft + 1;
  800. X
  801. X#ifndef OPTIMAL
  802. X        if (NANCY_BUGS) {
  803. X        fprintf(stderr, "nancy %s: left: %d right: %d\n",
  804. X            WHOAMI, iLeft, iRight);
  805. X        }
  806. X#endif    
  807. X
  808. X        for (iElt = iRight, pVElt = &pSite->pEnviron->pEltList[iRight];
  809. X         iElt >= iLeft;
  810. X         iElt--, pVElt--) {
  811. X        
  812. X        iErr = Native_NewVEltToXElt(pVElt, &pXElt, *pTestTime);
  813. X        if (iErr == VEOS_SUCCESS) {
  814. X
  815. X            /** assume caller protected *hXResult **/
  816. X            *hXResult = cons(pXElt, *hXResult);
  817. X            }
  818. X        /*
  819. X        else if (iErr == NATIVE_STALE)
  820. X            iErr = VEOS_SUCCESS;
  821. X            */
  822. X        }
  823. X        }
  824. X    }
  825. X
  826. X    xlpop();
  827. X
  828. X    return(VEOS_SUCCESS);
  829. X
  830. X    } /* Native_XCopySiteMatches */
  831. X/****************************************************************************************/
  832. X
  833. X
  834. X
  835. X/****************************************************************************************/
  836. XTVeosErr Native_XRemoveSiteMatches(pSite, pTestTime, hXResult)
  837. X    TPReplaceRec    pSite;
  838. X    TPTimeStamp        pTestTime;
  839. X    LVAL        *hXResult;
  840. X{
  841. X    int            iZone, iToKill, iElt, iLeft, iRight;
  842. X    LVAL        pXElt;
  843. X    TPElt        pVElt;
  844. X
  845. X    xlsave1(pXElt);
  846. X
  847. X    for (iZone = pSite->iZones - 1; iZone >= 0; iZone --) {
  848. X    iLeft = pSite->pWipeList[iZone].iLeft;
  849. X    iRight = pSite->pWipeList[iZone].iRight;
  850. X    iToKill = iRight - iLeft + 1;
  851. X    
  852. X    /** convert outgoing data into supplanted language format.
  853. X     ** that format is xlisp, and in reverse order
  854. X     **/
  855. X    
  856. X    for (iElt = iRight, pVElt = &pSite->pEnviron->pEltList[iRight];
  857. X         iElt >= iLeft;
  858. X         iElt--, pVElt--) {
  859. X
  860. X        if (Native_VEltToXElt(pVElt, &pXElt) == VEOS_SUCCESS)
  861. X
  862. X        /** assume caller has protected *hXResult **/
  863. X
  864. X        *hXResult = cons(pXElt, *hXResult);
  865. X        }
  866. X    
  867. X    Nancy_DeleteElementsInGrouple(pSite->pEnviron,
  868. X                      iLeft,
  869. X                      iToKill);
  870. X    }
  871. X
  872. X    xlpop();
  873. X
  874. X    return(VEOS_SUCCESS);
  875. X
  876. X    } /* Native_XRemoveSiteMatches */
  877. X/****************************************************************************************/
  878. X
  879. X
  880. X
  881. X/****************************************************************************************/
  882. XTVeosErr Native_XInsertEltAtSite(pXReplaceElt, pStampTime, pSite)
  883. X    LVAL        pXReplaceElt;
  884. X    TPTimeStamp        pStampTime;
  885. X    TPReplaceRec    pSite;
  886. X{
  887. X    TElt        localElt;
  888. X    TVeosErr        iErr = VEOS_SUCCESS;
  889. X
  890. X    if (pSite->iInsertElt >= 0) {
  891. X    
  892. X    localElt = NIL_ELT;
  893. X
  894. X    if (pStampTime)
  895. X        iErr = Native_XEltToNewVElt(pXReplaceElt, &localElt, *pStampTime);
  896. X    else
  897. X        iErr = Native_XEltToVElt(pXReplaceElt, &localElt);
  898. X
  899. X    if (iErr == VEOS_SUCCESS) {
  900. X
  901. X        Nancy_NewElementsInGrouple(pSite->pEnviron, pSite->iInsertElt, 1,
  902. X                       GR_unspecified, 0);
  903. X        pSite->pEnviron->pEltList[pSite->iInsertElt] = localElt;
  904. X        }
  905. X    }
  906. X
  907. X    return(iErr);
  908. X    
  909. X    } /* Native_XInsertEltAtSite */
  910. X/****************************************************************************************/
  911. X
  912. X
  913. X
  914. X/****************************************************************************************/
  915. XTVeosErr Native_TouchSiteMatches(pSite, time)
  916. X    TPReplaceRec    pSite;
  917. X    TTimeStamp        time;
  918. X{
  919. X    int            iZone, iElt, iLeft, iRight;
  920. X    TPElt        pVElt;
  921. X
  922. X    for (iZone = pSite->iZones - 1; iZone >= 0; iZone --) {
  923. X
  924. X    iLeft = pSite->pWipeList[iZone].iLeft;
  925. X    iRight = pSite->pWipeList[iZone].iRight;
  926. X    
  927. X    /** simply update time stamp of given elements **/
  928. X    
  929. X    for (iElt = iRight, pVElt = &pSite->pEnviron->pEltList[iRight];
  930. X         iElt >= iLeft; 
  931. X         iElt--, pVElt--)
  932. X
  933. X        pVElt->tLastMod = time;
  934. X    }
  935. X
  936. X    return(VEOS_SUCCESS);
  937. X
  938. X    } /* Native_TouchSiteMatches */
  939. X/****************************************************************************************/
  940. X
  941. X
  942. X
  943. X/****************************************************************************************/
  944. XTVeosErr Native_MessageToLSpace(pMsgRec)
  945. X    TPMsgRec        pMsgRec;
  946. X{
  947. X    TVeosErr         iErr;
  948. X    LVAL        pXElt, *hFinger;
  949. X    int            iLen;
  950. X    char        *pBuf;
  951. X
  952. X
  953. X    xlsave1(pXElt);
  954. X
  955. X    /** return data to grouple form **/            
  956. X    
  957. X    pBuf = pMsgRec->sMessage;
  958. X    iLen = 0;
  959. X    iErr = Native_MessageToXElt(pBuf, &pXElt, &iLen);
  960. X    
  961. X#ifndef OPTIMAL    
  962. X    if (TALK_BUGS) {
  963. X    fprintf(stderr, "listen %s: results of message conversion, native: %d\n",
  964. X        WHOAMI, iErr);
  965. X    }    
  966. X#endif
  967. X    
  968. X    if (iErr == VEOS_SUCCESS) {
  969. X
  970. X#ifndef OPTIMAL    
  971. X    if (TALK_BUGS) {
  972. X        fprintf(stderr, "listen %s: element in message:\n", WHOAMI);
  973. X
  974. X        errprint(pXElt);
  975. X        }
  976. X#endif
  977. X
  978. X    /** append message to native inspace list **/
  979. X    
  980. X    hFinger = NATIVE_INSPACE;
  981. X    while (!null(*hFinger))
  982. X        hFinger = &cdr(*hFinger);
  983. X
  984. X    *hFinger = cons(pXElt, NIL);
  985. X    }
  986. X
  987. X    xlpop();
  988. X
  989. X    return(iErr);
  990. X
  991. X    } /* Native_MessageToLSpace */
  992. X/****************************************************************************************/
  993. X
  994. X
  995. X
  996. X/****************************************************************************************/
  997. Xvoid Native_ShowMatchArgs(pMandRPB)
  998. X    TPXMandRRec        pMandRPB;
  999. X{
  1000. X    fprintf(stderr, "nancy %s: MandR arguments.\n", WHOAMI);
  1001. X
  1002. X    fprintf(stderr, "nancy %s: source:\n", WHOAMI);
  1003. X    Nancy_GroupleToStream(pMandRPB->pSrcGr, stderr);
  1004. X
  1005. X    fprintf(stderr, "nancy %s: pattern:\n", WHOAMI);
  1006. X    Nancy_GroupleToStream(pMandRPB->pPatGr, stderr);
  1007. X    
  1008. X    fprintf(stderr, "nancy %s: destroyFlag: %s\n", WHOAMI,
  1009. X        pMandRPB->iDestroyFlag == NANCY_RemoveMatch ? "remove" :
  1010. X        pMandRPB->iDestroyFlag == NANCY_CopyMatch ? "copy" :
  1011. X        pMandRPB->iDestroyFlag == NANCY_ReplaceMatch ? "replace" : "unknown");
  1012. X    
  1013. X    fprintf(stderr, "nancy %s: freqFlag: %s\n", WHOAMI,
  1014. X        pMandRPB->iFreqFlag == NANCY_MatchOne ? "one" : "all");
  1015. X    
  1016. X    fprintf(stderr, "nancy %s: replace elt:\n", WHOAMI);
  1017. X    errprint(pMandRPB->pXReplaceElt);
  1018. X    
  1019. X    fprintf(stderr, "nancy %s: stamp-time: ", WHOAMI);
  1020. X    if (pMandRPB->pStampTime)
  1021. X    PRINT_TIME(*pMandRPB->pStampTime, stderr);
  1022. X    else
  1023. X    fprintf(stderr, "nil");
  1024. X    fprintf(stderr, "\n");
  1025. X
  1026. X    fprintf(stderr, "nancy %s: test-time: ", WHOAMI);
  1027. X    if (pMandRPB->pTestTime)
  1028. X    PRINT_TIME(*pMandRPB->pTestTime, stderr);
  1029. X    else
  1030. X    fprintf(stderr, "nil");
  1031. X    fprintf(stderr, "\n");
  1032. X
  1033. X    } 
  1034. X/****************************************************************************************/
  1035. X
  1036. X
  1037. X
  1038. X/****************************************************************************************/
  1039. Xvoid Native_ShowSite(pSite)
  1040. X    TPReplaceRec           pSite;
  1041. X{
  1042. X    fprintf(stderr, "nancy %s: site grouple:\n", WHOAMI);
  1043. X    Nancy_GroupleToStream(pSite->pEnviron, stderr);
  1044. X    fprintf(stderr, "nancy %s: site zones: %d\n", WHOAMI, pSite->iZones);
  1045. X    fprintf(stderr, "nancy %s: site insert elt: %d\n", WHOAMI, pSite->iInsertElt);
  1046. X    }
  1047. X/****************************************************************************************/
  1048. X
  1049. X
  1050. X
  1051. END_OF_FILE
  1052. if test 24300 -ne `wc -c <'src/kernel_current/shell/xv_native.c'`; then
  1053.     echo shar: \"'src/kernel_current/shell/xv_native.c'\" unpacked with wrong size!
  1054. fi
  1055. # end of 'src/kernel_current/shell/xv_native.c'
  1056. fi
  1057. if test -f 'src/xlisp/xcore/c/xleval.c' -a "${1}" != "-c" ; then 
  1058.   echo shar: Will not clobber existing file \"'src/xlisp/xcore/c/xleval.c'\"
  1059. else
  1060. echo shar: Extracting \"'src/xlisp/xcore/c/xleval.c'\" \(21287 characters\)
  1061. sed "s/^X//" >'src/xlisp/xcore/c/xleval.c' <<'END_OF_FILE'
  1062. X/* -*-C-*-
  1063. X********************************************************************************
  1064. X*
  1065. X* File:         xleval.c
  1066. X* RCS:          $Header: xleval.c,v 1.3 89/11/25 05:21:43 mayer Exp $
  1067. X* Description:  xlisp evaluator
  1068. X* Author:       David Michael Betz
  1069. X* Created:      
  1070. X* Modified:     Sat Nov 25 05:21:14 1989 (Niels Mayer) mayer@hplnpm
  1071. X* Language:     C
  1072. X* Package:      N/A
  1073. X* Status:       X11r4 contrib tape release
  1074. X*
  1075. X* WINTERP 1.0 Copyright 1989 Hewlett-Packard Company (by Niels Mayer).
  1076. X* XLISP version 2.1, Copyright (c) 1989, by David Betz.
  1077. X*
  1078. X* Permission to use, copy, modify, distribute, and sell this software and its
  1079. X* documentation for any purpose is hereby granted without fee, provided that
  1080. X* the above copyright notice appear in all copies and that both that
  1081. X* copyright notice and this permission notice appear in supporting
  1082. X* documentation, and that the name of Hewlett-Packard and David Betz not be
  1083. X* used in advertising or publicity pertaining to distribution of the software
  1084. X* without specific, written prior permission.  Hewlett-Packard and David Betz
  1085. X* make no representations about the suitability of this software for any
  1086. X* purpose. It is provided "as is" without express or implied warranty.
  1087. X*
  1088. X* HEWLETT-PACKARD AND DAVID BETZ DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
  1089. X* SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
  1090. X* IN NO EVENT SHALL HEWLETT-PACKARD NOR DAVID BETZ BE LIABLE FOR ANY SPECIAL,
  1091. X* INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  1092. X* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  1093. X* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  1094. X* PERFORMANCE OF THIS SOFTWARE.
  1095. X*
  1096. X* See ./winterp/COPYRIGHT for information on contacting the authors.
  1097. X* 
  1098. X* Please send modifications, improvements and bugfixes to mayer@hplabs.hp.com
  1099. X* Post XLISP-specific questions/information to the newsgroup comp.lang.lisp.x
  1100. X*
  1101. X********************************************************************************
  1102. X*/
  1103. Xstatic char rcs_identity[] = "@(#)$Header: xleval.c,v 1.3 89/11/25 05:21:43 mayer Exp $";
  1104. X
  1105. X#include "xlisp.h"
  1106. X
  1107. X/* macro to check for lambda list keywords */
  1108. X#define iskey(s) ((s) == lk_optional \
  1109. X               || (s) == lk_rest \
  1110. X               || (s) == lk_key \
  1111. X               || (s) == lk_aux \
  1112. X               || (s) == lk_allow_other_keys)
  1113. X
  1114. X/* macros to handle tracing */
  1115. X#define trenter(sym,argc,argv) {if (sym) doenter(sym,argc,argv);}
  1116. X#define trexit(sym,val) {if (sym) doexit(sym,val);}
  1117. X
  1118. X/* external variables */
  1119. Xextern LVAL xlenv,xlfenv,xldenv,xlvalue,true;
  1120. Xextern LVAL lk_optional,lk_rest,lk_key,lk_aux,lk_allow_other_keys;
  1121. Xextern LVAL s_evalhook,s_applyhook,s_tracelist;
  1122. Xextern LVAL s_lambda,s_macro;
  1123. Xextern LVAL s_unbound;
  1124. Xextern int xlsample;
  1125. Xextern char buf[];
  1126. X
  1127. X/* forward declarations */
  1128. XFORWARD LVAL xlxeval();
  1129. XFORWARD LVAL evalhook();
  1130. XFORWARD LVAL evform();
  1131. XFORWARD LVAL evfun();
  1132. X
  1133. Xint iEvals = 0;            /* Voodoo */
  1134. X
  1135. X/* xleval - evaluate an xlisp expression (checking for *evalhook*) */
  1136. XLVAL xleval(expr)
  1137. X  LVAL expr;
  1138. X{
  1139. X    /* check for control codes */
  1140. X    if (--xlsample <= 0) {
  1141. X    xlsample = SAMPLE;
  1142. X    oscheck();
  1143. X    }
  1144. X
  1145. X    iEvals ++;            /* Voodoo */
  1146. X
  1147. X    /* check for *evalhook* */
  1148. X    if (getvalue(s_evalhook))
  1149. X    return (evalhook(expr));
  1150. X
  1151. X    /* check for nil */
  1152. X    if (null(expr))
  1153. X    return (NIL);
  1154. X
  1155. X    /* dispatch on the node type */
  1156. X    switch (ntype(expr)) {
  1157. X    case CONS:
  1158. X    return (evform(expr));
  1159. X    case SYMBOL:
  1160. X    return (xlgetvalue(expr));
  1161. X    default:
  1162. X    return (expr);
  1163. X    }
  1164. X}
  1165. X
  1166. X#ifdef CURRENTLY_UNUSED
  1167. X/* xlevalenv - evaluate an expression in a specified environment */
  1168. XLVAL xlevalenv(expr,env,fenv)
  1169. X  LVAL expr,env,fenv;
  1170. X{
  1171. X    LVAL oldenv,oldfenv,val;
  1172. X
  1173. X    /* protect some pointers */
  1174. X    xlstkcheck(2);
  1175. X    xlsave(oldenv);
  1176. X    xlsave(oldfenv);
  1177. X
  1178. X    /* establish the new environment */
  1179. X    oldenv = xlenv;
  1180. X    oldfenv = xlfenv;
  1181. X    xlenv = env;
  1182. X    xlfenv = fenv;
  1183. X
  1184. X    /* evaluate the expression */
  1185. X    val = xleval(expr);
  1186. X
  1187. X    /* restore the environment */
  1188. X    xlenv = oldenv;
  1189. X    xlfenv = oldfenv;
  1190. X
  1191. X    /* restore the stack */
  1192. X    xlpopn(2);
  1193. X
  1194. X    /* return the result value */
  1195. X    return (val);
  1196. X}
  1197. X#endif
  1198. X
  1199. X/* xlxeval - evaluate an xlisp expression (bypassing *evalhook*) */
  1200. XLVAL xlxeval(expr)
  1201. X  LVAL expr;
  1202. X{
  1203. X    /* check for nil */
  1204. X    if (null(expr))
  1205. X    return (NIL);
  1206. X
  1207. X    /* dispatch on node type */
  1208. X    switch (ntype(expr)) {
  1209. X    case CONS:
  1210. X    return (evform(expr));
  1211. X    case SYMBOL:
  1212. X    return (xlgetvalue(expr));
  1213. X    default:
  1214. X    return (expr);
  1215. X    }
  1216. X}
  1217. X
  1218. X/* xlapply - apply a function to arguments (already on the stack) */
  1219. XLVAL xlapply(argc)
  1220. X  int argc;
  1221. X{
  1222. X    LVAL *oldargv,fun,val;
  1223. X    int oldargc;
  1224. X    
  1225. X    /* get the function */
  1226. X    fun = xlfp[1];
  1227. X
  1228. X    /* get the functional value of symbols */
  1229. X    if (symbolp(fun)) {
  1230. X    while ((val = getfunction(fun)) == s_unbound)
  1231. X        xlfunbound(fun);
  1232. X    fun = xlfp[1] = val;
  1233. X    }
  1234. X
  1235. X    /* check for nil */
  1236. X    if (null(fun))
  1237. X    xlerror("bad function",fun);
  1238. X
  1239. X    /* dispatch on node type */
  1240. X    switch (ntype(fun)) {
  1241. X    case SUBR:
  1242. X    oldargc = xlargc;
  1243. X    oldargv = xlargv;
  1244. X    xlargc = argc;
  1245. X    xlargv = xlfp + 3;
  1246. X    val = (*getsubr(fun))();
  1247. X    xlargc = oldargc;
  1248. X    xlargv = oldargv;
  1249. X    break;
  1250. X    case CONS:
  1251. X    if (!consp(cdr(fun)))
  1252. X        xlerror("bad function",fun);
  1253. X    if (car(fun) == s_lambda)
  1254. X        fun = xlclose(NIL,
  1255. X                      s_lambda,
  1256. X                      car(cdr(fun)),
  1257. X                      cdr(cdr(fun)),
  1258. X                      xlenv,xlfenv);
  1259. X    else
  1260. X        xlerror("bad function",fun);
  1261. X    /**** fall through into the next case ****/
  1262. X    case CLOSURE:
  1263. X    if (gettype(fun) != s_lambda)
  1264. X        xlerror("bad function",fun);
  1265. X    val = evfun(fun,argc,xlfp+3);
  1266. X    break;
  1267. X    default:
  1268. X    xlerror("bad function",fun);
  1269. X    }
  1270. X
  1271. X    /* remove the call frame */
  1272. X    xlsp = xlfp;
  1273. X    xlfp = xlfp - (int)getfixnum(*xlfp);
  1274. X
  1275. X    /* return the function value */
  1276. X    return (val);
  1277. X}
  1278. X
  1279. X/* evform - evaluate a form */
  1280. XLOCAL LVAL evform(form)
  1281. X  LVAL form;
  1282. X{
  1283. X    LVAL fun,args,val,type;
  1284. X    LVAL tracing=NIL;
  1285. X    LVAL *argv;
  1286. X    int argc;
  1287. X
  1288. X    /* protect some pointers */
  1289. X    xlstkcheck(2);
  1290. X    xlsave(fun);
  1291. X    xlsave(args);
  1292. X
  1293. X    /* get the function and the argument list */
  1294. X    fun = car(form);
  1295. X    args = cdr(form);
  1296. X
  1297. X    /* get the functional value of symbols */
  1298. X    if (symbolp(fun)) {
  1299. X    if (getvalue(s_tracelist) && member(fun,getvalue(s_tracelist)))
  1300. X        tracing = fun;
  1301. X    fun = xlgetfunction(fun);
  1302. X    }
  1303. X
  1304. X    /* check for nil */
  1305. X    if (null(fun))
  1306. X    xlerror("bad function",NIL);
  1307. X
  1308. X    /* dispatch on node type */
  1309. X    switch (ntype(fun)) {
  1310. X    case SUBR:
  1311. X    argv = xlargv;
  1312. X    argc = xlargc;
  1313. X    xlargc = evpushargs(fun,args);
  1314. X    xlargv = xlfp + 3;
  1315. X    trenter(tracing,xlargc,xlargv);
  1316. X    val = (*getsubr(fun))();
  1317. X    trexit(tracing,val);
  1318. X    xlsp = xlfp;
  1319. X    xlfp = xlfp - (int)getfixnum(*xlfp);
  1320. X    xlargv = argv;
  1321. X    xlargc = argc;
  1322. X    break;
  1323. X    case FSUBR:
  1324. X    argv = xlargv;
  1325. X    argc = xlargc;
  1326. X    xlargc = pushargs(fun,args);
  1327. X    xlargv = xlfp + 3;
  1328. X    val = (*getsubr(fun))();
  1329. X    xlsp = xlfp;
  1330. X    xlfp = xlfp - (int)getfixnum(*xlfp);
  1331. X    xlargv = argv;
  1332. X    xlargc = argc;
  1333. X    break;
  1334. X    case CONS:
  1335. X    if (!consp(cdr(fun)))
  1336. X        xlerror("bad function",fun);
  1337. X    if ((type = car(fun)) == s_lambda)
  1338. X         fun = xlclose(NIL,
  1339. X                       s_lambda,
  1340. X                       car(cdr(fun)),
  1341. X                       cdr(cdr(fun)),
  1342. X                       xlenv,xlfenv);
  1343. X    else
  1344. X        xlerror("bad function",fun);
  1345. X    /**** fall through into the next case ****/
  1346. X    case CLOSURE:
  1347. X    if (gettype(fun) == s_lambda) {
  1348. X        argc = evpushargs(fun,args);
  1349. X        argv = xlfp + 3;
  1350. X        trenter(tracing,argc,argv);
  1351. X        val = evfun(fun,argc,argv);
  1352. X        trexit(tracing,val);
  1353. X        xlsp = xlfp;
  1354. X        xlfp = xlfp - (int)getfixnum(*xlfp);
  1355. X    }
  1356. X    else {
  1357. X        macroexpand(fun,args,&fun);
  1358. X        val = xleval(fun);
  1359. X    }
  1360. X    break;
  1361. X    default:
  1362. X    xlerror("bad function",fun);
  1363. X    }
  1364. X
  1365. X    /* restore the stack */
  1366. X    xlpopn(2);
  1367. X
  1368. X    /* return the result value */
  1369. X    return (val);
  1370. X}
  1371. X
  1372. X/* xlexpandmacros - expand macros in a form */
  1373. XLVAL xlexpandmacros(form)
  1374. X  LVAL form;
  1375. X{
  1376. X    LVAL fun,args;
  1377. X    
  1378. X    /* protect some pointers */
  1379. X    xlstkcheck(3);
  1380. X    xlprotect(form);
  1381. X    xlsave(fun);
  1382. X    xlsave(args);
  1383. X
  1384. X    /* expand until the form isn't a macro call */
  1385. X    while (consp(form)) {
  1386. X    fun = car(form);        /* get the macro name */
  1387. X    args = cdr(form);        /* get the arguments */
  1388. X    if (!symbolp(fun) || !fboundp(fun))
  1389. X        break;
  1390. X    fun = xlgetfunction(fun);    /* get the expansion function */
  1391. X    if (!macroexpand(fun,args,&form))
  1392. X        break;
  1393. X    }
  1394. X
  1395. X    /* restore the stack and return the expansion */
  1396. X    xlpopn(3);
  1397. X    return (form);
  1398. X}
  1399. X
  1400. X/* macroexpand - expand a macro call */
  1401. Xint macroexpand(fun,args,pval)
  1402. X  LVAL fun,args,*pval;
  1403. X{
  1404. X    LVAL *argv;
  1405. X    int argc;
  1406. X    
  1407. X    /* make sure it's really a macro call */
  1408. X    if (!closurep(fun) || gettype(fun) != s_macro)
  1409. X    return (FALSE);
  1410. X    
  1411. X    /* call the expansion function */
  1412. X    argc = pushargs(fun,args);
  1413. X    argv = xlfp + 3;
  1414. X    *pval = evfun(fun,argc,argv);
  1415. X    xlsp = xlfp;
  1416. X    xlfp = xlfp - (int)getfixnum(*xlfp);
  1417. X    return (TRUE);
  1418. X}
  1419. X
  1420. X/* evalhook - call the evalhook function */
  1421. XLOCAL LVAL evalhook(expr)
  1422. X  LVAL expr;
  1423. X{
  1424. X    LVAL *newfp,olddenv,val;
  1425. X
  1426. X    /* create the new call frame */
  1427. X    newfp = xlsp;
  1428. X    pusharg(cvfixnum((FIXTYPE)(newfp - xlfp)));
  1429. X    pusharg(getvalue(s_evalhook));
  1430. X    pusharg(cvfixnum((FIXTYPE)2));
  1431. X    pusharg(expr);
  1432. X    pusharg(cons(xlenv,xlfenv));
  1433. X    xlfp = newfp;
  1434. X
  1435. X    /* rebind the hook functions to nil */
  1436. X    olddenv = xldenv;
  1437. X    xldbind(s_evalhook,NIL);
  1438. X    xldbind(s_applyhook,NIL);
  1439. X
  1440. X    /* call the hook function */
  1441. X    val = xlapply(2);
  1442. X
  1443. X    /* unbind the symbols */
  1444. X    xlunbind(olddenv);
  1445. X
  1446. X    /* return the value */
  1447. X    return (val);
  1448. X}
  1449. X
  1450. X/* evpushargs - evaluate and push a list of arguments */
  1451. XLOCAL int evpushargs(fun,args)
  1452. X  LVAL fun,args;
  1453. X{
  1454. X    LVAL *newfp;
  1455. X    int argc;
  1456. X    
  1457. X    /* protect the argument list */
  1458. X    xlprot1(args);
  1459. X
  1460. X    /* build a new argument stack frame */
  1461. X    newfp = xlsp;
  1462. X    pusharg(cvfixnum((FIXTYPE)(newfp - xlfp)));
  1463. X    pusharg(fun);
  1464. X    pusharg(NIL); /* will be argc */
  1465. X
  1466. X    /* evaluate and push each argument */
  1467. X    for (argc = 0; consp(args); args = cdr(args), ++argc)
  1468. X    pusharg(xleval(car(args)));
  1469. X
  1470. X    /* establish the new stack frame */
  1471. X    newfp[2] = cvfixnum((FIXTYPE)argc);
  1472. X    xlfp = newfp;
  1473. X    
  1474. X    /* restore the stack */
  1475. X    xlpop();
  1476. X
  1477. X    /* return the number of arguments */
  1478. X    return (argc);
  1479. X}
  1480. X
  1481. X/* pushargs - push a list of arguments */
  1482. Xint pushargs(fun,args)
  1483. X  LVAL fun,args;
  1484. X{
  1485. X    LVAL *newfp;
  1486. X    int argc;
  1487. X    
  1488. X    /* build a new argument stack frame */
  1489. X    newfp = xlsp;
  1490. X    pusharg(cvfixnum((FIXTYPE)(newfp - xlfp)));
  1491. X    pusharg(fun);
  1492. X    pusharg(NIL); /* will be argc */
  1493. X
  1494. X    /* push each argument */
  1495. X    for (argc = 0; consp(args); args = cdr(args), ++argc)
  1496. X    pusharg(car(args));
  1497. X
  1498. X    /* establish the new stack frame */
  1499. X    newfp[2] = cvfixnum((FIXTYPE)argc);
  1500. X    xlfp = newfp;
  1501. X
  1502. X    /* return the number of arguments */
  1503. X    return (argc);
  1504. X}
  1505. X
  1506. X/* makearglist - make a list of the remaining arguments */
  1507. XLVAL makearglist(argc,argv)
  1508. X  int argc; LVAL *argv;
  1509. X{
  1510. X    LVAL list,this,last;
  1511. X    xlsave1(list);
  1512. X    for (last = NIL; --argc >= 0; last = this) {
  1513. X    this = cons(*argv++,NIL);
  1514. X    if (last) rplacd(last,this);
  1515. X    else list = this;
  1516. X    }
  1517. X    xlpop();
  1518. X    return (list);
  1519. X}
  1520. X
  1521. X/* evfun - evaluate a function */
  1522. XLOCAL LVAL evfun(fun,argc,argv)
  1523. X  LVAL fun; int argc; LVAL *argv;
  1524. X{
  1525. X    LVAL oldenv,oldfenv,cptr,name,val;
  1526. X    CONTEXT cntxt;
  1527. X
  1528. X    /* protect some pointers */
  1529. X    xlstkcheck(3);
  1530. X    xlsave(oldenv);
  1531. X    xlsave(oldfenv);
  1532. X    xlsave(cptr);
  1533. X
  1534. X    /* create a new environment frame */
  1535. X    oldenv = xlenv;
  1536. X    oldfenv = xlfenv;
  1537. X    xlenv = xlframe(xlgetenv(fun));
  1538. X    xlfenv = getfenv(fun);
  1539. X
  1540. X    /* bind the formal parameters */
  1541. X    xlabind(fun,argc,argv);
  1542. X
  1543. X    /* setup the implicit block */
  1544. X    if (name = getname(fun))
  1545. X    xlbegin(&cntxt,CF_RETURN,name);
  1546. X
  1547. X    /* execute the block */
  1548. X    if (name && xlsetjmp(cntxt.c_jmpbuf))
  1549. X    val = xlvalue;
  1550. X    else
  1551. X    for (val = NIL, cptr = getbody(fun); consp(cptr); cptr = cdr(cptr))
  1552. X        val = xleval(car(cptr));
  1553. X
  1554. X    /* finish the block context */
  1555. X    if (name)
  1556. X    xlend(&cntxt);
  1557. X
  1558. X    /* restore the environment */
  1559. X    xlenv = oldenv;
  1560. X    xlfenv = oldfenv;
  1561. X
  1562. X    /* restore the stack */
  1563. X    xlpopn(3);
  1564. X
  1565. X    /* return the result value */
  1566. X    return (val);
  1567. X}
  1568. X
  1569. X/* xlclose - create a function closure */
  1570. XLVAL xlclose(name,type,fargs,body,env,fenv)
  1571. X  LVAL name,type,fargs,body,env,fenv;
  1572. X{
  1573. X    LVAL closure,key,arg,def,svar,new,last;
  1574. X    char keyname[STRMAX+2];
  1575. X
  1576. X    /* protect some pointers */
  1577. X    xlsave1(closure);
  1578. X
  1579. X    /* create the closure object */
  1580. X    closure = newclosure(name,type,env,fenv);
  1581. X    setlambda(closure,fargs);
  1582. X    setbody(closure,body);
  1583. X
  1584. X    /* handle each required argument */
  1585. X    last = NIL;
  1586. X    while (consp(fargs) && (arg = car(fargs)) && !iskey(arg)) {
  1587. X
  1588. X    /* make sure the argument is a symbol */
  1589. X    if (!symbolp(arg))
  1590. X        badarglist();
  1591. X
  1592. X    /* create a new argument list entry */
  1593. X    new = cons(arg,NIL);
  1594. X
  1595. X    /* link it into the required argument list */
  1596. X    if (last)
  1597. X        rplacd(last,new);
  1598. X    else
  1599. X        setargs(closure,new);
  1600. X    last = new;
  1601. X
  1602. X    /* move the formal argument list pointer ahead */
  1603. X    fargs = cdr(fargs);
  1604. X    }
  1605. X
  1606. X    /* check for the '&optional' keyword */
  1607. X    if (consp(fargs) && car(fargs) == lk_optional) {
  1608. X    fargs = cdr(fargs);
  1609. X
  1610. X    /* handle each optional argument */
  1611. X    last = NIL;
  1612. X    while (consp(fargs) && (arg = car(fargs)) && !iskey(arg)) {
  1613. X
  1614. X        /* get the default expression and specified-p variable */
  1615. X        def = svar = NIL;
  1616. X        if (consp(arg)) {
  1617. X        if (def = cdr(arg))
  1618. X            if (consp(def)) {
  1619. X            if (svar = cdr(def))
  1620. X                if (consp(svar)) {
  1621. X                svar = car(svar);
  1622. X                if (!symbolp(svar))
  1623. X                    badarglist();
  1624. X                }
  1625. X                else
  1626. X                badarglist();
  1627. X            def = car(def);
  1628. X            }
  1629. X            else
  1630. X            badarglist();
  1631. X        arg = car(arg);
  1632. X        }
  1633. X
  1634. X        /* make sure the argument is a symbol */
  1635. X        if (!symbolp(arg))
  1636. X        badarglist();
  1637. X
  1638. X        /* create a fully expanded optional expression */
  1639. X        new = cons(cons(arg,cons(def,cons(svar,NIL))),NIL);
  1640. X
  1641. X        /* link it into the optional argument list */
  1642. X        if (last)
  1643. X        rplacd(last,new);
  1644. X        else
  1645. X        setoargs(closure,new);
  1646. X        last = new;
  1647. X        
  1648. X        /* move the formal argument list pointer ahead */
  1649. X        fargs = cdr(fargs);
  1650. X    }
  1651. X    }
  1652. X
  1653. X    /* check for the '&rest' keyword */
  1654. X    if (consp(fargs) && car(fargs) == lk_rest) {
  1655. X    fargs = cdr(fargs);
  1656. X
  1657. X    /* get the &rest argument */
  1658. X    if (consp(fargs) && (arg = car(fargs)) && !iskey(arg) && symbolp(arg))
  1659. X        setrest(closure,arg);
  1660. X    else
  1661. X        badarglist();
  1662. X
  1663. X    /* move the formal argument list pointer ahead */
  1664. X    fargs = cdr(fargs);
  1665. X    }
  1666. X
  1667. X    /* check for the '&key' keyword */
  1668. X    if (consp(fargs) && car(fargs) == lk_key) {
  1669. X    fargs = cdr(fargs);
  1670. X
  1671. X     /* handle each key argument */
  1672. X    last = NIL;
  1673. X    while (consp(fargs) && (arg = car(fargs)) && !iskey(arg)) {
  1674. X
  1675. X        /* get the default expression and specified-p variable */
  1676. X        def = svar = NIL;
  1677. X        if (consp(arg)) {
  1678. X        if (def = cdr(arg))
  1679. X            if (consp(def)) {
  1680. X            if (svar = cdr(def))
  1681. X                if (consp(svar)) {
  1682. X                svar = car(svar);
  1683. X                if (!symbolp(svar))
  1684. X                    badarglist();
  1685. X                }
  1686. X                else
  1687. X                badarglist();
  1688. X            def = car(def);
  1689. X            }
  1690. X            else
  1691. X            badarglist();
  1692. X        arg = car(arg);
  1693. X        }
  1694. X
  1695. X        /* get the keyword and the variable */
  1696. X        if (consp(arg)) {
  1697. X        key = car(arg);
  1698. X        if (!symbolp(key))
  1699. X            badarglist();
  1700. X        if (arg = cdr(arg))
  1701. X            if (consp(arg))
  1702. X            arg = car(arg);
  1703. X            else
  1704. X            badarglist();
  1705. X        }
  1706. X        else if (symbolp(arg)) {
  1707. X        strcpy(keyname,":");
  1708. X        strcat(keyname,getstring(getpname(arg)));
  1709. X        key = xlenter(keyname);
  1710. X        }
  1711. X
  1712. X        /* make sure the argument is a symbol */
  1713. X        if (!symbolp(arg))
  1714. X        badarglist();
  1715. X
  1716. X        /* create a fully expanded key expression */
  1717. X        new = cons(cons(key,cons(arg,cons(def,cons(svar,NIL)))),NIL);
  1718. X
  1719. X        /* link it into the optional argument list */
  1720. X        if (last)
  1721. X        rplacd(last,new);
  1722. X        else
  1723. X        setkargs(closure,new);
  1724. X        last = new;
  1725. X
  1726. X        /* move the formal argument list pointer ahead */
  1727. X        fargs = cdr(fargs);
  1728. X    }
  1729. X    }
  1730. X
  1731. X    /* check for the '&allow-other-keys' keyword */
  1732. X    if (consp(fargs) && car(fargs) == lk_allow_other_keys)
  1733. X    fargs = cdr(fargs);    /* this is the default anyway */
  1734. X
  1735. X    /* check for the '&aux' keyword */
  1736. X    if (consp(fargs) && car(fargs) == lk_aux) {
  1737. X    fargs = cdr(fargs);
  1738. X
  1739. X    /* handle each aux argument */
  1740. X    last = NIL;
  1741. X    while (consp(fargs) && (arg = car(fargs)) && !iskey(arg)) {
  1742. X
  1743. X        /* get the initial value */
  1744. X        def = NIL;
  1745. X        if (consp(arg)) {
  1746. X        if (def = cdr(arg))
  1747. X            if (consp(def))
  1748. X            def = car(def);
  1749. X            else
  1750. X            badarglist();
  1751. X        arg = car(arg);
  1752. X        }
  1753. X
  1754. X        /* make sure the argument is a symbol */
  1755. X        if (!symbolp(arg))
  1756. X        badarglist();
  1757. X
  1758. X        /* create a fully expanded aux expression */
  1759. X        new = cons(cons(arg,cons(def,NIL)),NIL);
  1760. X
  1761. X        /* link it into the aux argument list */
  1762. X        if (last)
  1763. X        rplacd(last,new);
  1764. X        else
  1765. X        setaargs(closure,new);
  1766. X        last = new;
  1767. X
  1768. X        /* move the formal argument list pointer ahead */
  1769. X        fargs = cdr(fargs);
  1770. X    }
  1771. X    }
  1772. X
  1773. X    /* make sure this is the end of the formal argument list */
  1774. X    if (fargs)
  1775. X    badarglist();
  1776. X
  1777. X    /* restore the stack */
  1778. X    xlpop();
  1779. X
  1780. X    /* return the new closure */
  1781. X    return (closure);
  1782. X}
  1783. X
  1784. X/* xlabind - bind the arguments for a function */
  1785. Xxlabind(fun,argc,argv)
  1786. X  LVAL fun; int argc; LVAL *argv;
  1787. X{
  1788. X    LVAL *kargv,fargs,key,arg,def,svar,p;
  1789. X    int rargc,kargc;
  1790. X    
  1791. X    /* protect some pointers */
  1792. X    xlsave1(def);
  1793. X
  1794. X    /* bind each required argument */
  1795. X    for (fargs = getargs(fun); fargs; fargs = cdr(fargs)) {
  1796. X
  1797. X    /* make sure there is an actual argument */
  1798. X    if (--argc < 0)
  1799. X        xlfail("too few arguments");
  1800. X
  1801. X    /* bind the formal variable to the argument value */
  1802. X    xlbind(car(fargs),*argv++);
  1803. X    }
  1804. X
  1805. X    /* bind each optional argument */
  1806. X    for (fargs = getoargs(fun); fargs; fargs = cdr(fargs)) {
  1807. X
  1808. X    /* get argument, default and specified-p variable */
  1809. X    p = car(fargs);
  1810. X    arg = car(p); p = cdr(p);
  1811. X    def = car(p); p = cdr(p);
  1812. X    svar = car(p);
  1813. X
  1814. X    /* bind the formal variable to the argument value */
  1815. X    if (--argc >= 0) {
  1816. X        xlbind(arg,*argv++);
  1817. X        if (svar) xlbind(svar,true);
  1818. X    }
  1819. X
  1820. X    /* bind the formal variable to the default value */
  1821. X    else {
  1822. X        if (def) def = xleval(def);
  1823. X        xlbind(arg,def);
  1824. X        if (svar) xlbind(svar,NIL);
  1825. X    }
  1826. X    }
  1827. X
  1828. X    /* save the count of the &rest of the argument list */
  1829. X    rargc = argc;
  1830. X    
  1831. X    /* handle '&rest' argument */
  1832. X    if (arg = getrest(fun)) {
  1833. X    def = makearglist(argc,argv);
  1834. X    xlbind(arg,def);
  1835. X    argc = 0;
  1836. X    }
  1837. X
  1838. X    /* handle '&key' arguments */
  1839. X    if (fargs = getkargs(fun)) {
  1840. X    for (; fargs; fargs = cdr(fargs)) {
  1841. X
  1842. X        /* get keyword, argument, default and specified-p variable */
  1843. X        p = car(fargs);
  1844. X        key = car(p); p = cdr(p);
  1845. X        arg = car(p); p = cdr(p);
  1846. X        def = car(p); p = cdr(p);
  1847. X        svar = car(p);
  1848. X
  1849. X        /* look for the keyword in the actual argument list */
  1850. X        for (kargv = argv, kargc = rargc; (kargc -= 2) >= 0; kargv += 2)
  1851. X        if (*kargv == key)
  1852. X            break;
  1853. X
  1854. X        /* bind the formal variable to the argument value */
  1855. X        if (kargc >= 0) {
  1856. X        xlbind(arg,*++kargv);
  1857. X        if (svar) xlbind(svar,true);
  1858. X        }
  1859. X
  1860. X        /* bind the formal variable to the default value */
  1861. X        else {
  1862. X        if (def) def = xleval(def);
  1863. X        xlbind(arg,def);
  1864. X        if (svar) xlbind(svar,NIL);
  1865. X        }
  1866. X    }
  1867. X    argc = 0;
  1868. X    }
  1869. X
  1870. X    /* check for the '&aux' keyword */
  1871. X    for (fargs = getaargs(fun); fargs; fargs = cdr(fargs)) {
  1872. X
  1873. X    /* get argument and default */
  1874. X    p = car(fargs);
  1875. X    arg = car(p); p = cdr(p);
  1876. X    def = car(p);
  1877. X
  1878. X    /* bind the auxiliary variable to the initial value */
  1879. X    if (def) def = xleval(def);
  1880. X    xlbind(arg,def);
  1881. X    }
  1882. X
  1883. X    /* make sure there aren't too many arguments */
  1884. X    if (argc > 0)
  1885. X    xlfail("too many arguments");
  1886. X
  1887. X    /* restore the stack */
  1888. X    xlpop();
  1889. X}
  1890. X
  1891. X/* doenter - print trace information on function entry */
  1892. XLOCAL doenter(sym,argc,argv)
  1893. X  LVAL sym; int argc; LVAL *argv;
  1894. X{
  1895. X    extern int xltrcindent;
  1896. X    int i;
  1897. X    
  1898. X    /* indent to the current trace level */
  1899. X    for (i = 0; i < xltrcindent; ++i)
  1900. X    trcputstr(" ");
  1901. X    ++xltrcindent;
  1902. X
  1903. X    /* display the function call */
  1904. X    sprintf(buf,"Entering: %s, Argument list: (",getstring(getpname(sym)));
  1905. X    trcputstr(buf);
  1906. X    while (--argc >= 0) {
  1907. X    trcprin1(*argv++);
  1908. X    if (argc) trcputstr(" ");
  1909. X    }
  1910. X    trcputstr(")\n");
  1911. X}
  1912. X
  1913. X/* doexit - print trace information for function/macro exit */
  1914. XLOCAL doexit(sym,val)
  1915. X  LVAL sym,val;
  1916. X{
  1917. X    extern int xltrcindent;
  1918. X    int i;
  1919. X    
  1920. X    /* indent to the current trace level */
  1921. X    --xltrcindent;
  1922. X    for (i = 0; i < xltrcindent; ++i)
  1923. X    trcputstr(" ");
  1924. X    
  1925. X    /* display the function value */
  1926. X    sprintf(buf,"Exiting: %s, Value: ",getstring(getpname(sym)));
  1927. X    trcputstr(buf);
  1928. X    trcprin1(val);
  1929. X    trcputstr("\n");
  1930. X}
  1931. X
  1932. X/* member - is 'x' a member of 'list'? */
  1933. XLOCAL int member(x,list)
  1934. X  LVAL x,list;
  1935. X{
  1936. X    for (; consp(list); list = cdr(list))
  1937. X    if (x == car(list))
  1938. X        return (TRUE);
  1939. X    return (FALSE);
  1940. X}
  1941. X
  1942. X/* xlunbound - signal an unbound variable error */
  1943. Xxlunbound(sym)
  1944. X  LVAL sym;
  1945. X{
  1946. X    xlcerror("try evaluating symbol again","unbound variable",sym);
  1947. X}
  1948. X
  1949. X/* xlfunbound - signal an unbound function error */
  1950. Xxlfunbound(sym)
  1951. X  LVAL sym;
  1952. X{
  1953. X    xlcerror("try evaluating symbol again","unbound function",sym);
  1954. X}
  1955. X
  1956. X/* xlstkoverflow - signal a stack overflow error */
  1957. Xxlstkoverflow()
  1958. X{
  1959. X    xlabort("evaluation stack overflow");
  1960. X}
  1961. X
  1962. X/* xlargstkoverflow - signal an argument stack overflow error */
  1963. Xxlargstkoverflow()
  1964. X{
  1965. X    xlabort("argument stack overflow");
  1966. X}
  1967. X
  1968. X/* badarglist - report a bad argument list error */
  1969. XLOCAL badarglist()
  1970. X{
  1971. X    xlfail("bad formal argument list");
  1972. X}
  1973. END_OF_FILE
  1974. if test 21287 -ne `wc -c <'src/xlisp/xcore/c/xleval.c'`; then
  1975.     echo shar: \"'src/xlisp/xcore/c/xleval.c'\" unpacked with wrong size!
  1976. fi
  1977. # end of 'src/xlisp/xcore/c/xleval.c'
  1978. fi
  1979. if test -f 'src/xlisp/xcore/c/xlftab.c' -a "${1}" != "-c" ; then 
  1980.   echo shar: Will not clobber existing file \"'src/xlisp/xcore/c/xlftab.c'\"
  1981. else
  1982. echo shar: Extracting \"'src/xlisp/xcore/c/xlftab.c'\" \(22885 characters\)
  1983. sed "s/^X//" >'src/xlisp/xcore/c/xlftab.c' <<'END_OF_FILE'
  1984. X/* xlftab.c - xlisp function table */
  1985. X/*    Copyright (c) 1985, by David Michael Betz */
  1986. X
  1987. X#include "xlisp.h"
  1988. X
  1989. X/* external functions */
  1990. Xextern LVAL
  1991. X    rmhash(),rmquote(),rmdquote(),rmbquote(),rmcomma(),
  1992. X    clnew(),clisnew(),clanswer(),
  1993. X    obisnew(),obclass(),obshow(),
  1994. X    rmlpar(),rmrpar(),rmsemi(),
  1995. X    xeval(),xapply(),xfuncall(),xquote(),xfunction(),xbquote(),
  1996. X    xlambda(),xset(),xsetq(),xsetf(),xdefun(),xdefmacro(),
  1997. X    xgensym(),xmakesymbol(),xintern(),
  1998. X    xsymname(),xsymvalue(),xsymplist(),
  1999. X    xget(),xputprop(),xremprop(),
  2000. X    xhash(),xmkarray(),xaref(),
  2001. X    xcar(),xcdr(),
  2002. X    xcaar(),xcadr(),xcdar(),xcddr(),
  2003. X    xcaaar(),xcaadr(),xcadar(),xcaddr(),
  2004. X    xcdaar(),xcdadr(),xcddar(),xcdddr(),
  2005. X    xcaaaar(),xcaaadr(),xcaadar(),xcaaddr(),
  2006. X    xcadaar(),xcadadr(),xcaddar(),xcadddr(),
  2007. X    xcdaaar(),xcdaadr(),xcdadar(),xcdaddr(),
  2008. X    xcddaar(),xcddadr(),xcdddar(),xcddddr(),
  2009. X    xcons(),xlist(),xappend(),xreverse(),xlast(),xnth(),xnthcdr(),
  2010. X    xmember(),xassoc(),xsubst(),xsublis(),xlength(),xsort(),
  2011. X    xremove(),xremif(),xremifnot(),
  2012. X    xmapc(),xmapcar(),xmapl(),xmaplist(),
  2013. X    xrplca(),xrplcd(),xnconc(),
  2014. X    xdelete(),xdelif(),xdelifnot(),
  2015. X    xatom(),xsymbolp(),xnumberp(),xboundp(),xnull(),xlistp(),xendp(),xconsp(),
  2016. X    xeq(),xeql(),xequal(),
  2017. X    xcond(),xcase(),xand(),xor(),xlet(),xletstar(),xif(),
  2018. X    xprog(),xprogstar(),xprog1(),xprog2(),xprogn(),xgo(),xreturn(),
  2019. X    xcatch(),xthrow(),
  2020. X    xerror(),xcerror(),xbreak(),
  2021. X    xcleanup(),xtoplevel(),xcontinue(),xerrset(),
  2022. X    xbaktrace(),xevalhook(),
  2023. X    xdo(),xdostar(),xdolist(),xdotimes(),
  2024. X    xminusp(),xzerop(),xplusp(),xevenp(),xoddp(),
  2025. X    xfix(),xfloat(),
  2026. X    xgcd(),xadd(),xsub(),xmul(),xdiv(),xrem(),xmin(),xmax(),xabs(),
  2027. X    xadd1(),xsub1(),xlogand(),xlogior(),xlogxor(),xlognot(),
  2028. X    xsin(),xcos(),xtan(),xexpt(),xexp(),xsqrt(),xrand(),
  2029. X    xlss(),xleq(),xequ(),xneq(),xgeq(),xgtr(),
  2030. X    xstrcat(),xsubseq(),xstring(),xchar(),
  2031. X    xread(),xprint(),xprin1(),xprinc(),xterpri(),
  2032. X    xflatsize(),xflatc(),
  2033. X    xopen(),xclose(),xrdchar(),xpkchar(),xwrchar(),xreadline(),
  2034. X    xload(),xtranscript(),
  2035. X    xtype(),xexit(),xpeek(),xpoke(),xaddrs(),
  2036. X    xvector(),xblock(),xrtnfrom(),xtagbody(),
  2037. X    xpsetq(),xflet(),xlabels(),xmacrolet(),xunwindprotect(),xpp(),
  2038. X    xstrlss(),xstrleq(),xstreql(),xstrneq(),xstrgeq(),xstrgtr(),
  2039. X    xstrilss(),xstrileq(),xstrieql(),xstrineq(),xstrigeq(),xstrigtr(),
  2040. X    xupcase(),xdowncase(),xnupcase(),xndowncase(),
  2041. X    xtrim(),xlefttrim(),xrighttrim(),
  2042. X    xuppercasep(),xlowercasep(),xbothcasep(),xdigitp(),xalphanumericp(),
  2043. X    xcharcode(),xcodechar(),xchupcase(),xchdowncase(),xdigitchar(),
  2044. X    xchrlss(),xchrleq(),xchreql(),xchrneq(),xchrgeq(),xchrgtr(),
  2045. X    xchrilss(),xchrileq(),xchrieql(),xchrineq(),xchrigeq(),xchrigtr(),
  2046. X    xintegerp(),xfloatp(),xstringp(),xarrayp(),xstreamp(),xobjectp(),
  2047. X    xwhen(),xunless(),xloop(),
  2048. X    xsymfunction(),xfboundp(),xsend(),xsendsuper(),
  2049. X    xprogv(),xrdbyte(),xwrbyte(),xformat(),
  2050. X    xcharp(),xcharint(),xintchar(),
  2051. X    xmkstrinput(),xmkstroutput(),xgetstroutput(),xgetlstoutput(),
  2052. X    xgetlambda(),xmacroexpand(),x1macroexpand(),
  2053. X    xtrace(),xuntrace(),
  2054. X    xdefstruct(),xmkstruct(),xcpystruct(),xstrref(),xstrset(),xstrtypep(),
  2055. X    xasin(),xacos(),xatan(),
  2056. X    Prim_POPEN(), Prim_PCLOSE(), Prim_SYSTEM(),    /* NPM */
  2057. X    Prim_FSCANF_FIXNUM(), Prim_FSCANF_STRING(), Prim_FSCANF_FLONUM(), /* NPM */
  2058. X    Prim_COPY_ARRAY(), Prim_ARRAY_INSERT_POS(), Prim_ARRAY_DELETE_POS(); /* NPM */
  2059. X
  2060. Xextern LVAL xosenvget(); /* JSP */
  2061. Xextern void xlinclude_hybrid_prims(); /* Voodoo */
  2062. X
  2063. X/* Include hybrid-class functions: *//* JSP */
  2064. X#define MODULE_XLFTAB_C_GLOBALS
  2065. X#include "../../xmodules.h"
  2066. X#undef MODULE_XLFTAB_C_GLOBALS
  2067. X
  2068. X/* functions specific to xldmem.c */
  2069. XLVAL xgc(),xexpand(),xalloc(),xmem();
  2070. X#ifdef SAVERESTORE
  2071. XLVAL xsave(),xrestore();
  2072. X#endif
  2073. X
  2074. X/* include system dependent definitions */
  2075. X#include "osdefs.h"
  2076. X
  2077. X/* SUBR/FSUBR indicator */
  2078. X#define S    SUBR
  2079. X#define F    FSUBR
  2080. X
  2081. X/* forward declarations */
  2082. XLVAL xnotimp();
  2083. X
  2084. X/* the function table */
  2085. XFUNDEF *funtab;
  2086. X
  2087. X/* and its associated parts */ /* Voodoo */
  2088. X#define xlisp_prim_max 500
  2089. Xint    iPrimCount;
  2090. X
  2091. X
  2092. X/* xlfinit - setup xlisp function table */ /* Voodoo */
  2093. Xvoid xlfinit()
  2094. X{
  2095. X    int        iIndex;
  2096. X
  2097. X    if (funtab = (FUNDEF *) malloc(xlisp_prim_max * sizeof(FUNDEF))) {
  2098. X    
  2099. X    iPrimCount = 0;
  2100. X
  2101. X    /* load xlisp native prims, updates iPrimCount global */
  2102. X    xlinclude_native_prims();      
  2103. X    
  2104. X    /* load user's hybrid prims, updates iPrimCount global */
  2105. X    xlinclude_hybrid_prims();      
  2106. X    
  2107. X    /* reserve a slot for sentinel */
  2108. X    funtab[iPrimCount].fd_name = 0;
  2109. X    funtab[iPrimCount].fd_type = 0;
  2110. X    funtab[iPrimCount].fd_subr = 0;
  2111. X    iPrimCount ++;
  2112. X
  2113. X    /* allocate permanent global funtable of exact size */
  2114. X    funtab = (FUNDEF *) realloc(funtab, iPrimCount * sizeof(FUNDEF));
  2115. X    }
  2116. X
  2117. X    } /* xlfinit */
  2118. X
  2119. X
  2120. X
  2121. X/*  xldefine_prim - enter xlisp prim into xlisp function table */
  2122. Xvoid xldefine_prim(sName, iType, pFun)  /* Voodoo */
  2123. X    char        *sName;
  2124. X    int            iType;
  2125. X    LVAL         (*pFun)();
  2126. X{
  2127. X    funtab[iPrimCount].fd_name = sName;        
  2128. X    funtab[iPrimCount].fd_type = iType;        
  2129. X    funtab[iPrimCount].fd_subr = pFun;        
  2130. X    iPrimCount ++;
  2131. X    }   
  2132. X
  2133. X
  2134. X
  2135. X/* xnotimp - function table entries that are currently not implemented */
  2136. XLOCAL LVAL xnotimp()
  2137. X{
  2138. X    xlfail("function not implemented");
  2139. X}
  2140. X
  2141. X/* funtab_offset - find given fn in funtab. */        /* JSP */
  2142. X/* (Obviates need for hacks like FT_CLNEW.) */          /* JSP */
  2143. XLOCAL int funtab_index = 0; /* For O(1) lookup time on ordered requests. */
  2144. Xfuntab_offset(fn)                    /* JSP */
  2145. XLVAL        (*fn)();                    /* JSP */
  2146. X{                            /* JSP */
  2147. X    int wrapCount = 0;                    /* JSP */
  2148. X    while (wrapCount < 2) {                /* JSP */
  2149. X        LVAL (*e)() = funtab[ funtab_index ].fd_subr;    /* JSP */
  2150. X        if (e == fn)   return funtab_index;        /* JSP */
  2151. X        if (e)              ++funtab_index;        /* JSP */
  2152. X        else {++wrapCount;    funtab_index = 0;}    /* JSP */
  2153. X    }                            /* JSP */
  2154. X    xlfatal("funtab_offset: internal error");        /* JSP */
  2155. X}                            /* JSP */
  2156. X
  2157. X
  2158. X
  2159. X
  2160. Xxlinclude_native_prims()
  2161. X{
  2162. X    /* read macro functions */
  2163. X
  2164. X    
  2165. Xxldefine_prim(NULL,        S, rmhash        ); /*   0 */
  2166. Xxldefine_prim(NULL,        S, rmquote        ); /*   1 */
  2167. Xxldefine_prim(NULL,        S, rmdquote        ); /*   2 */
  2168. Xxldefine_prim(NULL,        S, rmbquote        ); /*   3 */
  2169. Xxldefine_prim(NULL,        S, rmcomma        ); /*   4 */
  2170. Xxldefine_prim(NULL,        S, rmlpar        ); /*   5 */
  2171. Xxldefine_prim(NULL,        S, rmrpar        ); /*   6 */
  2172. Xxldefine_prim(NULL,        S, rmsemi        ); /*   7 */
  2173. Xxldefine_prim(NULL,        S, xnotimp        ); /*   8 */
  2174. X#ifdef ORIGINAL
  2175. Xxldefine_prim(NULL,        S, xnotimp        ); /*   9 */
  2176. X#else
  2177. X    /* BUGGO,need to put envget somewhere else. */
  2178. Xxldefine_prim("GETENV",        S, xosenvget        ); /*   9 */
  2179. X#endif
  2180. X    
  2181. X    /* methods */
  2182. Xxldefine_prim(NULL,        S, clnew        ); /*  10 */
  2183. Xxldefine_prim(NULL,        S, clisnew        ); /*  11 */
  2184. Xxldefine_prim(NULL,        S, clanswer        ); /*  12 */
  2185. Xxldefine_prim(NULL,        S, obisnew        ); /*  13 */
  2186. Xxldefine_prim(NULL,        S, obclass        ); /*  14 */
  2187. Xxldefine_prim(NULL,        S, obshow        ); /*  15 */
  2188. Xxldefine_prim(NULL,        S, xnotimp        ); /*  16 */
  2189. Xxldefine_prim(NULL,        S, xnotimp        ); /*  17 */
  2190. Xxldefine_prim(NULL,        S, xnotimp        ); /*  18 */
  2191. Xxldefine_prim(NULL,        S, xnotimp        ); /*  19 */
  2192. X    
  2193. X    /* evaluator functions */
  2194. Xxldefine_prim("EVAL",        S, xeval        ); /*  20 */
  2195. Xxldefine_prim("APPLY",        S, xapply        ); /*  21 */
  2196. Xxldefine_prim("FUNCALL",    S, xfuncall        ); /*  22 */
  2197. Xxldefine_prim("QUOTE",        F, xquote        ); /*  23 */
  2198. Xxldefine_prim("FUNCTION",    F, xfunction        ); /*  24 */
  2199. Xxldefine_prim("BACKQUOTE",    F, xbquote        ); /*  25 */
  2200. Xxldefine_prim("LAMBDA",        F, xlambda        ); /*  26 */
  2201. X    
  2202. X    /* symbol functions */
  2203. Xxldefine_prim("SET",        S, xset            ); /*  27 */
  2204. Xxldefine_prim("SETQ",        F, xsetq        ); /*  28 */
  2205. Xxldefine_prim("SETF",        F, xsetf        ); /*  29 */
  2206. Xxldefine_prim("DEFUN",        F, xdefun        ); /*  30 */
  2207. Xxldefine_prim("DEFMACRO",    F, xdefmacro        ); /*  31 */
  2208. Xxldefine_prim("GENSYM",        S, xgensym        ); /*  32 */
  2209. Xxldefine_prim("MAKE-SYMBOL",    S, xmakesymbol        ); /*  33 */
  2210. Xxldefine_prim("INTERN",     S, xintern        ); /*  34 */
  2211. Xxldefine_prim("SYMBOL-NAME",    S, xsymname        ); /*  35 */
  2212. Xxldefine_prim("SYMBOL-VALUE",    S, xsymvalue        ); /*  36 */
  2213. Xxldefine_prim("SYMBOL-PLIST",    S, xsymplist        ); /*  37 */
  2214. Xxldefine_prim("GET",        S, xget    ); /*  38 */
  2215. Xxldefine_prim("PUTPROP",    S, xputprop); /*  39 */
  2216. Xxldefine_prim("REMPROP",    S, xremprop        ); /*  40 */
  2217. Xxldefine_prim("HASH",        S, xhash        ); /*  41 */
  2218. X    
  2219. X    /* array functions */
  2220. Xxldefine_prim("MAKE-ARRAY",    S, xmkarray        ); /*  42 */
  2221. Xxldefine_prim("AREF",        S, xaref        ); /*  43 */
  2222. X    
  2223. X    /* list functions */
  2224. Xxldefine_prim("CAR",        S, xcar            ); /*  44 */
  2225. Xxldefine_prim("CDR",        S, xcdr            ); /*  45 */
  2226. X    
  2227. Xxldefine_prim("CAAR",        S, xcaar        ); /*  46 */
  2228. Xxldefine_prim("CADR",        S, xcadr        ); /*  47 */
  2229. Xxldefine_prim("CDAR",        S, xcdar        ); /*  48 */
  2230. Xxldefine_prim("CDDR",        S, xcddr        ); /*  49 */
  2231. X    
  2232. Xxldefine_prim("CAAAR",        S, xcaaar        ); /*  50 */
  2233. Xxldefine_prim("CAADR",        S, xcaadr        ); /*  51 */
  2234. Xxldefine_prim("CADAR",        S, xcadar        ); /*  52 */
  2235. Xxldefine_prim("CADDR",        S, xcaddr        ); /*  53 */
  2236. Xxldefine_prim("CDAAR",        S, xcdaar        ); /*  54 */
  2237. Xxldefine_prim("CDADR",        S, xcdadr        ); /*  55 */
  2238. Xxldefine_prim("CDDAR",        S, xcddar        ); /*  56 */
  2239. Xxldefine_prim("CDDDR",        S, xcdddr        ); /*  57 */
  2240. X    
  2241. Xxldefine_prim("CAAAAR",     S, xcaaaar        ); /*  58 */
  2242. Xxldefine_prim("CAAADR",        S, xcaaadr        ); /*  59 */
  2243. Xxldefine_prim("CAADAR",        S, xcaadar        ); /*  60 */
  2244. Xxldefine_prim("CAADDR",        S, xcaaddr        ); /*  61 */
  2245. Xxldefine_prim("CADAAR",        S, xcadaar        ); /*  62 */
  2246. Xxldefine_prim("CADADR",        S, xcadadr        ); /*  63 */
  2247. Xxldefine_prim("CADDAR",        S, xcaddar        ); /*  64 */
  2248. Xxldefine_prim("CADDDR",        S, xcadddr        ); /*  65 */
  2249. Xxldefine_prim("CDAAAR",        S, xcdaaar        ); /*  66 */
  2250. Xxldefine_prim("CDAADR",        S, xcdaadr        ); /*  67 */
  2251. Xxldefine_prim("CDADAR",        S, xcdadar        ); /*  68 */
  2252. Xxldefine_prim("CDADDR",        S, xcdaddr        ); /*  69 */
  2253. Xxldefine_prim("CDDAAR",        S, xcddaar        ); /*  70 */
  2254. Xxldefine_prim("CDDADR",        S, xcddadr        ); /*  71 */
  2255. Xxldefine_prim("CDDDAR",        S, xcdddar        ); /*  72 */
  2256. Xxldefine_prim("CDDDDR",        S, xcddddr        ); /*  73 */
  2257. X    
  2258. Xxldefine_prim("CONS",        S, xcons        ); /*  74 */
  2259. Xxldefine_prim("LIST",        S, xlist        ); /*  75 */
  2260. Xxldefine_prim("APPEND",        S, xappend        ); /*  76 */
  2261. Xxldefine_prim("REVERSE",    S, xreverse        ); /*  77 */
  2262. Xxldefine_prim("LAST",        S, xlast        ); /*  78 */
  2263. Xxldefine_prim("NTH",        S, xnth            ); /*  79 */
  2264. Xxldefine_prim("NTHCDR",        S, xnthcdr        ); /*  80 */
  2265. Xxldefine_prim("MEMBER",        S, xmember        ); /*  81 */
  2266. Xxldefine_prim("ASSOC",        S, xassoc        ); /*  82 */
  2267. Xxldefine_prim("SUBST",         S, xsubst        ); /*  83 */
  2268. Xxldefine_prim("SUBLIS",        S, xsublis        ); /*  84 */
  2269. Xxldefine_prim("REMOVE",        S, xremove        ); /*  85 */
  2270. Xxldefine_prim("LENGTH",        S, xlength        ); /*  86 */
  2271. Xxldefine_prim("MAPC",        S, xmapc        ); /*  87 */
  2272. Xxldefine_prim("MAPCAR",        S, xmapcar        ); /*  88 */
  2273. Xxldefine_prim("MAPL",        S, xmapl        ); /*  89 */
  2274. Xxldefine_prim("MAPLIST",    S, xmaplist        ); /*  90 */
  2275. X    
  2276. X    /* destructive list functions */
  2277. Xxldefine_prim("RPLACA",        S, xrplca        ); /*  91 */
  2278. Xxldefine_prim("RPLACD",        S, xrplcd        ); /*  92 */
  2279. Xxldefine_prim("NCONC",        S, xnconc        ); /*  93 */
  2280. Xxldefine_prim("DELETE",        S, xdelete        ); /*  94 */
  2281. X    
  2282. X    /* predicate functions */
  2283. Xxldefine_prim("ATOM",        S, xatom        ); /*  95 */
  2284. Xxldefine_prim("SYMBOLP",    S, xsymbolp        ); /*  96 */
  2285. Xxldefine_prim("NUMBERP",    S, xnumberp        ); /*  97 */
  2286. Xxldefine_prim("BOUNDP",        S, xboundp         ); /*  98 */
  2287. Xxldefine_prim("NULL",        S, xnull        ); /*  99 */
  2288. Xxldefine_prim("LISTP",        S, xlistp        ); /* 100 */
  2289. Xxldefine_prim("CONSP",        S, xconsp        ); /* 101 */
  2290. Xxldefine_prim("MINUSP",        S, xminusp         ); /* 102 */
  2291. Xxldefine_prim("ZEROP",        S, xzerop        ); /* 103 */
  2292. Xxldefine_prim("PLUSP",        S, xplusp        ); /* 104 */
  2293. Xxldefine_prim("EVENP",        S, xevenp        ); /* 105 */
  2294. Xxldefine_prim("ODDP",        S, xoddp        ); /* 106 */
  2295. Xxldefine_prim("EQ",        S, xeq            ); /* 107 */
  2296. Xxldefine_prim("EQL",        S, xeql            ); /* 108 */
  2297. Xxldefine_prim("EQUAL",        S, xequal        ); /* 109 */
  2298. X    
  2299. X    /* special forms */
  2300. Xxldefine_prim("COND",        F, xcond        ); /* 110 */
  2301. Xxldefine_prim("CASE",        F, xcase        ); /* 111 */
  2302. Xxldefine_prim("AND",        F, xand            ); /* 112 */
  2303. Xxldefine_prim("OR",        F, xor            ); /* 113 */
  2304. Xxldefine_prim("LET",        F, xlet            ); /* 114 */
  2305. Xxldefine_prim("LET*",        F, xletstar        ); /* 115 */
  2306. Xxldefine_prim("IF",        F, xif            ); /* 116 */
  2307. Xxldefine_prim("PROG",        F, xprog        ); /* 117 */
  2308. Xxldefine_prim("PROG*",        F, xprogstar        ); /* 118 */
  2309. Xxldefine_prim("PROG1",        F, xprog1        ); /* 119 */
  2310. Xxldefine_prim("PROG2",        F, xprog2        ); /* 120 */
  2311. Xxldefine_prim("PROGN",        F, xprogn        ); /* 121 */
  2312. Xxldefine_prim("GO",        F, xgo            ); /* 122 */
  2313. Xxldefine_prim("RETURN",        F, xreturn          ); /* 123 */
  2314. Xxldefine_prim("DO",        F, xdo            ); /* 124 */
  2315. Xxldefine_prim("DO*",        F, xdostar          ); /* 125 */
  2316. Xxldefine_prim("DOLIST",        F, xdolist          ); /* 126 */
  2317. Xxldefine_prim("DOTIMES",    F, xdotimes        ); /* 127 */
  2318. Xxldefine_prim("CATCH",        F, xcatch        ); /* 128 */
  2319. Xxldefine_prim("THROW",        F, xthrow        ); /* 129 */
  2320. X    
  2321. X    /* debugging and error handling functions */
  2322. Xxldefine_prim("ERROR",        S, xerror        ); /* 130 */
  2323. Xxldefine_prim("CERROR",        S, xcerror          ); /* 131 */
  2324. Xxldefine_prim("BREAK",        S, xbreak        ); /* 132 */
  2325. Xxldefine_prim("CLEAN-UP",    S, xcleanup        ); /* 133 */
  2326. Xxldefine_prim("TOP-LEVEL",    S, xtoplevel        ); /* 134 */
  2327. Xxldefine_prim("CONTINUE",    S, xcontinue        ); /* 135 */
  2328. Xxldefine_prim("ERRSET",     F, xerrset          ); /* 136 */
  2329. Xxldefine_prim("BAKTRACE",       S, xbaktrace        ); /* 137 */
  2330. Xxldefine_prim("EVALHOOK",    S, xevalhook        ); /* 138 */
  2331. X    
  2332. X    /* arithmetic functions */
  2333. Xxldefine_prim("TRUNCATE",    S, xfix            ); /* 139 */
  2334. Xxldefine_prim("FLOAT",        S, xfloat        ); /* 140 */
  2335. Xxldefine_prim("+",        S, xadd            ); /* 141 */
  2336. Xxldefine_prim("-",        S, xsub            ); /* 142 */
  2337. Xxldefine_prim("*",        S, xmul            ); /* 143 */
  2338. Xxldefine_prim("/",        S, xdiv            ); /* 144 */
  2339. Xxldefine_prim("1+",        S, xadd1        ); /* 145 */
  2340. Xxldefine_prim("1-",        S, xsub1        ); /* 146 */
  2341. Xxldefine_prim("REM",        S, xrem            ); /* 147 */
  2342. Xxldefine_prim("MIN",        S, xmin            ); /* 148 */
  2343. Xxldefine_prim("MAX",        S, xmax            ); /* 149 */
  2344. Xxldefine_prim("ABS",        S, xabs            ); /* 150 */
  2345. Xxldefine_prim("SIN",        S, xsin            ); /* 151 */
  2346. Xxldefine_prim("COS",        S, xcos            ); /* 152 */
  2347. Xxldefine_prim("TAN",        S, xtan            ); /* 153 */
  2348. Xxldefine_prim("EXPT",        S, xexpt        ); /* 154 */
  2349. Xxldefine_prim("EXP",        S, xexp            ); /* 155 */
  2350. Xxldefine_prim("SQRT",        S, xsqrt        ); /* 156 */
  2351. Xxldefine_prim("RANDOM",        S, xrand        ); /* 157 */
  2352. X    
  2353. X    /* bitwise logical functions */
  2354. Xxldefine_prim("LOGAND",        S, xlogand          ); /* 158 */
  2355. Xxldefine_prim("LOGIOR",        S, xlogior          ); /* 159 */
  2356. Xxldefine_prim("LOGXOR",        S, xlogxor          ); /* 160 */
  2357. Xxldefine_prim("LOGNOT",        S, xlognot          ); /* 161 */
  2358. X    
  2359. X    /* numeric comparison functions */
  2360. Xxldefine_prim("<",        S, xlss            ); /* 162 */
  2361. Xxldefine_prim("<=",        S, xleq            ); /* 163 */
  2362. Xxldefine_prim("=",        S, xequ            ); /* 164 */
  2363. Xxldefine_prim("/=",        S, xneq            ); /* 165 */
  2364. Xxldefine_prim(">=",        S, xgeq            ); /* 166 */
  2365. Xxldefine_prim(">",        S, xgtr            ); /* 167 */
  2366. X    
  2367. X    /* string functions */
  2368. Xxldefine_prim("STRCAT",        S, xstrcat          ); /* 168 */
  2369. Xxldefine_prim("SUBSEQ",        S, xsubseq          ); /* 169 */
  2370. Xxldefine_prim("STRING",        S, xstring          ); /* 170 */
  2371. Xxldefine_prim("CHAR",        S, xchar        ); /* 171 */
  2372. X    
  2373. X    /* I/O functions */
  2374. Xxldefine_prim("READ",        S, xread        ); /* 172 */
  2375. Xxldefine_prim("PRINT",        S, xprint        ); /* 173 */
  2376. Xxldefine_prim("PRIN1",        S, xprin1        ); /* 174 */
  2377. Xxldefine_prim("PRINC",        S, xprinc        ); /* 175 */
  2378. Xxldefine_prim("TERPRI",        S, xterpri          ); /* 176 */
  2379. Xxldefine_prim("FLATSIZE",    S, xflatsize        ); /* 177 */
  2380. Xxldefine_prim("FLATC",        S, xflatc        ); /* 178 */
  2381. X    
  2382. X    /* file I/O functions */
  2383. Xxldefine_prim("OPEN",        S, xopen        ); /* 179 */
  2384. Xxldefine_prim("FORMAT",        S, xformat          ); /* 180 */
  2385. Xxldefine_prim("CLOSE",        S, xclose        ); /* 181 */
  2386. Xxldefine_prim("READ-CHAR",    S, xrdchar          ); /* 182 */
  2387. Xxldefine_prim("PEEK-CHAR",    S, xpkchar          ); /* 183 */
  2388. Xxldefine_prim("WRITE-CHAR",    S, xwrchar          ); /* 184 */
  2389. Xxldefine_prim("READ-LINE",    S, xreadline        ); /* 185 */
  2390. X    
  2391. X    /* system functions */
  2392. Xxldefine_prim("LOAD",        S, xload        ); /* 186 */
  2393. Xxldefine_prim("DRIBBLE",    S, xtranscript        ); /* 187 */
  2394. X    
  2395. X    /* functions specific to xldmem.c */
  2396. Xxldefine_prim("GC",        S, xgc            ); /* 188 */
  2397. Xxldefine_prim("EXPAND",        S, xexpand          ); /* 189 */
  2398. Xxldefine_prim("ALLOC",        S, xalloc        ); /* 190 */
  2399. Xxldefine_prim("ROOM",        S, xmem            ); /* 191 */
  2400. X#ifdef SAVERESTORE
  2401. Xxldefine_prim("SAVE",        S, xsave        ); /* 192 */
  2402. Xxldefine_prim("RESTORE",    S, xrestore        ); /* 193 */
  2403. X#else
  2404. Xxldefine_prim(NULL,        S, xnotimp        ); /* 192 */
  2405. Xxldefine_prim(NULL,        S, xnotimp        ); /* 193 */
  2406. X#endif
  2407. X    /* end of functions specific to xldmem.c */
  2408. X    
  2409. Xxldefine_prim("TYPE-OF",    S, xtype        ); /* 194 */
  2410. Xxldefine_prim("EXIT",        S, xexit        ); /* 195 */
  2411. Xxldefine_prim("PEEK",        S, xpeek        ); /* 196 */
  2412. Xxldefine_prim("POKE",        S, xpoke        ); /* 197 */
  2413. Xxldefine_prim("ADDRESS-OF",    S, xaddrs        ); /* 198 */
  2414. X    
  2415. X    /* new functions and special forms */
  2416. Xxldefine_prim("VECTOR",        S, xvector          ); /* 199 */
  2417. Xxldefine_prim("BLOCK",        F, xblock        ); /* 200 */
  2418. Xxldefine_prim("RETURN-FROM",    F, xrtnfrom        ); /* 201 */
  2419. Xxldefine_prim("TAGBODY",    F, xtagbody        ); /* 202 */
  2420. Xxldefine_prim("PSETQ",        F, xpsetq        ); /* 203 */
  2421. Xxldefine_prim("FLET",        F, xflet        ); /* 204 */
  2422. Xxldefine_prim("LABELS",        F, xlabels          ); /* 205 */
  2423. Xxldefine_prim("MACROLET",    F, xmacrolet        ); /* 206 */
  2424. Xxldefine_prim("UNWIND-PROTECT",    F, xunwindprotect    ); /* 207 */
  2425. Xxldefine_prim("PPRINT",        S, xpp            ); /* 208 */
  2426. Xxldefine_prim("STRING<",    S, xstrlss          ); /* 209 */
  2427. Xxldefine_prim("STRING<=",    S, xstrleq          ); /* 210 */
  2428. Xxldefine_prim("STRING=",    S, xstreql          ); /* 211 */
  2429. Xxldefine_prim("STRING/=",    S, xstrneq          ); /* 212 */
  2430. Xxldefine_prim("STRING>=",    S, xstrgeq          ); /* 213 */
  2431. Xxldefine_prim("STRING>",    S, xstrgtr          ); /* 214 */
  2432. Xxldefine_prim("STRING-LESSP",        S, xstrilss        ); /* 215 */
  2433. Xxldefine_prim("STRING-NOT-GREATERP",    S, xstrileq        ); /* 216 */
  2434. Xxldefine_prim("STRING-EQUAL",        S, xstrieql        ); /* 217 */
  2435. Xxldefine_prim("STRING-NOT-EQUAL",    S, xstrineq        ); /* 218 */
  2436. Xxldefine_prim("STRING-NOT-LESSP",    S, xstrigeq        ); /* 219 */
  2437. Xxldefine_prim("STRING-GREATERP",    S, xstrigtr        ); /* 220 */
  2438. Xxldefine_prim("INTEGERP",        S, xintegerp        ); /* 221 */
  2439. Xxldefine_prim("FLOATP",            S, xfloatp          ); /* 222 */
  2440. Xxldefine_prim("STRINGP",        S, xstringp        ); /* 223 */
  2441. Xxldefine_prim("ARRAYP",            S, xarrayp          ); /* 224 */
  2442. Xxldefine_prim("STREAMP",        S, xstreamp        ); /* 225 */
  2443. Xxldefine_prim("OBJECTP",        S, xobjectp        ); /* 226 */
  2444. Xxldefine_prim("STRING-UPCASE",        S, xupcase          ); /* 227 */
  2445. Xxldefine_prim("STRING-DOWNCASE",    S, xdowncase        ); /* 228 */
  2446. Xxldefine_prim("NSTRING-UPCASE",        S, xnupcase        ); /* 229 */
  2447. Xxldefine_prim("NSTRING-DOWNCASE",    S, xndowncase        ); /* 230 */
  2448. Xxldefine_prim("STRING-TRIM",        S, xtrim        ); /* 231 */
  2449. Xxldefine_prim("STRING-LEFT-TRIM",    S, xlefttrim        ); /* 232 */
  2450. Xxldefine_prim("STRING-RIGHT-TRIM",    S, xrighttrim        ); /* 233 */
  2451. Xxldefine_prim("WHEN",            F, xwhen        ); /* 234 */
  2452. Xxldefine_prim("UNLESS",            F, xunless          ); /* 235 */
  2453. Xxldefine_prim("LOOP",            F, xloop        ); /* 236 */
  2454. Xxldefine_prim("SYMBOL-FUNCTION",    S, xsymfunction        ); /* 237 */
  2455. Xxldefine_prim("FBOUNDP",        S, xfboundp        ); /* 238 */
  2456. Xxldefine_prim("SEND",            S, xsend        ); /* 239 */
  2457. Xxldefine_prim("SEND-SUPER",        S, xsendsuper        ); /* 240 */
  2458. Xxldefine_prim("PROGV",            F, xprogv        ); /* 241 */
  2459. Xxldefine_prim("CHARACTERP",        S, xcharp        ); /* 242 */
  2460. Xxldefine_prim("CHAR-INT",        S, xcharint        ); /* 243 */
  2461. Xxldefine_prim("INT-CHAR",        S, xintchar        ); /* 244 */
  2462. Xxldefine_prim("READ-BYTE",        S, xrdbyte          ); /* 245 */
  2463. Xxldefine_prim("WRITE-BYTE",        S, xwrbyte          ); /* 246 */
  2464. Xxldefine_prim("MAKE-STRING-INPUT-STREAM",     S, xmkstrinput        ); /* 247 */
  2465. Xxldefine_prim("MAKE-STRING-OUTPUT-STREAM",    S, xmkstroutput        ); /* 248 */
  2466. Xxldefine_prim("GET-OUTPUT-STREAM-STRING",    S, xgetstroutput    ); /* 249 */
  2467. Xxldefine_prim("GET-OUTPUT-STREAM-LIST",    S, xgetlstoutput    ); /* 250 */
  2468. Xxldefine_prim("GCD",            S, xgcd            ); /* 251 */
  2469. Xxldefine_prim("GET-LAMBDA-EXPRESSION",     S, xgetlambda        ); /* 252 */
  2470. Xxldefine_prim("MACROEXPAND",        S, xmacroexpand        ); /* 253 */
  2471. Xxldefine_prim("MACROEXPAND-1",        S, x1macroexpand    ); /* 254 */
  2472. Xxldefine_prim("CHAR<",            S, xchrlss          ); /* 255 */
  2473. Xxldefine_prim("CHAR<=",            S, xchrleq          ); /* 256 */
  2474. Xxldefine_prim("CHAR=",            S, xchreql          ); /* 257 */
  2475. Xxldefine_prim("CHAR/=",            S, xchrneq          ); /* 258 */
  2476. Xxldefine_prim("CHAR>=",            S, xchrgeq          ); /* 259 */
  2477. Xxldefine_prim("CHAR>",            S, xchrgtr          ); /* 260 */
  2478. Xxldefine_prim("CHAR-LESSP",        S, xchrilss        ); /* 261 */
  2479. Xxldefine_prim("CHAR-NOT-GREATERP",    S, xchrileq        ); /* 262 */
  2480. Xxldefine_prim("CHAR-EQUAL",        S, xchrieql        ); /* 263 */
  2481. Xxldefine_prim("CHAR-NOT-EQUAL",        S, xchrineq        ); /* 264 */
  2482. Xxldefine_prim("CHAR-NOT-LESSP",        S, xchrigeq        ); /* 265 */
  2483. Xxldefine_prim("CHAR-GREATERP",        S, xchrigtr        ); /* 266 */
  2484. Xxldefine_prim("UPPER-CASE-P",        S, xuppercasep        ); /* 267 */
  2485. Xxldefine_prim("LOWER-CASE-P",        S, xlowercasep        ); /* 268 */
  2486. Xxldefine_prim("BOTH-CASE-P",        S, xbothcasep        ); /* 269 */
  2487. Xxldefine_prim("DIGIT-CHAR-P",        S, xdigitp        ); /* 270 */
  2488. Xxldefine_prim("ALPHANUMERICP",        S, xalphanumericp    ); /* 271 */
  2489. Xxldefine_prim("CHAR-UPCASE",        S, xchupcase        ); /* 272 */
  2490. Xxldefine_prim("CHAR-DOWNCASE",        S, xchdowncase        ); /* 273 */
  2491. Xxldefine_prim("DIGIT-CHAR",        S, xdigitchar        ); /* 274 */
  2492. Xxldefine_prim("CHAR-CODE",        S, xcharcode        ); /* 275 */
  2493. Xxldefine_prim("CODE-CHAR",        S, xcodechar        ); /* 276 */
  2494. Xxldefine_prim("ENDP",            S, xendp        ); /* 277 */
  2495. Xxldefine_prim("REMOVE-IF",        S, xremif        ); /* 278 */
  2496. Xxldefine_prim("REMOVE-IF-NOT",        S, xremifnot        ); /* 279 */
  2497. Xxldefine_prim("DELETE-IF",        S, xdelif        ); /* 280 */
  2498. Xxldefine_prim("DELETE-IF-NOT",        S, xdelifnot        ); /* 281 */
  2499. Xxldefine_prim("TRACE",            F, xtrace        ); /* 282 */
  2500. Xxldefine_prim("UNTRACE",        F, xuntrace        ); /* 283 */
  2501. Xxldefine_prim("SORT",            S, xsort        ); /* 284 */
  2502. Xxldefine_prim("DEFSTRUCT",        F, xdefstruct        ); /* 285 */
  2503. Xxldefine_prim("%STRUCT-TYPE-P",        S, xstrtypep        ); /* 286 */
  2504. Xxldefine_prim("%MAKE-STRUCT",        S, xmkstruct        ); /* 287 */
  2505. Xxldefine_prim("%COPY-STRUCT",        S, xcpystruct        ); /* 288 */
  2506. Xxldefine_prim("%STRUCT-REF",        S, xstrref        ); /* 289 */
  2507. Xxldefine_prim("%STRUCT-SET",        S, xstrset        ); /* 290 */
  2508. Xxldefine_prim("ASIN",            S, xasin        ); /* 291 */
  2509. Xxldefine_prim("ACOS",            S, xacos        ); /* 292 */
  2510. Xxldefine_prim("ATAN",            S, xatan        ); /* 293 */
  2511. X    
  2512. X    /* extra table entries */
  2513. Xxldefine_prim("SYSTEM",            S, Prim_SYSTEM        ); /* 294 NPM */
  2514. Xxldefine_prim("POPEN",            S, Prim_POPEN        ); /* 295 NPM */
  2515. Xxldefine_prim("PCLOSE",            S, Prim_PCLOSE        ); /* 296 NPM */
  2516. Xxldefine_prim("FSCANF-FIXNUM",        S, Prim_FSCANF_FIXNUM    ); /* 297 NPM */
  2517. Xxldefine_prim("FSCANF-STRING",        S, Prim_FSCANF_STRING    ); /* 298 NPM */
  2518. Xxldefine_prim("FSCANF-FLONUM",        S, Prim_FSCANF_FLONUM    ); /* 299 NPM */
  2519. Xxldefine_prim("COPY-ARRAY",        S, Prim_COPY_ARRAY    ); /* 300 NPM */
  2520. Xxldefine_prim("ARRAY-INSERT-POS",    S, Prim_ARRAY_INSERT_POS); /* 301 NPM */
  2521. Xxldefine_prim("ARRAY-DELETE-POS",    S, Prim_ARRAY_DELETE_POS); /* 302 NPM */
  2522. X    
  2523. X    /* include system dependant function pointers */
  2524. X#include "osptrs.h"
  2525. X    
  2526. X/* Include hybrid-class funtab entries: */  /* JSP a la Voodoo */
  2527. X#define MODULE_XLFTAB_C_FUNTAB_S
  2528. X#include "../../xmodules.h"
  2529. X#undef MODULE_XLFTAB_C_FUNTAB_S
  2530. X
  2531. X/* Include hybrid-class funtab entries: */  /* JSP a la Voodoo */
  2532. X#define MODULE_XLFTAB_C_FUNTAB_F
  2533. X#include "../../xmodules.h"
  2534. X#undef MODULE_XLFTAB_C_FUNTAB_F
  2535. X
  2536. X}
  2537. END_OF_FILE
  2538. if test 22885 -ne `wc -c <'src/xlisp/xcore/c/xlftab.c'`; then
  2539.     echo shar: \"'src/xlisp/xcore/c/xlftab.c'\" unpacked with wrong size!
  2540. fi
  2541. # end of 'src/xlisp/xcore/c/xlftab.c'
  2542. fi
  2543. echo shar: End of archive 10 \(of 16\).
  2544. cp /dev/null ark10isdone
  2545. MISSING=""
  2546. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 ; do
  2547.     if test ! -f ark${I}isdone ; then
  2548.     MISSING="${MISSING} ${I}"
  2549.     fi
  2550. done
  2551. if test "${MISSING}" = "" ; then
  2552.     echo You have unpacked all 16 archives.
  2553.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  2554. else
  2555.     echo You still need to unpack the following archives:
  2556.     echo "        " ${MISSING}
  2557. fi
  2558. ##  End of shell archive.
  2559. exit 0
  2560.