1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488
|
\documentclass{article}
\usepackage{axiom}
\begin{document}
\title{\$SPAD/src/interp util.lisp}
\author{Timothy Daly}
\maketitle
\begin{abstract}
\end{abstract}
\eject
\tableofcontents
\eject
\section{util.lisp}
This file is a collection of utility functions that are useful
for system level work. A couple of the functions, {\bf build-depsys}
and {\bf build-interpsys} interface to the src/interp/Makefile.
A second group of related functions allows us to rebuild portions
of the system from the command prompt. This varies from rebuilding
individual files to whole directories. The most complex functions
like {\bf makespad} can rebuild the whole algebra tree.
A third group of related functions are used to set up the
{\bf autoload} mechanism. These enable whole subsystems to
be kept out of memory until they are used.
A fourth group of related functions are used to construct and
search Emacs TAGS files.
A fifth group of related functions are some translated boot
functions we need to define here so they work and are available
at load time.
\subsection{Building Depsys (build-depsys)}
The {\bf depsys} image is one of the two images we build from
the src/interp subdirectory (the other is {\bf interpsys}). We
use {\bf depsys} as a compile-time image as it contains all of
the necessary functions and macros to compile any file. The
{\bf depsys} image is almost the same as an {\bf interpsys}
image but it does not have any autoload triggers or databases
loaded.
\begin{chunk}{build-depsys}
(defun build-depsys (load-files spad lsp src int obj mnt sys)
#+:CCL
(setq *package* (find-package "BOOT"))
#+:AKCL
(in-package "BOOT")
(push :oldboot *features*)
(mapcar #'load load-files)
(make-depsys lsp src int obj mnt sys)
(initroot spad)
#+:AKCL
(init-memory-config :cons 1000 :fixnum 400 :symbol 1000 :package 16
:array 800 :string 1000 :cfun 200 :cpages 2000
:rpages 2000 :hole 4000) )
;; (init-memory-config :cons 500 :fixnum 200 :symbol 500 :package 8
;; :array 400 :string 500 :cfun 100 :cpages 1000
;; :rpages 1000 :hole 2000) )
\end{chunk}
\subsubsection{make-depsys}
When we are building a {\bf depsys} image for AKCL (now GCL) we need
need to initialize some optimization routines. Each time a file is
compiled in GCL we collect some function information and write it
out to a {\bf .fn} file. If this {\bf .fn} file exists at compile
time then GCL will perform function call optimizations. These can
be significant in terms of performance.
We comment out the load of collectfn because it is already preloaded
into the image. It used to read:
\begin{verbatim}
((collectfn (concatenate 'string (string lsp) "/cmpnew/collectfn")))
(unless (probe-file (concatenate 'string collectfn ".o"))
(compile-file collectfn))
(load collectfn)
(compiler::emit-fn t)
\end{verbatim}
\begin{chunk}{make-depsys}
(defun make-depsys (lsp src int obj mnt sys)
;; perform system initializations for building a starter system
(init-memory-config)
#+:AKCL
(let ()
(mapcar
#'load
(directory (concatenate 'string obj "/" sys "/interp/*.fn")))
(with-open-file
(out (concatenate 'string obj "/" sys "/interp/proclaims.lisp" )
:direction :output)
(compiler::make-proclaims out))
(load (concatenate 'string obj "/" sys "/interp/proclaims.lisp")))
)
\end{chunk}
\subsection{Building Interpsys (build-interpsys)}
\begin{verbatim}
;############################################################################
;# autoload dependencies
;#
;# if you are adding a file which is to be autoloaded the following step
;# information is useful:
;# there are 2 cases:
;# 1) adding files to currently autoloaded parts
;# (as of 2/92: browser old parser and old compiler)
;# 2) adding new files
;# case 1:
;# a) you have to add the file to the list of files currently there
;# (e.g. see BROBJS above)
;# b) add an autolaod rule
;# (e.g. ${AUTO}/parsing.${O}: ${OUT}/parsing.${O})
;# c) edit util.lisp to add the 'external' function (those that
;# should trigger the autoload
;# case 2:
;# build-interpsys (in util.lisp) needs an extra argument for the
;# new autoload things and several functions in util.lisp need hacking.
;############################################################################
\end{verbatim}
The {\bf build-interpsys} function takes a list of files to load
into the image ({\bf load-files}). It also takes several lists of files,
one for each subsystem which will be autoloaded. Autoloading is explained
below. Next it takes a set of shell variables, the most important of
which is the {\bf spad} variable. This is normally set to be the same
as the final build location. This function is called in the
src/interp/Makefile.
This function calls {\bf initroot} to set up pathnames we need. Next
it sets up the lisp system memory (at present only for AKCL/GCL). Next
it loads all of the named files, resets a few global state variables,
loads the databases, sets up autoload triggers and clears out hash tables.
After this function is called the image is clean and can be saved.
\begin{chunk}{build-interpsys}
(defun build-interpsys (load-files browse-files nagbr-files
spad lsp src int obj mnt sys)
(push :oldboot *features*)
(initroot spad)
#+:AKCL
(init-memory-config :cons 500 :fixnum 200 :symbol 500 :package 8
:array 400 :string 500 :cfun 100 :cpages 1000
:rpages 1000 :hole 2000)
\getchunk{compiler-notes}
(mapcar #'load load-files)
(|resetWorkspaceVariables|)
(|initHist|)
(|initNewWorld|)
(interpopen)
(|start| :fin)
#+:CCL
(resethashtables)
(setq *load-verbose* nil)
(|setBootAutloadProperties| browse-functions browse-files)
(|setNAGBootAutloadProperties| nagbr-functions nagbr-files)
(setf (symbol-function 'boot::|addConsDB|) #'identity)
(resethashtables) ; the databases into core, then close the streams
)
\end{chunk}
;start(:l) ==
; -- The function start begins the interpreter process, reading in
; -- the profile and printing start-up messages.
; $PrintCompilerMessageIfTrue: local := nil
; if $displayStartMsgs then sayKeyedMsg("S2IZ0053",['"interpreter"])
; initializeTimedNames($interpreterTimedNames,$interpreterTimedClasses)
; statisticsInitialization()
; $InteractiveFrame := makeInitialModemapFrame()
; initializeSystemCommands()
; initializeInterpreterFrameRing()
; SETQ(ERROROUTSTREAM,
; DEFIOSTREAM('((DEVICE . CONSOLE)(MODE . OUTPUT)),80,0))
; setOutputAlgebra "%initialize%"
; loadExposureGroupData()
; if $displayStartMsgs then sayKeyedMsg("S2IZ0053",['"database"])
; mkLowerCaseConTable()
; if not $ruleSetsInitialized then initializeRuleSets()
; if $displayStartMsgs then sayKeyedMsg("S2IZ0053",['"constructors"])
; makeConstructorsAutoLoad()
; GCMSG(NIL)
; SETQ($IOindex,1)
; if $displayStartMsgs then sayKeyedMsg("S2IZ0053",['"history"])
; initHist()
; if functionp 'addtopath then addtopath CONCAT($SPADROOT,'"bin")
; SETQ($CURRENT_-DIRECTORY,_*DEFAULT_-PATHNAME_-DEFAULTS_*)
; if null(l) then
; if $displayStartMsgs then
; sayKeyedMsg("S2IZ0053",[namestring ['_.axiom,'input]])
; readSpadProfileIfThere()
; if $displayStartMsgs then spadStartUpMsgs()
; if $OLDLINE then
; SAY fillerSpaces($LINELENGTH,'"=")
; sayKeyedMsg("S2IZ0050",[namestring ['axiom,'input]])
; if $OLDLINE ^= 'END__UNIT
; then
; centerAndHighlight($OLDLINE,$LINELENGTH,'" ")
; sayKeyedMsg("S2IZ0051",NIL)
; else sayKeyedMsg("S2IZ0052",NIL)
; SAY fillerSpaces($LINELENGTH,'"=")
; TERPRI()
; $OLDLINE := NIL
; $superHash := MAKE_-HASHTABLE('UEQUAL)
; if null l then runspad()
; 'EndOfSpad
\begin{chunk}{defun start}
(DEFUN |start| (&REST G166080 &AUX |l|)
(DSETQ |l| G166080)
(PROG (|$PrintCompilerMessageIfTrue|)
(DECLARE (SPECIAL |$PrintCompilerMessageIfTrue| |$superHash|
$OLDLINE $LINELENGTH |$displayStartMsgs|
$CURRENT-DIRECTORY *DEFAULT-PATHNAME-DEFAULTS*
$SPADROOT |$IOindex| |$ruleSetsInitialized|
|$InteractiveFrame| |$interpreterTimedClasses|
|$interpreterTimedNames|))
(RETURN
(PROGN
(SPADLET |$PrintCompilerMessageIfTrue| NIL)
(COND
(|$displayStartMsgs|
(|sayKeyedMsg| 'S2IZ0053
(CONS "interpreter" NIL))))
(|initializeTimedNames| |$interpreterTimedNames|
|$interpreterTimedClasses|)
(|statisticsInitialization|)
(SPADLET |$InteractiveFrame| (|makeInitialModemapFrame|))
(|initializeSystemCommands|)
(|initializeInterpreterFrameRing|)
(SETQ ERROROUTSTREAM
(DEFIOSTREAM '((DEVICE . CONSOLE) (MODE . OUTPUT)) 80 0))
(|setOutputAlgebra| '|%initialize%|)
(COND
(|$displayStartMsgs|
(|sayKeyedMsg| 'S2IZ0053
(CONS "database" NIL))))
(|mkLowerCaseConTable|)
(COND ((NULL |$ruleSetsInitialized|) (|initializeRuleSets|)))
(COND
(|$displayStartMsgs|
(|sayKeyedMsg| 'S2IZ0053
(CONS "constructors" NIL))))
(|makeConstructorsAutoLoad|)
(GCMSG NIL)
(SETQ |$IOindex| 1)
(COND
(|$displayStartMsgs|
(|sayKeyedMsg| 'S2IZ0053
(CONS "history" NIL))))
(|initHist|)
(COND
((canFuncall? '|addtopath|)
(|addtopath| (CONCAT $SPADROOT "bin"))))
(SETQ $CURRENT-DIRECTORY *DEFAULT-PATHNAME-DEFAULTS*)
(COND
((NULL |l|)
(COND
(|$displayStartMsgs|
(|sayKeyedMsg| 'S2IZ0053
(CONS (|namestring|
(CONS (INTERN ".axiom" "BOOT")
(CONS '|input| NIL)))
NIL))))
(|readSpadProfileIfThere|)))
(COND (|$displayStartMsgs| (|spadStartUpMsgs|)))
(COND
($OLDLINE (SAY (|fillerSpaces| $LINELENGTH "="))
(|sayKeyedMsg| 'S2IZ0050
(CONS (|namestring|
(CONS '|axiom| (CONS '|input| NIL)))
NIL))
(COND
((NEQUAL $OLDLINE 'END_UNIT)
(|centerAndHighlight| $OLDLINE $LINELENGTH
" ")
(|sayKeyedMsg| 'S2IZ0051 NIL))
('T (|sayKeyedMsg| 'S2IZ0052 NIL)))
(SAY (|fillerSpaces| $LINELENGTH "="))
(TERPRI) (SPADLET $OLDLINE NIL)))
(SPADLET |$superHash| (MAKE-HASHTABLE 'UEQUAL))
(COND ((NULL |l|) (|runspad|)))
'|EndOfSpad|))))
\end{chunk}
\begin{verbatim}
;--% Top level system command
;-- (mapcar #'car $systemCommands)
;initializeSystemCommands() ==
; l := $systemCommands
; $SYSCOMMANDS := NIL
; while l repeat
; $SYSCOMMANDS := CONS(CAAR l, $SYSCOMMANDS)
; l := CDR l
; $SYSCOMMANDS := NREVERSE $SYSCOMMANDS
\end{verbatim}
\begin{chunk}{defun initializeSystemCommands}
(DEFUN |initializeSystemCommands| ()
(PROG (|l|)
(declare (special $SYSCOMMANDS |$systemCommands|))
(RETURN
(SEQ (PROGN
(SPADLET |l| |$systemCommands|)
(SPADLET $SYSCOMMANDS NIL)
(DO () ((NULL |l|) NIL)
(SEQ (EXIT (PROGN
(SPADLET $SYSCOMMANDS
(CONS (CAAR |l|) $SYSCOMMANDS))
(SPADLET |l| (CDR |l|))))))
(SPADLET $SYSCOMMANDS (NREVERSE $SYSCOMMANDS)))))))
\end{chunk}
\subsubsection{GCL porting changes}
GCL likes to output lines of the form:
\begin{verbatim}
;; Note: Tail-recursive call of |matSuperList1| was replaced by iteration.
\end{verbatim}
which is pointless and should be removed. Bill Schelter added this while
he was debugging tail-recursive replacement and it never was removed.
\begin{chunk}{compiler-notes}
#+:AKCL
(setq compiler::*suppress-compiler-notes* t)
\end{chunk}
\subsection{The variables}
Various lisps use different ``extensions'' on the filename to indicate
that a file has been compiled. We set this variable correctly depending
on the system we are using.
\begin{chunk}{bin-path}
(defvar *bin-path*
#+kcl "o"
#+lucid "bbin"
#+symbolics "bin"
#+cmulisp "fasl"
#+:ccl "not done this way at all")
\end{chunk}
\subsection{The autoload list}
There are several subsystems within {\bf AXIOM} that are not normally
loaded into a running system. They will be loaded only if you invoke
one of the functions listed here. Each of these listed functions will
have their definitions replaced by a special ``autoloader'' function.
The first time a function named here is called it will trigger a
load of the associated subsystem, the autoloader functions will get
overwritten, the function call is retried and now succeeds. Files
containing functions listed here are assumed to exist in the
{\bf autoload} subdirectory. The list of files to load is defined
in the src/interp/Makefile.
\subsubsection{setBootAutloadProperties}
This function is called by {\bf build-interpsys}. It takes two lists.
The first is a list of functions that need to be used as
``autoload triggers''. The second is a list of files to load if one
of the trigger functions is called. At system build time each of the
functions in the first list is set up to load every file in the second
list. In this way we will automatically load a whole subsystem if we
touch any function in that subsystem. We call a helper function
called {\bf setBootAutoLoadProperty} to set up the autoload trigger.
This helper function is listed below.
\begin{chunk}{setBootAutloadProperties}
(defun |setBootAutloadProperties| (fun-list file-list)
#+:AKCL
(mapc #'(lambda (fun) (|setBootAutoLoadProperty| fun file-list)) fun-list)
#+:CCL
(mapc #'(lambda (fun) (lisp::set-autoload fun file-list)) fun-list)
)
\end{chunk}
\subsubsection{setBootAutoLoadProperty}
This is a helper function to set up the autoload trigger. It sets
the function cell of each symbol to {\bf mkBootAutoLoad} which is
listed below.
\begin{chunk}{setBootAutoLoadProperty}
(defun |setBootAutoLoadProperty| (func file-list)
(setf (symbol-function func) (|mkBootAutoLoad| func file-list)) )
\end{chunk}
\subsubsection{mkBootAutoLoad}
This is how the autoload magic happens. Every function named in the
autoload lists is actually just another name for this function. When
the named function is called we call {\bf boot-load} on all of the
files in the subsystem. This overwrites all of the autoload triggers.
We then look up the new (real) function definition and call it again
with the real arguments. Thus the subsystem loads and the original
call succeeds.
\begin{chunk}{mkBootAutoLoad}
(defun |mkBootAutoLoad| (fn file-list)
(function (lambda (&rest args)
(mapc #'boot-load file-list)
(unless (string= (subseq (string fn) 0 4) "LOAD")
(apply (symbol-function fn) args)))))
\end{chunk}
\subsubsection{boot-load}
This function knows where the {\bf autoload} subdirectory lives.
It is called by {\bf mkBootAutoLoad} above to find the necessary
files.
\begin{chunk}{boot-load}
(defun boot-load (file)
(let ((name (concat $SPADROOT "/autoload/" (pathname-name file))))
(if |$printLoadMsgs|
(format t " Loading ~A.~%" name))
(load name)))
\end{chunk}
\subsubsection{setNAGBootAutloadProperties}
This is a further refinement of the autoload scheme. Since the
Numerical Algorithms Group (NAG) fortran library contains many
functions we subdivide the NAG library subsystem into chapters.
We use a different helper function {\bf get-NAG-chapter} to decide
which files to load.
\begin{chunk}{setNAGBootAutloadProperties}
(defun |setNAGBootAutloadProperties| (function-list file-list)
(mapcar
#'(lambda (f)
(|setBootAutloadProperties|
(get-NAG-chapter (chapter-name f) function-list)
(nag-files f file-list)))
file-list))
\end{chunk}
\subsubsection{get-NAG-chapter}
This function is used to find the names of the files to load.
On solaris 9 under GCL the original implementation will fail because
the max number of arguments is 63. We rewrite it to get around this
problem. It originally read:
\begin{verbatim}
(defun get-NAG-chapter (chapter function-list)
(apply 'append
(mapcar
#'(lambda (f)
(cond
((equalp chapter (subseq (string f) 0 (length chapter))) (list f ))))
function-list)))
\end{verbatim}
\begin{chunk}{get-NAG-chapter}
(defun get-NAG-chapter (chapter function-list)
(let ((l (length chapter)) r)
(dolist (f function-list)
(when (equalp chapter (subseq (string f) 0 l))
(push f r)))
(nreverse r)))
\end{chunk}
\subsubsection{nag-files}
We analyze the function names to decide which chapter we are in.
We load files based on the chapter.
\begin{chunk}{nag-files}
(defun nag-files (filename filelist)
(apply 'append (mapcar
#'(lambda (f)
(cond ((equalp (chapter-name filename) (chapter-name f)) (list f))) )
filelist)))
\end{chunk}
\subsubsection{chapter-name}
The library names follow a convention that allows us to extract
the chapter name.
\begin{chunk}{chapter-name}
(defun chapter-name (f)
#+:AKCL
(apply
#'(lambda (s)
(cond ((equalp (aref s 0) #\s) "s") (T (reverse (subseq s 0 3)))))
(list (string-left-trim "a.o" (reverse f) )) )
#+:CCL
(subseq (string-downcase (string f)) 4 (length (string f)))
)
\end{chunk}
\subsubsection{parse-functions}
This is the {\bf boot parser} subsystem. It is only needed by
developers who translate boot code to Common Lisp.
\begin{chunk}{parse-functions}
;(setq parse-functions
; '(
;;; loadparser
; |oldParserAutoloadOnceTrigger|
; |PARSE-Expression|
; BOOT
; SPAD
; init-boot/spad-reader))
\end{chunk}
\subsubsection{comp-functions}
This is the {\bf spad compiler} subsystem. It is only needed by
developers who write or modify algebra code.
\begin{chunk}{comp-functions}
;(setq comp-functions
; '(
;;; loadcompiler
; |oldCompilerAutoloadOnceTrigger|
;;; |compileSpad2Cmd|
; |convertSpadToAsFile|
; |compilerDoit|
; |compilerDoitWithScreenedLisplib|
; |mkCategory|
; |cons5|
; |sublisV|))
\end{chunk}
\subsubsection{browse-functions}
This is the {\bf browser} subsystem. It will get autoloaded only
if you use the browse function of the {\bf hypertex} system.
\begin{chunk}{browse-functions}
(setq browse-functions
'(
|browserAutoloadOnceTrigger|
|htInitPage|
|parentsOf| ; br-con
|getParentsFor| ; br-con
|folks| ; br-con
|oSearch| ; br-con
|aokSearch|
|kSearch|
|aSearch|
|genSearch|
|docSearch|
|abSearch|
|detailedSearch|
|ancestorsOf|
|domainsOf|
|aPage|
|dbGetOrigin|
|dbComments|
|grepConstruct|
|cSearch|
|dbName|
|dbPart|
|form2HtString|
|htSystemCommands|
|oPage|
|oPageFrom|
|spadSys|
|spadType|
|syscomPage|))
\end{chunk}
\subsubsection{translate-functions}
This is a little used subsystem to generate {\bf ALDOR} code
from {\bf Spad} code. Frankly, I'd be amazed if it worked.
\begin{chunk}{translate-functions}
(setq translate-functions '(
;; .spad to .as translator, in particular
;; loadtranslate
|spad2AsTranslatorAutoloadOnceTrigger|
))
\end{chunk}
\subsubsection{debug-functions}
These are some {\bf debugging} functions that I use. I can't imagine
why you might autoload them but they don't need to be in a running
system.
\begin{chunk}{debug-functions}
(setq debug-functions '(
loaddebug
|showSummary|
|showPredicates|
|showAttributes|
|showFrom|
|showImp|))
\end{chunk}
\subsubsection{anna-functions}
The {\bf ANNA} subsystem, invoked thru {\bf hypertex}, is an
expert system that understands the Numerical Algorithms Group (NAG)
fortran library.
\begin{chunk}{anna-functions}
(setq anna-functions '(
|annaInt|
|annaMInt|
|annaOde|
|annaOpt|
|annaOpt2|
|annaPDESolve|
|annaOptDefaultSolve1|
|annaOptDefaultSolve2|
|annaOptDefaultSolve3|
|annaOptDefaultSolve4|
|annaOptDefaultSolve5|
|annaOpt2DefaultSolve|
|annaFoo|
|annaBar|
|annaJoe|
|annaSue|
|annaAnn|
|annaBab|
|annaFnar|
|annaDan|
|annaBlah|
|annaTub|
|annaRats|
|annaMInt|
|annaOdeDefaultSolve1|
|annaOdeDefaultSolve2|))
\end{chunk}
\subsubsection{nagbr-functions}
The Numerical Algorithms Group (NAG) fortran library has a set
of cover functions. These functions need to be loaded if you use
the NAG library.
\begin{chunk}{nagbr-functions}
(setq nagbr-functions '(
loadnag
|c02aff| |c02agf|
|c05adf| |c05nbf| |c05pbf|
|c06eaf| |c06ebf| |c06ecf| |c06ekf| |c06fpf| |c06fqf| |c06frf|
|c06fuf| |c06gbf| |c06gcf| |c06gqf| |c06gsf|
|d01ajf| |d01akf| |d01alf| |d01amf| |d01anf| |d01apf| |d01aqf|
|d01asf| |d01bbf| |d01fcf| |d01gaf| |d01gbf|
|d02bbf| |d02bhf| |d02cjf| |d02ejf| |d02gaf| |d02gbf| |d02kef|
|d02raf|
|d03edf| |d03eef| |d03faf|
|e01baf| |e01bef| |e01bff| |e01bgf| |e01bhf| |e01daf| |e01saf|
|e01sbf| |e01sef|
|e02adf| |e02aef| |e02agf| |e02ahf| |e02ajf| |e02akf| |e02baf|
|e02bbf| |e02bcf| |e02bdf| |e02bef| |e02daf| |e02dcf|
|e02ddf| |e02def| |e02dff| |e02gaf| |e02zaf|
|e04dgf| |e04fdf| |e04gcf| |e04jaf| |e04mbf| |e04naf| |e04ucf|
|e04ycf|
|f01brf| |f01bsf| |f01maf| |f01mcf| |f01qcf| |f01qdf| |f01qef|
|f01rcf| |f01rdf| |f01ref|
|f02aaf| |f02abf| |f02adf| |f02aef| |f02aff| |f02agf| |f02ajf|
|f02akf| |f02awf| |f02axf| |f02bbf| |f02bjf| |f02fjf|
|f02wef| |f02xef|
|f04adf| |f04arf| |f04asf| |f04atf| |f04axf| |f04faf| |f04jgf|
|f04maf| |f04mbf| |f04mcf| |f04qaf|
|f07adf| |f07aef| |f07fdf| |f07fef|
|s01eaf| |s13aaf| |s13acf| |s13adf| |s14aaf| |s14abf| |s14baf|
|s15adf| |s15aef| |s17acf| |s17adf| |s17aef| |s17aff|
|s17agf| |s17ahf| |s17ajf| |s17akf| |s17dcf| |s17def|
|s17dgf| |s17dhf| |s17dlf| |s18acf| |s18adf| |s18aef|
|s18aff| |s18dcf| |s18def| |s19aaf| |s19abf| |s19acf|
|s19adf| |s20acf| |s20adf| |s21baf| |s21bbf| |s21bcf|
|s21bdf|
))
\end{chunk}
\subsection{The command-line build functions}
\subsubsection{translist}
Translate a list of boot files to common lisp.
\begin{chunk}{translist}
(defun translist (fns)
(mapcar #'(lambda (f) (format t "translating ~a~%" (concat f ".boot"))
(translate f))
fns))
\end{chunk}
\subsubsection{translate}
Translate a single boot file to common lisp
\begin{chunk}{translate}
(defun translate (file) ;; translates a single boot file
#+:CCL
(setq *package* (find-package "BOOT"))
#+:AKCL
(in-package "BOOT")
(let (*print-level* *print-length* (fn (pathname-name file))
(bootfile (merge-pathnames file (concat $spadroot "nboot/.boot"))))
(declare (special *print-level* *print-length*))
(boot bootfile (make-pathname :type "lisp" :defaults bootfile))))
\end{chunk}
\subsubsection{compile-boot-file}
Translate a single boot file to common lisp, compile it
and load it.
\begin{chunk}{compile-boot-file}
(defun compile-boot-file (file)
"compile and load a boot file"
(boot (concat file ".boot") (concat file ".lisp"))
#+:AKCL
(compile-file (concat file ".lisp"))
#+:AKCL
(load (concat file "." *bin-path*))
#+:CCL
(load (concat file ".lisp"))
)
\end{chunk}
\subsubsection{retranslate-file-if-necessary}
Retranslate a single boot file if it has been changed.
\begin{chunk}{retranslate-file-if-necessary}
(defun retranslate-file-if-necessary (bootfile)
(let* ((lfile (make-pathname :type "lisp" :defaults bootfile))
(ldate (our-write-date lfile))
(binfile (make-pathname :type *bin-path* :defaults bootfile))
(bindate (our-write-date binfile))
(bootdate (our-write-date bootfile)))
(if (and ldate bootdate (> ldate bootdate)) nil
(if (and bindate bootdate (> bindate bootdate)) nil
(progn (format t "translating ~a~%" bootfile)
(boot bootfile lfile) (list bootfile))))))
\end{chunk}
\subsubsection{retranslate-directory}
Translate a directory of boot code to common lisp if the boot code
is newer.
\begin{chunk}{retranslate-directory}
(defun retranslate-directory (dir)
(let* ((direc (make-directory dir))
(pattern (make-pathname :directory (pathname-directory direc)
:name :wild :type "boot"))
(files (directory pattern)))
(mapcan #'retranslate-file-if-necessary files)))
\end{chunk}
\subsubsection{recompile-nrlib-if-necessary}
Recompile a single library's lisp file if it is out of date.
The {\bf recompile-lib-file-if-necessary} is defined in nlib.lisp.
\begin{chunk}{recompile-nrlib-if-necessary}
(defun recompile-nrlib-if-necessary (lib)
(recompile-lib-file-if-necessary (concat (namestring lib) "/code.lsp"))
(lift-nrlib-name (namestring lib)))
\end{chunk}
\subsubsection{lift-nrlib-name}
We used to use FOO.nrlib/code.o files for algebra. However there
was no need for this additional level of indirection since the rest
of the information in an nrlib is now kept in the daase files. Thus
we lift the FOO.nrlib/code.o to FOO.o in the final system.
\begin{chunk}{lift-nrlib-name}
(defun lift-nrlib-name (f)
(obey (concat "cp " f "/code.o " (subseq f 0 (position #\. f)) ".o"))
nil)
\end{chunk}
\subsubsection{recompile-lib-directory}
Recompile library lisp code if necessary.
\begin{chunk}{recompile-lib-directory}
(defun recompile-lib-directory (dir)
(let* ((direc (make-directory dir))
(pattern (make-pathname :directory (pathname-directory direc)
:name :wild :type "nrlib"))
(files (directory pattern)))
(mapcan #'recompile-nrlib-if-necessary files)))
\end{chunk}
\subsubsection{recompile-all-files}
Force recompilation of all lisp files in a directory.
\begin{chunk}{recompile-all-files}
(defun recompile-all-files (dir)
(let* ((direc (make-directory dir))
(pattern (make-pathname :directory (pathname-directory direc)
:name :wild :type "lisp"))
(files (directory pattern)))
(mapcar #'compile-file files)))
\end{chunk}
\subsubsection{recompile-directory}
This function will compile any lisp code that has changed in a directory.
\begin{chunk}{recompile-directory}
(defun recompile-directory (dir)
(let* ((direc (make-directory dir))
(pattern (make-pathname :directory (pathname-directory direc)
:name :wild :type "lisp"))
(files (directory pattern)))
(mapcan #'recompile-file-if-necessary files)))
\end{chunk}
\subsubsection{recompile-file-if-necessary}
This is a helper function that checks the time stamp between
the given file and its compiled binary. If the file has changed
since it was last compiled this function will recompile it.
\begin{chunk}{recompile-file-if-necessary}
(defun recompile-file-if-necessary (lfile)
(let* ((bfile (make-pathname :type *bin-path* :defaults lfile))
(bdate (our-write-date bfile))
(ldate (our-write-date lfile)))
(if (and bdate ldate (> bdate ldate)) nil
(progn
(format t "compiling ~a~%" lfile)
(compile-file lfile)
(list bfile)))))
\end{chunk}
\subsubsection{our-write-date}
Get the write date of a file. In GCL we need to check that it
exists first. This is a simple helper function.
\begin{chunk}{our-write-date}
(defun our-write-date (file) (and #+kcl (probe-file file)
(file-write-date file)))
\end{chunk}
\subsubsection{fe}
I'm unsure what this does but I believe it is related to an interpreter
command. Invoking ``)fe'' in the interpreter tries to get at the
src/interp/TAGS file.
\begin{chunk}{fe}
(defun fe (function file &optional (compflag nil) &aux (fn (pathname-name file)))
(let ((tbootfile (concat "/tmp/" fn ".boot"))
(tlispfile (concat "/tmp/" fn ".lisp")))
(system::run-aix-program "fc"
:arguments (list (string function)
(namestring
(merge-pathnames file (concat $SPADROOT "nboot/.boot"))))
:if-output-exists :supersede :output tbootfile)
(boot tbootfile tlispfile)
(if compflag (progn (compile-file tlispfile)
(load (make-pathname :type *bin-path* :defaults tlispfile)))
(load tlispfile))))
\end{chunk}
\subsubsection{fc}
I'm unsure what this does but I believe it is related to an interpreter
command. Invoking ``)fc'' in the interpreter tries to get at the
src/interp/TAGS file.
\begin{chunk}{fc}
(defun fc (function file) (fe function file t))
\end{chunk}
\subsubsection{compspadfiles}
The {\bf compspadfiles} function will recompile a list of {\bf spad} files.
The filelist should be a file containing names of files to compile.
\begin{chunk}{compspadfiles}
(defun compspadfiles (filelist ;; should be a file containing files to compile
&optional (*default-pathname-defaults*
(pathname (concat $SPADROOT "nalgebra/"))))
(with-open-file (stream filelist)
(do ((fname (read-line stream nil nil) (read-line stream nil nil)))
((null fname) 'done)
(setq fname (string-right-trim " *" fname))
(when (not (equal (elt fname 0) #\*))
(spad fname (concat (pathname-name fname) ".out"))))))
\end{chunk}
\subsubsection{load-directory}
Load a whole subdirectory of compiled files
\begin{chunk}{load-directory}
(defun load-directory (dir)
(let* ((direc (make-directory dir))
(pattern (make-pathname :directory (pathname-directory direc)
:name :wild :type *bin-path*))
(files (directory pattern)))
(mapcar #'load files)))
\end{chunk}
\subsubsection{interp-make-directory}
This is used by the ")cd" system command.
\begin{chunk}{interp-make-directory}
(defun interp-make-directory (direc)
(setq direc (namestring direc))
(if (string= direc "") $current-directory
(if (or (member :unix *features*)
(member 'unix *features*))
(progn
(if (char/= (char $current-directory (1-(length $current-directory))) #\/)
(setq $current-directory (concat $current-directory "/")))
(if (char/= (char direc 0) #\/)
(setq direc (concat $current-directory direc)))
(if (char/= (char direc (1- (length direc))) #\/)
(setq direc (concat direc "/")))
direc)
(progn ;; Assume Windows conventions
(if (not (or (char= (char $current-directory (1- (length $current-directory))) #\/)
(char= (char $current-directory (1- (length $current-directory))) #\\ )))
(setq $current-directory (concat $current-directory "\\")))
(if (not (or (char= (char direc 0) #\/)
(char= (char direc 0) #\\)
(find #\: direc)))
(setq direc (concat $current-directory direc)))
(if (not (or (char= (char direc (1- (length direc))) #\/)
(char= (char direc (1- (length direc))) #\\ )))
(setq direc (concat direc "\\")))
direc))))
\end{chunk}
\subsubsection{make-directory}
Make a directory relative to the {\bf \$spadroot} variable.
\begin{chunk}{make-directory}
(defun make-directory (direc)
(setq direc (namestring direc))
(if (string= direc "") $SPADROOT
(if (or (member :unix *features*)
(member 'unix *features*))
(progn
(if (char/= (char direc 0) #\/)
(setq direc (concat $SPADROOT "/" direc)))
(if (char/= (char direc (1- (length direc))) #\/)
(setq direc (concat direc "/")))
direc)
(progn ;; Assume Windows conventions
(if (not (or (char= (char direc 0) #\/)
(char= (char direc 0) #\\)
(find #\: direc)))
(setq direc (concat $SPADROOT "\\" direc)))
(if (not (or (char= (char direc (1- (length direc))) #\/)
(char= (char direc (1- (length direc))) #\\ )))
(setq direc (concat direc "\\")))
direc))))
\end{chunk}
\subsubsection{recompile-all-libs}
Occasionally it will be necessary to iterate over all of the nrlib
directories and compile each of the code.lsp files in every nrlib.
This function will do that. A correct call looks like:
\begin{verbatim}
(in-package "BOOT")
(recompile-all-libs "/spad/mnt/${SYS}/algebra")
\end{verbatim}
where the [[${SYS}]] variable is same as the one set at build time.
\begin{chunk}{recompile-all-libs}
(defun recompile-all-libs (dir)
(let* ((direc (make-directory dir))
(pattern (make-pathname :directory (pathname-directory direc)
:name :wild :type "nrlib"))
(files (directory pattern)))
(mapcar
#'(lambda (lib) (compile-lib-file (concat (namestring lib) "/code.lsp")))
files)))
\end{chunk}
\subsubsection{recompile-all-algebra-files}
We occasionally need to completely rebuild the algebra from the spad
files. This function will iterate across a directory containing all
of the spad files and attempt to recompile them. A correct call looks
like:
\begin{verbatim}
(in-package "BOOT")
(recompile-all-algebra-files "nalg")
\end{verbatim}
Note that it will build a pathname from the current {\bf AXIOM}
shell variable. So if the {\bf AXIOM} shell variable had the value
\begin{verbatim}
/spad/mnt/${SYS}
\end{verbatim}
(where the [[${SYS}]] variable is the same one set at build time)
then the wildcard expands to
\begin{verbatim}
/spad/mnt/${SYS}/nalg/*.spad
\end{verbatim}
and all of the matching files would be recompiled.
\begin{chunk}{recompile-all-algebra-files}
(defun recompile-all-algebra-files (dir) ;; a desperation measure
(let* ((direc (make-directory dir))
(pattern (make-pathname :directory (pathname-directory direc)
:name :wild :type "spad"))
(files (directory pattern))
(*default-pathname-defaults* (pathname direc)))
(mapcar
#'(lambda (fname) (spad fname (concat (pathname-name fname) ".out")))
files)))
\end{chunk}
\subsubsection{boottocl}
The {\bf boottocl} function is the workhorse function that translates
{\bf .boot} files to {\bf Common Lisp}. It basically wraps the actual
{\bf boot} function call to ensure that we don't truncate lines
because of {\bf *print-level*} or {\bf *print-length*}.
\begin{chunk}{boottocl}
(in-package "BOOTTRAN")
#+:oldboot
(defun boottran::boottocl (file) ;; translates a single boot file
#+:CCL
(setq *package* (find-package "BOOT"))
#+:AKCL
(in-package "BOOT")
(let (*print-level* *print-length* (fn (pathname-name file)))
(declare (special *print-level* *print-length*))
(boot::boot
file
(make-pathname
:name (pathname-name file)
:defaults (concatenate 'string boot::$spadroot
"/../../int/interp/foo.clisp")))))
\end{chunk}
\subsubsection{yearweek}
We need a way of distinguishing different versions of the system.
There used to be a way to touch the src/timestamp file whenever
you checked in a change to the change control subsystem.
During make PART=interp (the default for make) we set timestamp
to the filename of this timestamp file. This function converts it
to a luser readable string and sets the *yearweek* variable.
The result of this function is a string that is printed as a banner
when Axiom starts. The actual printing is done by the function
[[spadStartUpMsgs]] in [[src/interp/msgdb.boot]]. It uses a
format string from the file [[src/doc/msgs/s2-us.msgs]].
\begin{chunk}{yearweek}
(defun yearweek ()
"set *yearweek* to the current time string for the version banner"
(declare (special timestamp) (special *yearweek*))
(if (and (boundp 'timestamp) (probe-file timestamp))
(let (sec min hour date month year day dayvec monvec)
(setq dayvec '("Monday" "Tuesday" "Wednesday" "Thursday"
"Friday" "Saturday" "Sunday"))
(setq monvec '("January" "February" "March" "April" "May" "June"
"July" "August" "September" "October" "November"
"December"))
(multiple-value-setq (sec min hour date month year day)
(decode-universal-time
(file-write-date timestamp)))
(setq *yearweek*
(copy-seq
(format nil "~a ~a ~d, ~d at ~2,'0d:~2,'0d:~2,'0d "
(elt dayvec day)
(elt monvec (1- month)) date year hour min sec))))
(setq *yearweek* "no timestamp")))
\end{chunk}
\subsubsection{makelib}
Make will not compare dates across directories.
Rather than copy all of the code.lsp files to the MNT directory
we run this function to compile the files that are out of date
this function assumes that the shell variables INT and MNT are set.
Also of note: on the rt some files (those in the nooptimize list)
need to be compiled without optimize due to compiler bugs
\begin{chunk}{makelib}
(defun makelib (mid out stype btype)
"iterate over the nrlibs, compiling ones that are out of date.
mid is the directory containing code.lsp
out is the directory containing code.o"
(let (libs lspdate odate nooptimize (alphabet #\space))
#+(and :akcl :rt)
(setq nooptimize '("FFCAT-.nrlib" "CHVAR.nrlib" "PFO.nrlib" "SUP.nrlib"
"INTG0.nrlib" "FSPRMELT.nrlib" "VECTOR.nrlib"
"EUCDOM-.nrlib"))
(if (and mid out)
(format t "doing directory on ~s...~%" (concatenate 'string mid "/*"))
(error "makelib:MID=~a OUT=~a~% these are not set properly~%" mid out))
#+:akcl (compiler::emit-fn nil)
#+:akcl (si::chdir mid)
#-:akcl (vmlisp::obey (concatenate 'string "cd " mid))
(setq libs (directory "*.nrlib"))
(unless libs
(format t "makelib:directory of ~a returned NIL~%" mid)
(bye -1))
(princ "checking ")
(dolist (lib libs)
(unless (char= (schar (pathname-name lib) 0) alphabet)
(setq alphabet (schar (pathname-name lib) 0))
(princ alphabet)
(finish-output))
(let (dotlsp doto mntlib intkaf mntkaf intkafdate mntkafdate)
(setq dotlsp
(concatenate 'string mid "/" (file-namestring lib) "/code." stype))
(setq doto
(concatenate 'string out "/" (pathname-name lib) ".nrlib/code." btype))
(setq mntlib
(concatenate 'string out "/" (pathname-name lib) ".nrlib"))
(setq intkaf
(concatenate 'string mid "/" (file-namestring lib) "/index.kaf*"))
(setq mntkaf
(concatenate 'string out "/" (pathname-name lib) ".nrlib/index.kaf*"))
(unless (probe-file mntlib)
(format t "creating directory ~a~%" mntlib)
(vmlisp::obey (concatenate 'string "cp -pr " (namestring lib) " " out))
(when (probe-file (concatenate 'string mntlib "/code." stype))
(delete-file (concatenate 'string mntlib "/code." stype))))
(setq intkafdate (and (probe-file intkaf) (file-write-date intkaf)))
(setq mntkafdate (and (probe-file mntkaf) (file-write-date mntkaf)))
(when intkafdate
(unless (and mntkafdate (> mntkafdate intkafdate))
(format t "~©ing ~s to ~s" intkaf mntkaf)
(vmlisp::obey
(concatenate 'string "cp "
(namestring intkaf) " " (namestring mntkaf)))))
(setq lspdate (and (probe-file dotlsp) (file-write-date dotlsp)))
(setq odate (and (probe-file doto) (file-write-date doto)))
(when lspdate
(unless (and odate (> odate lspdate))
#+(and :akcl :rt)
(if (member (file-namestring lib) nooptimize :test #'string=)
(setq compiler::*speed* 0)
(setq compiler::*speed* 3))
(compile-lib-file dotlsp :output-file doto)))))))
\end{chunk}
\subsubsection{makespad}
Make will not compare dates across directories.
In particular, it cannot compare the algebra files because there
is a one-to-many correspondence. This function will walk over
all of the algebra nrlib files and find all of the spad files
that are out of date and need to be recompiled. This function
creates a file "/tmp/compile.input" to be used later in the
makefile.
Note that the file /tmp/compile.input is not currently used
as algebra source recompiles are not necessarily something
we want done automatically. Nevertheless, in the quest for
quality we check anyway.
\begin{chunk}{makespad}
(defun makespad (src mid stype)
"iterate over the spad files, compiling ones that are out of date.
src is the directory containing .spad
mid is the directory containing code.lsp
out is the directory containing code.o"
(let (mntlibs spadwork (alphabet #\space))
(labels (
(findsrc (mid libname)
"return a string name of the source file given the library file
name (eg PI) as a string"
(let (kaffile index alist)
(setq kaffile
(concatenate 'string mid "/" libname ".nrlib/index.kaf*"))
(with-open-file (kaf kaffile)
(setq index (read kaf))
(file-position kaf index)
(setq alist (read kaf))
(setq index (third (assoc "sourceFile" alist :test #'string=)))
(file-position kaf index)
(pathname-name (pathname (read kaf index)))))))
(format t "makespad:src=~s mid=~s stype=~s~%" src mid stype)
(if (and src mid)
(format t "doing directory on ~s...~%" (concatenate 'string src "/*"))
(error "makespad:SRC=~a MID=~a not set properly~%" src mid))
#+:akcl (si::chdir mid)
#-:akcl (vmlisp::obey (concatenate 'string "cd " mid))
(setq mntlibs (directory "*.nrlib"))
(unless mntlibs
(format t "makespad:directory of ~a returned NIL~%" src)
(bye 1))
(princ "checking ")
(dolist (lib mntlibs)
(unless (char= (schar (pathname-name lib) 0) alphabet)
(setq alphabet (schar (pathname-name lib) 0))
(princ alphabet)
(finish-output))
(let (spad spaddate lsp lspdate)
(setq spad
(concatenate 'string src "/" (findsrc mid (pathname-name lib)) ".spad"))
(setq spaddate
(and (probe-file spad) (file-write-date spad)))
(setq lsp
(concatenate 'string mid "/" (pathname-name lib) ".nrlib/code." stype))
(setq lspdate
(and (probe-file lsp) (file-write-date lsp)))
(cond
((and spaddate lspdate (<= spaddate lspdate)))
((and spaddate lspdate (> spaddate lspdate))
(setq spadwork (adjoin spad spadwork :test #'string=)))
((and spaddate (not lspdate))
(setq spadwork (adjoin spad spadwork :test #'string=)))
((and (not spaddate) lspdate)
(format t "makespad:missing spad file ~a for lisp file ~a~%" spad lsp))
((and (not spaddate) (not lspdate))
(format t "makespad:nrlib ~a exist but is spad ~a and lsp ~a don't~%"
lib spad lsp)))))
(with-open-file (tmp "/tmp/compile.input" :direction :output)
(dolist (spad spadwork)
(format t "~a is out of date~%" spad)
(format tmp ")co ~a~%" spad))))))
\end{chunk}
\subsection{Constructing TAGS}
TAGS are useful for finding functions if you run Emacs. We have a
set of functions that construct TAGS files for Axiom.
\subsubsection{make-tags-file}
Run the etags command on all of the lisp code. Then run the
{\bf spadtags-from-directory} function on the boot code. The
final TAGS file is constructed in the {\bf tmp} directory.
\begin{chunk}{make-tags-file}
(defun make-tags-file ()
#+:gcl (system::chdir "/tmp")
#-:gcl (vmlisp::obey (concatenate 'string "cd " "/tmp"))
(obey (concat "etags " (make-absolute-filename "../../src/interp/*.lisp")))
(spadtags-from-directory "../../src/interp" "boot")
(obey "cat /tmp/boot.TAGS >> /tmp/TAGS"))
\end{chunk}
\subsubsection{spadtags-from-directory}
This function will walk across a directory and call
{\bf spadtags-from-file} on each file.
\begin{chunk}{spadtags-from-directory}
(defun spadtags-from-directory (dir type)
(let* ((direc (make-directory dir))
(pattern (make-pathname :directory (pathname-directory direc)
:name :wild :type type))
(files (directory pattern)))
(with-open-file
(tagstream (concatenate 'string "/tmp/" type ".TAGS") :direction :output
:if-exists :supersede :if-does-not-exist :create)
(dolist (file files (namestring tagstream))
(print (list "processing:" file))
(write-char #\page tagstream)
(terpri tagstream)
(write-string (namestring file) tagstream)
(write-char #\, tagstream)
(princ (spadtags-from-file file) tagstream)
(terpri tagstream)
(with-open-file (stream "/tmp/*TAGS")
(do ((line (read-line stream nil nil)
(read-line stream nil nil)))
((null line) nil)
(write-line line tagstream)))))))
\end{chunk}
\subsubsection{spadtags-from-file}
This function knows how to find function names in {\bf boot} code
so we can add them to the TAGS file using standard etags format.
\begin{chunk}{spadtags-from-file}
(defun spadtags-from-file (spadfile)
(with-open-file (tagstream "/tmp/*TAGS" :direction :output
:if-exists :supersede :if-does-not-exist :create)
(with-open-file (stream spadfile)
(do ((char-count 0 (file-position stream))
(line (read-line stream nil nil) (read-line stream nil nil))
(line-count 1 (1+ line-count)))
((null line) (file-length tagstream))
(if (/= (length line) 0)
(let ((firstchar (elt line 0)) (end nil)
(len (length line)))
(cond ((member firstchar '(#\space #\{ #\} #\tab )
:test #'char= ) "skip")
((string= line ")abb" :end1 (min 4 len))
(setq end (position #\space line :from-end t
:test-not #'eql)
end (and end (position #\space line :from-end t
:end end)))
(write-tag-line line tagstream end
line-count char-count))
((char= firstchar #\)) "skip")
((and (> len 1) (string= line "--" :end1 2)) "skip")
((and (> len 1) (string= line "++" :end1 2)) "skip")
((search "==>" line) "skip")
((and (setq end (position #\space line)
end (or (position #\( line :end end) end)
end (or (position #\: line :end end) end)
end (or (position #\[ line :end end) end))
(equal end 0)) "skip")
((position #\] line :end end) "skip")
((string= line "SETANDFILEQ" :end1 end) "skip")
((string= line "EVALANDFILEACTQ" :end1 end) "skip")
(t (write-tag-line line tagstream
(if (numberp end) (+ end 1) end)
line-count char-count)) )))))))
\end{chunk}
\subsubsection{write-tag-line}
This function knows how to write a single line into a TAGS file
using the etags file format.
\begin{chunk}{write-tag-line}
(defun write-tag-line (line tagstream endcol line-count char-count)
(write-string line tagstream :end endcol)
(write-char #\rubout tagstream)
(princ line-count tagstream)
(write-char #\, tagstream)
(princ char-count tagstream)
(terpri tagstream))
\end{chunk}
\subsubsection{blankcharp}
This is a trivial predicate for calls to {\bf position-if-not} in the
{\bf findtag} function.
\begin{chunk}{blankcharp}
(defun blankcharp (c) (char= c #\Space))
\end{chunk}
\subsubsection{findtag}
The {\bf findtag} function is a user-level function to figure out
which file contains a given tag. This is sometimes useful if Emacs
is not around or TAGS are not loaded.
\begin{chunk}{findtag}
(defun findtag (tag &optional (tagfile (concat $spadroot "/../../src/interp/TAGS")) )
;; tag is an identifier
(with-open-file (tagstream tagfile)
(do ((tagline (read-line tagstream nil nil)
(read-line tagstream nil nil))
(*package* (symbol-package tag))
(sourcefile)
(stringtag (string tag))
(pos)
(tpos)
(type))
((null tagline) ())
(cond ((char= (char tagline 0) #\Page)
(setq tagline (read-line tagstream nil nil))
(setq sourcefile (subseq tagline 0
(position #\, tagline)))
(setq type (pathname-type sourcefile)))
((string= type "lisp")
(if (match-lisp-tag tag tagline)
(return (cons sourcefile tagline))))
((> (mismatch ")abb" tagline) 3)
(setq pos (position #\Space tagline :start 3))
(setq pos (position-if-not #'blankcharp tagline
:start pos))
(setq pos (position #\Space tagline :start pos))
(setq pos (position-if-not #'blankcharp tagline
:start pos))
(setq tpos (mismatch stringtag tagline :start2 pos))
(if (and (= tpos (length (string tag)))
(member (char tagline (+ pos tpos)) '(#\Space #\Rubout)))
(return (cons sourcefile tagline))))
((setq pos (mismatch stringtag tagline))
(if (and (= pos (length stringtag))
(> (length tagline) pos)
(member (char tagline pos)
'( #\Space #\( #\:) ))
(return (cons sourcefile tagline))))))))
\end{chunk}
\subsubsection{match-lisp-tag}
The {\bf match-lisp-tag} function is used by {\bf findtag}. This
function assumes that \\ can only appear as first character of name.
\begin{chunk}{match-lisp-tag}
(defun match-lisp-tag (tag tagline &optional (prefix nil)
&aux (stringtag (string tag)) pos tpos)
(when (and (if prefix
(= (mismatch prefix tagline :test #'char-equal)
(length prefix))
t)
(numberp (setq pos (position #\Space tagline)))
(numberp (setq pos (position-if-not #'blankcharp tagline
:start pos))))
(if (char= (char tagline pos) #\') (incf pos))
(if (member (char tagline pos) '( #\\ #\|))
(setq tpos (1+ pos))
(setq tpos pos))
(and (= (mismatch stringtag tagline :start2 tpos :test #'char-equal)
(length stringtag))
(eq tag (read-from-string tagline nil nil :start pos))) ))
\end{chunk}
\subsection{Translated Boot functions}
\subsubsection{string2SpadTree}
\begin{chunk}{string2SpadTree}
(DEFUN |string2SpadTree| (LINE)
(DECLARE (SPECIAL LINE))
(if (and (> (LENGTH LINE) 0) (EQ (CHAR LINE 0) #\) ))
(|processSynonyms|))
(ioclear)
(LET* ((BOOT-LINE-STACK (LIST (CONS 1 LINE)))
($BOOT NIL)
($SPAD T)
(XTOKENREADER 'GET-BOOT-TOKEN)
(LINE-HANDLER 'NEXT-BOOT-LINE)
(PARSEOUT (PROG2 (|PARSE-NewExpr|) (POP-STACK-1))))
(DECLARE (SPECIAL BOOT-LINE-STACK $BOOT $SPAD XTOKENREADER LINE-HANDLER))
PARSEOUT))
\end{chunk}
\section{License}
\begin{verbatim}
;; Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd.
;; All rights reserved.
;;
;; Redistribution and use in source and binary forms, with or without
;; modification, are permitted provided that the following conditions are
;; met:
;;
;; - Redistributions of source code must retain the above copyright
;; notice, this list of conditions and the following disclaimer.
;;
;; - Redistributions in binary form must reproduce the above copyright
;; notice, this list of conditions and the following disclaimer in
;; the documentation and/or other materials provided with the
;; distribution.
;;
;; - Neither the name of The Numerical ALgorithms Group Ltd. nor the
;; names of its contributors may be used to endorse or promote products
;; derived from this software without specific prior written permission.
;;
;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
;; IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
;; TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
;; PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
;; OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
;; EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
;; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
;; PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
;; LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\end{verbatim}
\begin{chunk}{*}
(in-package "BOOT")
(export '($spadroot $directory-list $current-directory reroot
make-absolute-filename |$msgDatabaseName| |$defaultMsgDatabaseName|))
\getchunk{our-write-date}
\getchunk{make-directory}
\getchunk{interp-make-directory}
\getchunk{bin-path}
\getchunk{load-directory}
\getchunk{compspadfiles}
\getchunk{recompile-all-algebra-files}
\getchunk{fe}
\getchunk{fc}
\getchunk{recompile-directory}
\getchunk{recompile-file-if-necessary}
\getchunk{recompile-all-files}
\getchunk{recompile-lib-directory}
\getchunk{recompile-all-libs}
\getchunk{recompile-nrlib-if-necessary}
\getchunk{lift-nrlib-name}
\getchunk{retranslate-directory}
\getchunk{retranslate-file-if-necessary}
\getchunk{make-tags-file}
\getchunk{spadtags-from-directory}
\getchunk{spadtags-from-file}
\getchunk{write-tag-line}
\getchunk{blankcharp}
\getchunk{findtag}
\getchunk{match-lisp-tag}
\getchunk{compile-boot-file}
\getchunk{translate}
\getchunk{translist}
\getchunk{make-depsys}
\getchunk{boottocl}
(in-package "BOOT")
\getchunk{parse-functions}
\getchunk{comp-functions}
\getchunk{browse-functions}
\getchunk{translate-functions}
\getchunk{debug-functions}
\getchunk{anna-functions}
\getchunk{nagbr-functions}
\getchunk{setBootAutloadProperties}
\getchunk{boot-load}
\getchunk{setBootAutoLoadProperty}
\getchunk{mkBootAutoLoad}
\getchunk{build-interpsys}
\getchunk{defun start}
\getchunk{defun initializeSystemCommands}
\getchunk{setNAGBootAutloadProperties}
\getchunk{get-NAG-chapter}
\getchunk{nag-files}
\getchunk{chapter-name}
\getchunk{build-depsys}
\getchunk{string2SpadTree}
;; the following are for conditional reading
#+:ieee-floating-point (setq $ieee t)
#-:ieee-floating-point (setq $ieee nil)
(setq |$opSysName| '"shell")
(setq |$machineType| (machine-type))
; spad-clear-input patches around fact that akcl clear-input leaves newlines chars
(defun spad-clear-input (st) (clear-input st) (if (listen st) (read-char st)))
\getchunk{yearweek}
(defun sourcepath (f)
"find the sourcefile in the system directories"
(let (axiom algebra naglink)
(setq axiom (|getEnv| "AXIOM"))
(setq algebra (concatenate 'string axiom "/../../src/algebra/" f ".spad"))
(setq naglink (concatenate 'string axiom "/../../src/naglink/" f ".spad"))
(cond
((probe-file algebra) algebra)
((probe-file naglink) naglink)
('else nil))))
(defun srcabbrevs (sourcefile)
"read spad source files and return the constructor names and abbrevs"
(let (expr point mark names longnames)
(catch 'done
(with-open-file (in sourcefile)
(loop
(setq expr (read-line in nil 'done))
(when (eq expr 'done) (throw 'done nil))
(when (and (> (length expr) 4) (string= ")abb" (subseq expr 0 4)))
(setq expr (string-right-trim '(#\space #\tab) expr))
(setq point (position #\space expr :from-end t :test #'char=))
(push (subseq expr (1+ point)) longnames)
(setq expr (string-right-trim '(#\space #\tab)
(subseq expr 0 point)))
(setq mark (position #\space expr :from-end t))
(push (subseq expr (1+ mark)) names)))))
(values longnames names)))
#+(and :AKCL (not :dos))
(in-package "COMPILER")
#+(and :AKCL (not :dos))
(defun gazonk-name ( &aux tem)
"return the name of the intermediate compiler file"
(dotimes (i 1000)
(setq tem (merge-pathnames (format nil "/tmp/gazonk~d.lsp" i)))
(unless (probe-file tem)
(return-from gazonk-name (pathname tem))))
(error "1000 gazonk names used already!"))
(in-package "BOOT")
(defun |tr| (fn)
(|oldCompilerAutoloadOnceTrigger|)
(|browserAutoloadOnceTrigger|)
(|spad2AsTranslatorAutoloadOnceTrigger|)
(|convertSpadFile| fn) )
\getchunk{makelib}
\getchunk{makespad}
\end{chunk}
\eject
\begin{thebibliography}{99}
\bibitem{1} nothing
\end{thebibliography}
\end{document}
|