printers.red 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525
  1. %
  2. % PRINTERS.RED - Printing functions for various data types
  3. %
  4. % Author: Eric Benson
  5. % Symbolic Computation Group
  6. % Computer Science Dept.
  7. % University of Utah
  8. % Date: 27 August 1981
  9. % Copyright (c) 1981 University of Utah
  10. %
  11. % <PSL.KERNEL>PRINTERS.RED.17, 7-Mar-83 11:53:59, Edit by KESSLER
  12. % Change Channelwriteblankoreol to check linelength = 0 also.
  13. % Edit by MLGriss, 11:31am Saturday, 5 February 1983
  14. % Fix ChannelWriteBitstring to put out a single 0 if needed
  15. % Fixed to handle largest NEGATIVE number correctly
  16. % Used to get ------, since -(largest neg) NOT=largestPOS
  17. % <PSL.KERNEL>PRINTERS.RED.14, 31-Jan-83 15:45:30, Edit by PERDUE
  18. % Fix to printing of EVECTORs
  19. % Edit by Cris Perdue, 29 Jan 1983 1620-PST
  20. % Removed definition of EVecInf (both compile- and load-time)
  21. % Edit by Cris Perdue, 27 Jan 1983 1436-PST
  22. % Put in Kessler's change so CheckLineFit won't write EOL if LineLength = 0
  23. % <PSL.KERNEL>PRINTERS.RED.11, 10-Jan-83 13:58:14, Edit by PERDUE
  24. % Added some code to handle EVectors, especially to represent OBJECTs
  25. % <PSL.KERNEL>PRINTERS.RED.10, 21-Dec-82 15:24:18, Edit by BENSON
  26. % Changed order of tests in WriteInteger so that -ive hex #s are done right
  27. % <PSL.KERNEL>PRINTERS.RED.9, 4-Oct-82 10:04:34, Edit by BENSON
  28. % Added PrinLength and PrinLevel
  29. % <PSL.KERNEL>PRINTERS.RED.3, 23-Sep-82 13:16:20, Edit by BENSON
  30. % Look for # of args in code pointer, changed : to space in #<...> stuff
  31. % <PSL.INTERP>PRINTERS.RED.12, 2-Sep-82 09:01:31, Edit by BENSON
  32. % (QUOTE x y) prints correctly, not as 'x
  33. % <PSL.INTERP>PRINTERS.RED.11, 4-May-82 20:31:32, Edit by BENSON
  34. % Printers keep tags on, for Emode GC
  35. % <PSL.VAX-INTERP>PRINTERS.RED.6, 18-Feb-82 16:30:12, Edit by BENSON
  36. % Added printer for unbound, changed code to #<Code:xx>
  37. % <PSL.VAX-INTERP>PRINTERS.RED.2, 20-Jan-82 02:11:16, Edit by GRISS
  38. % fixed prining of zero length vectors
  39. % <PSL.VAX-INTERP>PRINTERS.RED.1, 15-Jan-82 14:27:13, Edit by BENSON
  40. % Changed for new integer tags
  41. % <PSL.INTERP>PRINTERS.RED.13, 7-Jan-82 22:47:40, Edit by BENSON
  42. % Made (QUOTE xxx) print as 'xxx
  43. % <PSL.INTERP>PRINTERS.RED.12, 5-Jan-82 21:37:41, Edit by BENSON
  44. % Changed OBase to OutputBase!*
  45. fluid '(OutputBase!* % current output base
  46. PrinLength % length of structures to print
  47. PrinLevel % level of recursion to print
  48. CurrentScanTable!*
  49. IDEscapeChar!*
  50. !*Lower); % print IDs with uppercase chars lowered
  51. global '(LispScanTable!*);
  52. LoadTime
  53. << OutputBase!* := 10;
  54. IDEscapeChar!* := 33; % (char !!)
  55. CurrentScanTable!* := LispScanTable!* >>; % so TokenTypeOfChar works right
  56. on SysLisp;
  57. CompileTime <<
  58. syslsp smacro procedure UpperCaseP Ch;
  59. Ch >= char A and Ch <= char Z;
  60. syslsp smacro procedure LowerCaseP Ch;
  61. Ch >= char !a and Ch <= char !z;
  62. syslsp smacro procedure RaiseChar Ch;
  63. (Ch - char !a) + char A;
  64. syslsp smacro procedure LowerChar Ch;
  65. (Ch - char A) + char !a;
  66. >>;
  67. CompileTime flag('(CheckLineFit WriteNumber1 ChannelWriteBitString),
  68. 'InternalFunction);
  69. %. Writes EOL first if given Len causes max line length to be exceeded
  70. syslsp procedure CheckLineFit(Len, Chn, Fn, Itm);
  71. << if (LinePosition[Chn] + Len > MaxLine[Chn]) and (MaxLine[Chn] > 0) then
  72. ChannelWriteChar(Chn, char EOL);
  73. IDApply2(Chn, Itm, Fn) >>;
  74. syslsp procedure ChannelWriteString(Channel, Strng);
  75. %
  76. % Strng may be tagged or not, but it must have a length field accesible
  77. % by StrLen.
  78. %
  79. begin scalar UpLim;
  80. UpLim := StrLen StrInf Strng;
  81. for I := 0 step 1 until UpLim do
  82. ChannelWriteChar(Channel, StrByt(StrInf Strng, I));
  83. end;
  84. syslsp procedure WriteString S;
  85. ChannelWriteString(LispVar OUT!*, S);
  86. internal WString DigitString = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  87. internal WString WriteNumberBuffer[40];
  88. syslsp procedure ChannelWriteSysInteger(Channel, Number, Radix);
  89. begin scalar Exponent,N1;
  90. return if (Exponent := SysPowerOf2P Radix) then
  91. ChannelWriteBitString(Channel, Number, Radix - 1, Exponent)
  92. else if Number < 0 then
  93. << ChannelWriteChar(Channel, char '!-);
  94. WriteNumber1(Channel,-(Number/Radix),Radix); % To catch largest NEG
  95. ChannelWriteChar(Channel,
  96. StrByt(DigitString, - MOD(Number, Radix))) >>
  97. else if Number = 0 then ChannelWriteChar(Channel, char !0)
  98. else WriteNumber1(Channel, Number, Radix);
  99. end;
  100. syslsp procedure WriteNumber1(Channel, Number, Radix);
  101. if Number = 0 then Channel
  102. else
  103. << WriteNumber1(Channel, Number / Radix, Radix);
  104. ChannelWriteChar(Channel,
  105. StrByt(DigitString, MOD(Number, Radix))) >>;
  106. syslsp procedure ChannelWriteBitString(Channel, Number, DigitMask, Exponent);
  107. if Number = 0 then ChannelWriteChar(Channel,char !0)
  108. else ChannelWriteBitStrAux(Channel, Number, DigitMask, Exponent);
  109. syslsp procedure ChannelWriteBitStrAux(Channel, Number, DigitMask, Exponent);
  110. if Number = 0 then Channel % Channel means nothing here
  111. else % just trying to fool the compiler
  112. << ChannelWriteBitStrAux(Channel,
  113. LSH(Number, -Exponent),
  114. DigitMask,
  115. Exponent);
  116. ChannelWriteChar(Channel,
  117. StrByt(DigitString,
  118. LAND(Number, DigitMask))) >>;
  119. syslsp procedure WriteSysInteger(Number, Radix);
  120. ChannelWriteSysInteger(LispVar OUT!*, Number, Radix);
  121. syslsp procedure ChannelWriteFixnum(Channel, Num);
  122. ChannelWriteInteger(Channel, FixVal FixInf Num);
  123. syslsp procedure ChannelWriteInteger(Channel, Num);
  124. begin scalar CurrentBase;
  125. if (CurrentBase := LispVar OutputBase!*) neq 10 then
  126. << ChannelWriteSysInteger(Channel, CurrentBase, 10);
  127. ChannelWriteChar(Channel, char !#) >>;
  128. ChannelWriteSysInteger(Channel,
  129. Num,
  130. CurrentBase);
  131. end;
  132. syslsp procedure ChannelWriteSysFloat(Channel, FloatPtr);
  133. begin scalar Ch, ChIndex;
  134. WriteFloat(WriteNumberBuffer, FloatPtr);
  135. ChannelWriteString(Channel, WriteNumberBuffer);
  136. end;
  137. syslsp procedure ChannelWriteFloat(Channel, LispFloatPtr);
  138. ChannelWriteSysFloat(Channel, FloatBase FltInf LispFloatPtr);
  139. syslsp procedure ChannelPrintString(Channel, Strng);
  140. begin scalar Len, Ch;
  141. ChannelWriteChar(Channel, char !");
  142. Len := StrLen StrInf Strng;
  143. for I := 0 step 1 until Len do
  144. << Ch := StrByt(StrInf Strng, I);
  145. if Ch eq char !" then ChannelWriteChar(Channel, char !");
  146. ChannelWriteChar(Channel, Ch) >>;
  147. ChannelWriteChar(Channel, char !");
  148. end;
  149. syslsp procedure ChannelWriteID(Channel, Itm);
  150. if not LispVar !*Lower then
  151. ChannelWriteString(Channel, SymNam IDInf Itm)
  152. else begin scalar Ch, Len;
  153. Itm := StrInf SymNam IDInf Itm;
  154. Len := StrLen Itm;
  155. for I := 0 step 1 until Len do
  156. << Ch := StrByt(Itm, I);
  157. if UpperCaseP Ch then Ch := LowerChar Ch;
  158. ChannelWriteChar(Channel, Ch) >>;
  159. end;
  160. syslsp procedure ChannelWriteUnbound(Channel, Itm);
  161. << ChannelWriteString(Channel, "#<Unbound:");
  162. ChannelWriteID(Channel, Itm);
  163. ChannelWriteChar(Channel, char '!>) >>;
  164. syslsp procedure ChannelPrintID(Channel, Itm);
  165. begin scalar Len, Ch, TokenType;
  166. Itm := StrInf SymNam IDInf Itm;
  167. Len := StrLen Itm;
  168. Ch := StrByt(Itm, 0);
  169. if TokenTypeOfChar Ch neq 10 then ChannelWriteChar(Channel,
  170. LispVar IDEscapeChar!*);
  171. if not LispVar !*Lower then
  172. << ChannelWriteChar(Channel, Ch);
  173. for I := 1 step 1 until Len do
  174. << Ch := StrByt(Itm, I);
  175. TokenType := TokenTypeOfChar Ch;
  176. if not (TokenType <= 10
  177. or TokenType eq PLUSSIGN
  178. or TokenType eq MINUSSIGN) then
  179. ChannelWriteChar(Channel, LispVar IDEscapeChar!*);
  180. ChannelWriteChar(Channel, Ch) >> >>
  181. else
  182. << if UpperCaseP Ch then Ch := LowerChar Ch;
  183. ChannelWriteChar(Channel, Ch);
  184. for I := 1 step 1 until Len do
  185. << Ch := StrByt(Itm, I);
  186. TokenType := TokenTypeOfChar Ch;
  187. if not (TokenType <= 10
  188. or TokenType eq PLUSSIGN
  189. or TokenType eq MINUSSIGN) then
  190. ChannelWriteChar(Channel, LispVar IDEscapeChar!*);
  191. if UpperCaseP Ch then Ch := LowerChar Ch;
  192. ChannelWriteChar(Channel, Ch) >> >>
  193. end;
  194. syslsp procedure ChannelPrintUnbound(Channel, Itm);
  195. << ChannelWriteString(Channel, "#<Unbound ");
  196. ChannelPrintID(Channel, Itm);
  197. ChannelWriteChar(Channel, char '!>) >>;
  198. syslsp procedure ChannelWriteCodePointer(Channel, CP);
  199. begin scalar N;
  200. CP := CodeInf CP;
  201. ChannelWriteString(Channel, "#<Code ");
  202. N := !%code!-number!-of!-arguments CP;
  203. if N >= 0 and N <= MaxArgs then
  204. << ChannelWriteSysInteger(Channel, N, 10);
  205. ChannelWriteChar(Channel, char BLANK) >>:
  206. ChannelWriteSysInteger(Channel, CP, CompressedBinaryRadix);
  207. ChannelWriteChar(Channel, char '!>);
  208. end;
  209. syslsp procedure ChannelWriteUnknownItem(Channel, Itm);
  210. << ChannelWriteString(Channel, "#<Unknown ");
  211. ChannelWriteSysInteger(Channel, Itm, CompressedBinaryRadix);
  212. ChannelWriteChar(Channel, char !>) >>;
  213. syslsp procedure ChannelWriteBlankOrEOL Channel;
  214. << if (LinePosition[Channel] + 1 >= MaxLine[Channel]) and
  215. (MaxLine[Channel] > 0) then
  216. ChannelWriteChar(Channel, char EOL)
  217. else
  218. ChannelWriteChar(Channel, char ! ) >>;
  219. syslsp procedure ChannelWritePair(Channel, Itm, Level);
  220. if IntP LispVar PrinLevel and Level >= LispVar PrinLevel then
  221. ChannelWriteChar(Channel, char '!#)
  222. else
  223. begin scalar N;
  224. Level := Level + 1;
  225. CheckLineFit(1, Channel, 'ChannelWriteChar, char !( );
  226. if not IntP LispVar PrinLength or 1 <= LispVar PrinLength then
  227. << RecursiveChannelPrin2(Channel, car Itm, Level);
  228. N := 2;
  229. Itm := cdr Itm;
  230. while PairP Itm and
  231. (not IntP LispVar PrinLength or N <= LispVar PrinLength) do
  232. << ChannelWriteBlankOrEOL Channel;
  233. RecursiveChannelPrin2(Channel, car Itm, Level);
  234. N := N + 1;
  235. Itm := cdr Itm >>;
  236. if PairP Itm then
  237. CheckLineFit(3, Channel, 'ChannelWriteString, " ...")
  238. else
  239. if Itm then
  240. << CheckLineFit(3, Channel, 'ChannelWriteString, " . ");
  241. RecursiveChannelPrin2(Channel, Itm, Level) >> >>
  242. else
  243. CheckLineFit(3, Channel, 'ChannelWriteString, "...");
  244. CheckLineFit(1, Channel, 'ChannelWriteChar, char !) );
  245. end;
  246. syslsp procedure ChannelPrintPair(Channel, Itm, Level);
  247. if IntP LispVar PrinLevel and Level >= LispVar PrinLevel then
  248. ChannelWriteChar(Channel, char '!#)
  249. else
  250. begin scalar N;
  251. Level := Level + 1;
  252. CheckLineFit(1, Channel, 'ChannelWriteChar, char !( );
  253. if not IntP LispVar PrinLength or 1 <= LispVar PrinLength then
  254. << RecursiveChannelPrin1(Channel, car Itm, Level);
  255. N := 2;
  256. Itm := cdr Itm;
  257. while PairP Itm and
  258. (not IntP LispVar PrinLength or N <= LispVar PrinLength) do
  259. << ChannelWriteBlankOrEOL Channel;
  260. RecursiveChannelPrin1(Channel, car Itm, Level);
  261. N := N + 1;
  262. Itm := cdr Itm >>;
  263. if PairP Itm then
  264. CheckLineFit(3, Channel, 'ChannelWriteString, " ...")
  265. else
  266. if Itm then
  267. << CheckLineFit(3, Channel, 'ChannelWriteString, " . ");
  268. RecursiveChannelPrin1(Channel, Itm, Level) >> >>
  269. else
  270. CheckLineFit(3, Channel, 'ChannelWriteString, "...");
  271. CheckLineFit(1, Channel, 'ChannelWriteChar, char !) );
  272. end;
  273. syslsp procedure ChannelWriteVector(Channel, Vec, Level);
  274. if IntP LispVar PrinLevel and Level >= LispVar PrinLevel then
  275. ChannelWriteChar(Channel, char '!#)
  276. else
  277. begin scalar Len, I;
  278. Level := Level + 1;
  279. CheckLineFit(1, Channel, 'ChannelWriteChar, char '![ );
  280. Len := VecLen VecInf Vec;
  281. If Len<0 then
  282. return CheckLineFit(1, Channel, 'ChannelWriteChar, char '!] );
  283. I := 0;
  284. LoopBegin:
  285. if not IntP LispVar PrinLength or I < LispVar PrinLength then
  286. << RecursiveChannelPrin2(Channel, VecItm(VecInf Vec, I), Level);
  287. if (I := I + 1) <= Len then
  288. << ChannelWriteBlankOrEOL Channel;
  289. goto LoopBegin >> >>
  290. else
  291. CheckLineFit(3, Channel, 'ChannelWriteString, "...");
  292. CheckLineFit(1, Channel, 'ChannelWriteChar, char '!] );
  293. end;
  294. syslsp procedure ChannelPrintVector(Channel, Vec, Level);
  295. if IntP LispVar PrinLevel and Level >= LispVar PrinLevel then
  296. ChannelWriteChar(Channel, char '!#)
  297. else
  298. begin scalar Len, I;
  299. Level := Level + 1;
  300. CheckLineFit(1, Channel, 'ChannelWriteChar, char '![ );
  301. Len := VecLen VecInf Vec;
  302. If Len<0 then
  303. return CheckLineFit(1, Channel, 'ChannelWriteChar, char '!] );
  304. I := 0;
  305. LoopBegin:
  306. if not IntP LispVar PrinLength or I < LispVar PrinLength then
  307. << RecursiveChannelPrin1(Channel, VecItm(VecInf Vec, I), Level);
  308. if (I := I + 1) <= Len then
  309. << ChannelWriteBlankOrEOL Channel;
  310. goto LoopBegin >> >>
  311. else
  312. CheckLineFit(3, Channel, 'ChannelWriteString, "...");
  313. CheckLineFit(1, Channel, 'ChannelWriteChar, char '!] );
  314. end;
  315. syslsp procedure ChannelWriteEVector(Channel, EVec, Level);
  316. begin
  317. scalar handler;
  318. if IntP LispVar PrinLevel and Level >= LispVar PrinLevel then
  319. ChannelWriteChar(Channel, char '!#)
  320. else
  321. if getd('object!-get!-handler!-quietly)
  322. and (handler :=
  323. object!-get!-handler!-quietly(EVec, 'ChannelPrin)) then
  324. apply(handler, list(EVec, Channel, Level, NIL))
  325. else
  326. << ChannelWriteString(Channel, "#<EVector ");
  327. ChannelWriteSysInteger(Channel, EVecInf EVec,
  328. CompressedBinaryRadix);
  329. ChannelWriteChar(Channel, char '!>); >>;
  330. end;
  331. syslsp procedure ChannelPrintEVector(Channel, EVec, Level);
  332. begin
  333. scalar handler;
  334. if IntP LispVar PrinLevel and Level >= LispVar PrinLevel then
  335. ChannelWriteChar(Channel, char '!#)
  336. else
  337. if getd('object!-get!-handler!-quietly)
  338. and (handler :=
  339. object!-get!-handler!-quietly(EVec, 'ChannelPrin)) then
  340. apply(handler, list(EVec, Channel, Level, T))
  341. else
  342. << ChannelWriteString(Channel, "#<EVector ");
  343. ChannelWriteSysInteger(Channel, EVecInf EVec,
  344. CompressedBinaryRadix);
  345. ChannelWriteChar(Channel, char '!>); >>;
  346. end;
  347. syslsp procedure ChannelWriteWords(Channel, Itm);
  348. begin scalar Len, I;
  349. ChannelWriteString(Channel, "#<Words:");
  350. Len := WrdLen WrdInf Itm;
  351. if Len < 0 then
  352. return CheckLineFit(1, Channel, 'ChannelWriteChar, char '!> );
  353. I := 0;
  354. LoopBegin:
  355. if not IntP LispVar PrinLength or I < LispVar PrinLength then
  356. << CheckLineFit(10, Channel, 'ChannelWriteInteger, WrdItm(WrdInf Itm, I));
  357. if (I := I + 1) <= Len then
  358. << ChannelWriteBlankOrEOL Channel;
  359. goto LoopBegin >> >>
  360. else
  361. CheckLineFit(3, Channel, 'ChannelWriteString, "...");
  362. CheckLineFit(1, Channel, 'ChannelWriteChar, char '!> );
  363. end;
  364. syslsp procedure ChannelWriteHalfWords(Channel, Itm);
  365. begin scalar Len, I;
  366. ChannelWriteString(Channel, "#<Halfwords:");
  367. Len := HalfWordLen HalfWordInf Itm;
  368. if Len < 0 then
  369. return CheckLineFit(1, Channel, 'ChannelWriteChar, char '!> );
  370. I := 0;
  371. LoopBegin:
  372. if not IntP LispVar PrinLength or I < LispVar PrinLength then
  373. << CheckLineFit(10, Channel, 'ChannelWriteInteger,
  374. HalfWordItm(HalfWordInf Itm, I));
  375. if (I := I + 1) <= Len then
  376. << ChannelWriteBlankOrEOL Channel;
  377. goto LoopBegin >> >>
  378. else
  379. CheckLineFit(3, Channel, 'ChannelWriteString, "...");
  380. CheckLineFit(1, Channel, 'ChannelWriteChar, char '!> );
  381. end;
  382. syslsp procedure ChannelWriteBytes(Channel, Itm);
  383. begin scalar Len, I;
  384. ChannelWriteString(Channel, "#<Bytes:");
  385. Len := StrLen StrInf Itm;
  386. if Len < 0 then
  387. return CheckLineFit(1, Channel, 'ChannelWriteChar, char '!> );
  388. I := 0;
  389. LoopBegin:
  390. if not IntP LispVar PrinLength or I < LispVar PrinLength then
  391. << CheckLineFit(10, Channel, 'ChannelWriteInteger, StrByt(StrInf Itm, I));
  392. if (I := I + 1) <= Len then
  393. << ChannelWriteBlankOrEOL Channel;
  394. goto LoopBegin >> >>
  395. else
  396. CheckLineFit(3, Channel, 'ChannelWriteString, "...");
  397. CheckLineFit(1, Channel, 'ChannelWriteChar, char '!> );
  398. end;
  399. syslsp procedure ChannelPrin2(Channel, Itm); %. Display Itm on Channel
  400. RecursiveChannelPrin2(Channel, Itm, 0);
  401. syslsp procedure RecursiveChannelPrin2(Channel, Itm, Level);
  402. << case Tag Itm of
  403. PosInt, NegInt:
  404. CheckLineFit(10, Channel, 'ChannelWriteInteger, Itm);
  405. ID:
  406. CheckLineFit(StrLen StrInf SymNam IDInf Itm + 1,
  407. Channel, 'ChannelWriteID, Itm);
  408. UNBOUND:
  409. CheckLineFit(StrLen StrInf SymNam IDInf Itm + 12,
  410. Channel, 'ChannelWriteUnbound, Itm);
  411. STR:
  412. CheckLineFit(StrLen StrInf Itm + 1,
  413. Channel, 'ChannelWriteString, Itm);
  414. CODE:
  415. CheckLineFit(14, Channel, 'ChannelWriteCodePointer, Itm);
  416. FIXN:
  417. CheckLineFit(20, Channel, 'ChannelWriteFixnum, Itm);
  418. FLTN:
  419. CheckLineFit(30, Channel, 'ChannelWriteFloat, Itm);
  420. WRDS:
  421. ChannelWriteWords(Channel, Itm);
  422. Halfwords:
  423. ChannelWriteHalfWords(Channel, Itm);
  424. Bytes:
  425. ChannelWriteBytes(Channel, Itm);
  426. PAIR:
  427. ChannelWritePair(Channel, Itm, Level);
  428. VECT:
  429. ChannelWriteVector(Channel, Itm, Level);
  430. EVECT:
  431. ChannelWriteEVector(Channel, Itm, Level);
  432. default:
  433. CheckLineFit(20, Channel, 'ChannelWriteUnknownItem, Itm)
  434. end;
  435. Itm >>;
  436. syslsp procedure Prin2 Itm; %. ChannelPrin2 to current channel
  437. ChannelPrin2(LispVar OUT!*, Itm);
  438. syslsp procedure ChannelPrin1(Channel, Itm); %. Display Itm in READable form
  439. RecursiveChannelPrin1(Channel, Itm, 0);
  440. syslsp procedure RecursiveChannelPrin1(Channel, Itm, Level);
  441. << case Tag Itm of
  442. PosInt, NegInt:
  443. CheckLineFit(10, Channel, 'ChannelWriteInteger, Itm);
  444. ID: % leave room for possible escape chars
  445. CheckLineFit(StrLen StrInf SymNam IDInf Itm + 5,
  446. Channel, 'ChannelPrintID, Itm);
  447. UNBOUND: % leave room for possible escape chars
  448. CheckLineFit(StrLen StrInf SymNam IDInf Itm + 16,
  449. Channel, 'ChannelPrintUnbound, Itm);
  450. STR:
  451. CheckLineFit(StrLen StrInf Itm + 4,
  452. Channel, 'ChannelPrintString, Itm);
  453. CODE:
  454. CheckLineFit(14, Channel, 'ChannelWriteCodePointer, Itm);
  455. FIXN:
  456. CheckLineFit(20, Channel, 'ChannelWriteFixnum, Itm);
  457. FLTN:
  458. CheckLineFit(20, Channel, 'ChannelWriteFloat, Itm);
  459. WRDS:
  460. ChannelWriteWords(Channel, Itm);
  461. Halfwords:
  462. ChannelWriteHalfWords(Channel, Itm);
  463. Bytes:
  464. ChannelWriteBytes(Channel, Itm);
  465. PAIR:
  466. ChannelPrintPair(Channel, Itm, Level);
  467. VECT:
  468. ChannelPrintVector(Channel, Itm, Level);
  469. EVECT:
  470. ChannelPrintEVector(Channel, Itm, Level);
  471. default:
  472. CheckLineFit(20, Channel, 'ChannelWriteUnknownItem, Itm)
  473. end;
  474. Itm >>;
  475. syslsp procedure Prin1 Itm; %. ChannelPrin1 to current output
  476. ChannelPrin1(LispVar OUT!*, Itm);
  477. off SysLisp;
  478. END;