unused.6 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. <USE-TOTAL "ASYLUM">
  2. <USE "MADMAN">
  3. <FLOAD "AR2:TAA;SSNAME NBIN">
  4. <DEFINE GUNUSED ("OPTIONAL" (ENABLE T)
  5. "AUX" (DC ,TVASS) UV HI (LOSSTABLE ,LOSSTABLE) (UV1 ,DUV1)
  6. (SP <OR <AND <GASSIGNED? MOBYSPACE>
  7. ,MOBYSPACE>
  8. <SETG MOBYSPACE <AFIND 4>>>))
  9. #DECL ((DC) ASYLUM (HI) FIX (UV UV1) <UVECTOR [REST <PRIMTYPE WORD>]>
  10. (LOSSTABLE) <LIST [REST TIME STRING FIX FIX]> (SP) SPACE
  11. (ENABLE) <OR ATOM FALSE>)
  12. <ALLOC-MAP .DC>
  13. <SET HI
  14. <CHTYPE <1 <GET-LOC <+ ,HIGHID <* <ALLOCPAGE .DC> 1024>> .UV1>> FIX>>
  15. <GUNASSIGN MOBY>
  16. <ARESET .SP>
  17. <SETG MUV <SET UV <AIUVECTOR .SP .HI 0>>>
  18. <MARK-CHAIN ,LOMAIL .UV .DC>
  19. <SSNAME <STRTOX "MARKQ">>
  20. <MARK-Q-CHAIN .UV .DC>
  21. <REPEAT (LUBLK)
  22. <COND (<EMPTY? .LOSSTABLE> <RETURN>)>
  23. <SET LUBLK <3 .LOSSTABLE>>
  24. <SSNAME <1 .LOSSTABLE>>
  25. <MARK-UBLOCK .LUBLK .UV>
  26. <MARK-CHAIN <+ .LUBLK ,ANEXT> .UV .DC>
  27. <MARK-CHAIN <+ .LUBLK ,MNEXT> .UV .DC>
  28. <SET LOSSTABLE <REST .LOSSTABLE 4>>>
  29. <SUBSTRUC <IUVECTOR 27 1> 0 27 .UV>
  30. <PRESULT .UV .DC .ENABLE>>
  31. <DEFINE MARK-CHAIN (START BUCKET DC)
  32. #DECL ((START) FIX (BUCKET) <UVECTOR [REST FIX]> (DC) ASYLUM)
  33. <REPEAT ()
  34. <COND (<0? <SET START <CHTYPE <DATA-READW .DC .START> FIX>>>
  35. <RETURN>)
  36. (T
  37. <PUT .BUCKET .START <+ <NTH .BUCKET .START> 1>>)>>>
  38. <DEFINE MARK-Q-CHAIN (BUCKET DC
  39. "AUX" Q S (START ,LOWQUES) (TVS <ARESET ,QSPACE>))
  40. #DECL ((BUCKET) <UVECTOR [REST FIX]> (DC) ASYLUM (S START) FIX
  41. (TVS) SPACE (Q) VECTOR)
  42. <REPEAT ()
  43. <COND (<0? <SET START <CHTYPE <DATA-READW .DC .START> FIX>>>
  44. <RETURN>)
  45. (T
  46. <SET Q <DATA-AREAD .DC .START <ARESET .TVS>>>
  47. <SET S <QSCORE .Q>>
  48. <PUT .BUCKET .START <+ <NTH .BUCKET .START> 1>>
  49. <COND (<AND <0? .S> <==? <QTYPE .Q> ,$TSIMPLE>>)
  50. (T <PUT .BUCKET .S <+ <NTH .BUCKET .S> 1>>)>)>>>
  51. <DEFINE MARK-UBLOCK (LUBLK UV "AUX" (MARKS '![1 1 1 1 1 1 1 1 1 1 1 1]))
  52. #DECL ((LUBLK) FIX (UV MARKS) <UVECTOR [REST FIX]>)
  53. <SUBSTRUC .MARKS 0 12 <REST .UV <- .LUBLK 1>>>>
  54. <DEFINE PRESULT (UV DC ENABLE "AUX" MDATA (CT 0) (ULIST (0)) POINT
  55. (FLIST (0)) CLIST)
  56. #DECL ((ENABLE) <OR ATOM FALSE> (CLIST ULIST FLIST) <LIST [REST FIX]>
  57. (UV) <UVECTOR [REST FIX]> (DC) ASYLUM (CT POINT) FIX
  58. (MDATA) <UVECTOR [4 <PRIMTYPE WORD>]>)
  59. <MARK-FREE .UV .DC>
  60. <MAPF <>
  61. <FUNCTION (X)
  62. #DECL ((X) FIX)
  63. <SET CT <+ .CT 1>>
  64. <COND
  65. (<0? .X>
  66. <SET MDATA <DATA-FIND .DC .CT>>
  67. <COND (<L? <SET POINT <CHTYPE <3 .MDATA> FIX>> 0>
  68. <SET POINT <CHTYPE <ANDB .POINT *777777*> FIX>>
  69. <SET CLIST .FLIST>)
  70. (T
  71. <SET CLIST .ULIST>
  72. <SET POINT <CHTYPE <4 .MDATA> FIX>>)>
  73. <COND
  74. (<NOT .ENABLE> <PUTREST .CLIST (.CT !<REST .CLIST>)>)
  75. (<EMPTY? <REST .CLIST>> <PUTREST .CLIST (.CT <- .POINT>)>)
  76. (<REPEAT (TEMP (NL <REST .CLIST>) (OLD .CLIST) (FCT <- .CT>) (WON2 <>)
  77. (WON1 <>) (LASTM .CLIST) TLIST)
  78. #DECL ((TEMP FCT) FIX (TLIST LASTM NL OLD FCT) <LIST [REST FIX]>
  79. (WON2 WON1) <OR <LIST [REST FIX]> FALSE>)
  80. <COND (<AND <==? <SET TEMP <1 .NL>> .POINT> <G? .POINT 0>>
  81. <COND (.WON2
  82. <PUTREST .OLD ()>
  83. <SET TLIST <REST .WON2 2>>
  84. <PUTREST .WON2 .NL>
  85. <PUTREST <REST .NL <- <LENGTH .NL> 1>> .TLIST>
  86. <RETURN>)
  87. (T <PUTREST .OLD (.CT !.NL)> <SET WON1 .OLD>)>)
  88. (<==? .TEMP .FCT>
  89. <COND (.WON1
  90. <PUTREST .OLD <REST .WON1>>
  91. <PUTREST .WON1 <REST .LASTM>>
  92. <PUTREST .LASTM <REST .NL>>
  93. <RETURN>)
  94. (<AND <NOT <LENGTH? .NL 1>>
  95. <==? <2 .NL> .POINT>>
  96. <PUTREST .OLD (.CT !<REST .NL>)>
  97. <RETURN>)
  98. (T
  99. <PUTREST .OLD (.CT <- .POINT> !<REST .NL>)>
  100. <SET WON2 <REST .OLD>>)>)>
  101. <SET OLD .NL>
  102. <COND (<L=? .TEMP 0> <SET LASTM .NL>)>
  103. <COND (<EMPTY? <SET NL <REST .NL>>>
  104. <AND <NOT .WON1>
  105. <NOT .WON2>
  106. <PUTREST .CLIST
  107. (.CT <- .POINT> !<REST .CLIST>)>>
  108. <RETURN>)>>)>
  109. <PRINC "Unused item #">
  110. <PRINC .CT>
  111. <CRLF>)
  112. (<L? .X 0>)
  113. (<G? .X 1>
  114. <PRINC "Item #">
  115. <PRINC .CT>
  116. <PRINC " used ">
  117. <PRINC .X>
  118. <PRINC " times.">
  119. <CRLF>)>>
  120. .UV>
  121. <SETG ULIST
  122. <COND (.ENABLE
  123. <REPEAT (TEMP (OLD .ULIST) (NLIST ()) (UL .ULIST)
  124. (NL <REST .ULIST>))
  125. #DECL ((NLIST) <LIST [REST <LIST [REST FIX]>]>
  126. (UL NL) <LIST [REST FIX]> (TEMP) FIX)
  127. <COND (<EMPTY? .NL>
  128. <SET NLIST (<REST .UL> !.NLIST)>
  129. <RETURN .NLIST>)
  130. (<L=? <SET TEMP <1 .NL>> 0>
  131. <COND (<EMPTY? <REST .NL>>
  132. <PUTREST .OLD ()>
  133. <SET NLIST (<REST .UL> !.NLIST)>
  134. <RETURN .NLIST>)
  135. (T
  136. <PUTREST .OLD ()>
  137. <SET NLIST (<REST .UL> !.NLIST)>
  138. <SET UL .NL>)>)>
  139. <SET OLD .NL>
  140. <SET NL <REST .NL>>>)
  141. (T <REST .ULIST>)>>
  142. <SETG FLIST
  143. <COND (.ENABLE
  144. <REPEAT (TEMP (OLD .FLIST) (NLIST ()) (UL .FLIST)
  145. (NL <REST .FLIST>))
  146. #DECL ((NLIST) <LIST [REST <LIST [REST FIX]>]>
  147. (UL NL) <LIST [REST FIX]> (TEMP) FIX)
  148. <COND (<EMPTY? .NL>
  149. <SET NLIST (<REST .UL> !.NLIST)>
  150. <RETURN .NLIST>)
  151. (<L=? <SET TEMP <1 .NL>> 0>
  152. <COND (<EMPTY? <REST .NL>>
  153. <PUTREST .OLD ()>
  154. <SET NLIST (<REST .UL> !.NLIST)>
  155. <RETURN .NLIST>)
  156. (T
  157. <PUTREST .OLD ()>
  158. <SET NLIST (<REST .UL> !.NLIST)>
  159. <SET UL .NL>)>)>
  160. <SET OLD .NL>
  161. <SET NL <REST .NL>>>)
  162. (T <REST .FLIST>)>>
  163. <UVECTOR ,ULIST ,FLIST>>
  164. <SETG AUV1 <UVECTOR #WORD *0*>>
  165. <GDECL (AUV1) <UVECTOR <PRIMTYPE WORD>>>
  166. <DEFINE MARK-FREE (UV DC "AUX" FOO)
  167. #DECL ((UV) <UVECTOR [REST FIX]> (DC) ASYLUM (FOO) FIX)
  168. <SSNAME <STRTOX "MARKF">>
  169. <SET FOO <CHTYPE <1 <GET-LOC <+ ,IDCHAIN <* 1024 <ALLOCPAGE .DC>>>
  170. ,AUV1>>
  171. FIX>>
  172. <REPEAT (TEMP Q) #DECL ((TEMP) FIX (Q) <UVECTOR [REST <PRIMTYPE WORD>]>)
  173. <AND <G=? .FOO 0> <RETURN>>
  174. <SET FOO <CHTYPE <ANDB .FOO #WORD *000000777777*> FIX>>
  175. <COND (<0? <SET TEMP <NTH .UV .FOO>>>
  176. <PUT .UV .FOO -1>)
  177. (<L? .TEMP 0>
  178. <ERROR CIRCULAR-FREE-CHAIN .FOO>)
  179. (T
  180. <PRINC "Free item #">
  181. <PRINC .FOO>
  182. <PRINC " used ">
  183. <PRINC .TEMP>
  184. <PRINC " times.">
  185. <CRLF>)>
  186. <SET Q <DATA-FIND .DC .FOO>>
  187. <SET FOO <CHTYPE <3 .Q> FIX>>>>
  188. <DEFINE LISTU ("OPTIONAL" (DC ,TVASS) (SP ,ASPACE)
  189. "AUX" (ALL <* 1024 <ALLOCPAGE .DC>>) HI V)
  190. #DECL ((DC) ASYLUM (ALL HI) FIX (V) UVECTOR (SP) SPACE)
  191. <SET HI <CHTYPE <1 <GET-LOC <+ .ALL ,HIGHID> ,DUV1>> FIX>>
  192. <SET V <AIUVECTOR ,MOBYSPACE .HI 0>>
  193. <REPEAT ((VEC .V) (N 1) FX)
  194. #DECL ((VEC) UVECTOR (N FX) FIX)
  195. <SET FX <CHTYPE <DATA-READW .DC .N> FIX>>
  196. <COND (<AND <G? .FX 0> <L? .FX .HI>>
  197. <PUT .VEC .FX 1>)>
  198. <AND <==? .N .HI> <RETURN>>
  199. <SET N <+ .N 1>>>
  200. <MAPR <>
  201. <FUNCTION (X "AUX" FOO)
  202. #DECL ((X) UVECTOR (FOO) FIX)
  203. <COND (<1? <1 .X>>)
  204. (<DATA-AREAD .DC <SET FOO <- <LENGTH .V> <LENGTH .X> -1>>
  205. <ARESET .SP>>
  206. <COND (<OR <MEMQ <- .FOO 3> ,LOSSTABLE>
  207. <MEMQ <- .FOO 6> ,LOSSTABLE>>)
  208. (<PRINC "
  209. Non-referenced object #">
  210. <PRIN1 .FOO>)>)>>
  211. .V>
  212. ,NULL>