load.red 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. %
  2. % LOAD.RED - New version of LOAD function, with search path
  3. %
  4. % Author: Eric Benson
  5. % Symbolic Computation Group
  6. % Computer Science Dept.
  7. % University of Utah
  8. % Date: 2 April 1982
  9. % Copyright (c) 1982 University of Utah
  10. %
  11. % <PSL.KERNEL>LOAD.RED.15, 7-Mar-83 13:42:15, Edit by KESSLER
  12. % Change loaddirectories for Apollo to ~p/l/
  13. % Edit by MLG, 6 March 1983.
  14. % Corrected bug in Fix to IMPORTS
  15. % Edit by Cris Perdue, 17 Feb 1983 1201-PST
  16. % Corrected use of *verboseload in top of load1
  17. % MLG, 15 Feb 1983
  18. % Added !*VERBOSELOAD and !*PRINTLOADNAMES
  19. % M. Griss, 9 Feb 1983
  20. % Changed LoadDirectories!* for the VAX to refer to "$pl/"
  21. % <PSL.NEW>-SOURCE-CHANGES.LOG.15, 15-Dec-82 15:45:55, Edit by PERDUE
  22. % LOAD will now handle ".sl" extension
  23. % <PSL.KERNEL>LOAD.RED.7, 1-Dec-82 16:07:38, Edit by BENSON
  24. % Added if_system(HP9836, ...)
  25. % EDIT by GRISS 28 Oct 1982: Added EvLoad to Imports
  26. % <PSL.KERNEL>LOAD.RED.4, 4-Oct-82 09:46:54, Edit by BENSON
  27. % Moved addition of U to Options!* to avoid double load
  28. % <PSL.KERNEL>LOAD.RED.3, 30-Sep-82 11:57:03, Edit by BENSON
  29. % Removed "FOO already loaded" message
  30. % <PSL.KERNEL>LOAD.RED.2, 22-Sep-82 15:38:48, Edit by BENSON
  31. % Added ReLoad, changed VAX search path
  32. fluid '(LoadDirectories!* % list of strings to append to front
  33. LoadExtensions!* % a-list of (str . fn) to append to end
  34. % and apply
  35. PendingLoads!* % created by Imports, aux loads
  36. !*Lower % print IDs in lowercase, for building
  37. % filename for Unix
  38. !*RedefMSG % controls printing of redefined
  39. % function message
  40. !*UserMode % Controls query of user for redefining
  41. % system functions
  42. !*InsideLoad % Controls "already loaded" message
  43. !*VerboseLoad % Print REDEFs and LOAD file names
  44. !*PrintLoadNames % Print Names of files loading
  45. Options!*); % list of modules already loaded
  46. if_system(Apollo,
  47. LoadDirectories!* := '("" "~p/l/"));
  48. if_system(Tops20,
  49. LoadDirectories!* := '("" "pl:"));
  50. if_system(Unix,
  51. LoadDirectories!* := '("" "$pll/" "$pl/"));
  52. if_system(HP9836,
  53. LoadDirectories!* := '("" "pl:"));
  54. LoadExtensions!* := '((".b" . FaslIN) (".lap" . LapIN) (".sl" . LapIN));
  55. !*VerboseLoad :=NIL;
  56. !*PrintLoadNames := NIL;
  57. macro procedure Load U;
  58. list('EvLoad, MkQuote cdr U);
  59. lisp procedure EvLoad U;
  60. for each X in U do Load1 X;
  61. macro procedure ReLoad U;
  62. list('EvReLoad, MkQuote cdr U);
  63. lisp procedure EvReLoad U;
  64. << for each X in U do Options!* := Delete(X, Options!*);
  65. EvLoad U >>;
  66. lisp procedure Load1 U;
  67. begin scalar !*RedefMSG, !*UserMode, LD, LE, F, Found;
  68. If !*VerBoseLoad then !*RedefMSG := T;
  69. return if U memq Options!* then
  70. if !*VerboseLoad then
  71. ErrorPrintF("*** %w already loaded", U)
  72. else NIL
  73. else
  74. (lambda(!*InsideLoad);
  75. << LD := LoadDirectories!*;
  76. (lambda (!*Lower);
  77. while not null LD and not Found do
  78. << LE := LoadExtensions!*;
  79. while not null LE and not Found do
  80. << if FileP(F := BldMsg("%w%w%w", first LD, U, car first LE)) then
  81. Found := cdr first LE; % Found is function to apply
  82. LE := rest LE >>;
  83. LD := rest LD >>)(T);
  84. if not Found then
  85. StdError BldMsg("%r load module not found", U)
  86. else
  87. << Options!* := U . Options!*;
  88. If !*VerboseLoad or !*PrintLoadNames
  89. then ErrorPrintf("*** loading %w%n",F);
  90. Apply(Found, list F);
  91. while not null PendingLoads!* do
  92. << Found := car PendingLoads!*;
  93. PendingLoads!* := cdr PendingLoads!*;
  94. Load1 Found >> >> >>)(T);
  95. end;
  96. lisp procedure Imports L;
  97. if !*InsideLoad then
  98. <<for each X in L do
  99. if not (X memq Options!* or X memq PendingLoads!*) then
  100. PendingLoads!* := Append(PendingLoads!*, list X)>>
  101. else EvLoad L;
  102. END;