-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathLOOPSPRINT
508 lines (369 loc) · 18.4 KB
/
LOOPSPRINT
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
(DEFINE-FILE-INFO PACKAGE "INTERLISP" READTABLE "INTERLISP" BASE 10)
(FILECREATED "19-Aug-2022 14:47:13" {DSK}<home>larry>loops>system>LOOPSPRINT.;2 18068
:CHANGES-TO (VARS LOOPSPRINTCOMS)
:PREVIOUS-DATE "28-Jun-93 22:43:05" {DSK}<home>larry>loops>system>LOOPSPRINT.;1)
(* ; "
Copyright (c) 1983-1988, 1990-1991, 1993 by Venue & Xerox Corporation.
")
(PRETTYCOMPRINT LOOPSPRINTCOMS)
(RPAQQ LOOPSPRINTCOMS
[
(* ;;; "Functions for handling READ macros")
(DECLARE%: DONTCOPY (PROP MAKEFILE-ENVIRONMENT LOOPSPRINT)
(PROP FILETYPE LOOPSPRINT))
(INITVARS (LoopsReadMacroChar '%#))
(GLOBALVARS LoopsReadMacroChar)
(ADDVARS (GLOBALVARS LoopsReadMacroChar))
(FNS HashMacro PPDefault SETALLSYNTAX $& $ $C)
(* ;; "Used to include the following: (COMS (P (SETALLSYNTAX LoopsReadMacroChar '(MACRO FIRST HashMacro))) (ADVICE HPINITRDTBL)")
(* ;;; "Printing of classes and instances")
(FNS PrintClass PrintInstance)
(DECLARE%: EVAL@COMPILE DONTCOPY (EXPORT (FUNCTIONS TTYStream?))
DONTEVAL@LOAD
(FILES (LOADCOMP)
LOOPSDATATYPES))
(P (DEFPRINT 'class 'PrintClass)
(DEFPRINT 'instance 'PrintInstance))
(* ;;; "Prettyprinting functions")
(* ;; "PPObj is Called by the PreetyPrinter on instances. ObjectAlwaysPPFlag and ObjectDontPPFlag are used to determine if the PrettyPrint macro should be applied recursively within the scope of a pretty printing operation. ObjectDontPPFlag is bound to NIL in Object.PP to supress recursive prettyprinting on files and if objects don't have special PP Methods of there own.")
(INITVARS (ObjectAlwaysPPFlag)
(ObjectDontPPFlag)
(WritingToEtherNet))
(FUNCTIONS WITH.PP.OUTPUT)
(SPECVARS ObjectAlwaysPPFlag ObjectDontPPFlag WritingToEtherNet)
(FNS EntityAddress PrettyPrintLoopsForm PrettyPrintClass PrintDefInstances
PrettyPrintInstance PrttyClasses PrttyInstances PrintLoopsEvalAtLoad PPC PPObj)
(INITVARS (UnnamedInstances NIL))
(GLOBALVARS UnnamedInstances)
(ALISTS (PRETTYPRINTYPEMACROS instance)
(PRETTYPRINTMACROS @ _@ _ SEND _IV _Proto _New _Super _! _Process _Process!
\LOOPS-PRINT-EVAL-MARKER))
(* ;;; "Set up macros so that references to classes and instances seen by HPRINT don't recur into their structure.")
(FNS HPRINTCLASS HPRINTINSTANCE HREADCLASS HREADINSTANCE)
(ADDVARS (HPRINTMACROS (class . HPRINTCLASS)
(instance . HPRINTINSTANCE)))
(DECLARE%: DONTEVAL@LOAD DOEVAL@COMPILE DONTCOPY COMPILERVARS (ADDVARS (NLAMA $&)
(NLAML $C $)
(LAMA])
(* ;;; "Functions for handling READ macros")
(DECLARE%: DONTCOPY
(PUTPROPS LOOPSPRINT MAKEFILE-ENVIRONMENT (:PACKAGE "IL" :READTABLE "INTERLISP" :BASE 10))
(PUTPROPS LOOPSPRINT FILETYPE :COMPILE-FILE)
)
(RPAQ? LoopsReadMacroChar '%#)
(DECLARE%: DOEVAL@COMPILE DONTCOPY
(GLOBALVARS LoopsReadMacroChar)
)
(ADDTOVAR GLOBALVARS LoopsReadMacroChar)
(DEFINEQ
(HashMacro
(LAMBDA (fileHandle readTable) (* AAA "24-Feb-86 18:41")
(LET* ((char (PEEKC fileHandle))
(charFn (GETPROP char 'HASHREADMACRO)))
(COND
(charFn (if (NEQ char '%()
then (READCCODE fileHandle))
(APPLY* charFn fileHandle readTable))
(T (SELCHARQ (CHCON1 char)
("."
(* Following CommonLisp, %#. means read in the value of the next expression)
(READCCODE fileHandle)
(EVAL (READ fileHandle readTable)))
(- (* a datatype dumped)
(READCCODE fileHandle)
(APPLY* (FUNCTION $A)
(HREAD fileHandle)
'DataType))
(SELECTQ (GETSYNTAX (CHCON1 char)
readTable)
((LEFTBRACKET RIGHTPAREN RIGHTBRACKET STRINGDELIM BREAKCHAR SEPRCHAR)
'%#)
(PACK* '%# (RATOM fileHandle readTable)))))))))
(PPDefault
(LAMBDA (file) (* smL "31-Oct-86 10:56")
(* ;;; "")
(* ;;; "Return the default stream to use for output")
(* ;;; "")
(OR file (AND (TTYStream? NIL)
PPDefault))))
(SETALLSYNTAX
(LAMBDA (CHAR FORM) (* smL "15-Oct-86 16:44")
(DECLARE (GLOBALVARS CODERDTBL DEDITRDTBL EDITRDTBL FILERDTBL))
(SETSYNTAX CHAR FORM)
(SETSYNTAX CHAR FORM T)
(SETSYNTAX CHAR FORM FILERDTBL)
(SETSYNTAX CHAR FORM EDITRDTBL) (* ;
"In Lyric, the DEdit readtable is not defined...")
(AND (BOUNDP 'DEDITRDTBL)
(SETSYNTAX CHAR FORM DEDITRDTBL))
(SETSYNTAX CHAR FORM CODERDTBL)))
($&
(NLAMBDA nameOrUID (* smL " 5-Sep-86 13:35")
(* * Used to read back in printed instances -
"(className (name1 ... nameN uid) (ivName ivValue prop val ...)...)" is a
posibility -
Archaic! Ugh! nameOrUID = "(mumble number ...)" is a pointer to location
number!)
(COND
((AND (LISTP (CADR nameOrUID))
(FIXP (CAR (CADR nameOrUID)))
(FIXP (CDR (CADR nameOrUID))))
(VAG (CADR nameOrUID)))
(T (ModifyInstance nameOrUID)))))
($
(NLAMBDA (name) (* smL " 4-Apr-86 15:21")
(* * Get object given name)
(GetObjectRec name)))
($C
(NLAMBDA (name) (* smL " 4-Apr-86 15:25")
(* * Get class, given the name. If the class doesn't exist, create it.
-
This is an attempt to take care of forward references in files.
See the fn PrintClass to see how classes print out.)
(OR (GetClassRec name)
(NewClass name))))
)
(* ;;
"Used to include the following: (COMS (P (SETALLSYNTAX LoopsReadMacroChar '(MACRO FIRST HashMacro))) (ADVICE HPINITRDTBL)"
)
(* ;;; "Printing of classes and instances")
(DEFINEQ
(PrintClass
[LAMBDA (classRec file) (* ; "Edited 15-Aug-90 12:49 by jds")
(* ;;; "This is called by the LISP PRINT function when it sees an instance of the data type class")
(CONS (CONCAT LoopsReadMacroChar ",")
(LIST (if (OR (NULL file)
(TTYStream? file)
(DISPLAYSTREAMP file))
then (* ; "for local human consumption")
'$
else (* ; "Dumping to a file")
'$C)
(fetch (class className) of classRec])
(PrintInstance
(LAMBDA (instanceRec file) (* ; "Edited 4-Jun-87 18:33 by smL")
(* ;;; "This is called by the LISP PRINT function when it sees an instance of the data type instance")
(DECLARE (SPECVARS WritingToEtherNet FileEntities OutInstances))
(PROG (entity uid uidString) (* ;
"(NOT (EQP FILERDTBL (GETREADTABLE)))")
(COND
((OR WritingToEtherNet OutInstances) (* ;
"Force items being saved to have a uid")
(SETQ uid (UID instanceRec)))
((OR (NULL file)
(TTYStream? file)
(DISPLAYSTREAMP file)) (* ; "for local human consumption")
(RETURN (_ instanceRec PrintOn file)))
(T (* ;
"this case is for a non display stream file")
(SETQ uid (UID instanceRec))))
(RETURN (COND
(OutInstances (* ;
"This case when dumping instances to a file with INSTANCES")
(AND (_ instanceRec SaveInstance? file (CAR OutInstances))
(TCONC OutInstances instanceRec))
(* ;
"Recursive dump of instances referred to")
(LIST (CONCAT LoopsReadMacroChar ",")
'$&
(ClassName instanceRec)
uid))
(T
(* ;;; "Internal or ethernetPrinting printing * WritingToEtherNet set when writing to EtherNet")
(LIST (CONCAT LoopsReadMacroChar ",")
'$&
(ClassName instanceRec)
uid)))))))
)
(DECLARE%: EVAL@COMPILE DONTCOPY
(* "FOLLOWING DEFINITIONS EXPORTED")
(DEFMACRO TTYStream? (s)
`(EQ (GETSTREAM T 'OUTPUT)
(GETSTREAM ,s 'OUTPUT)))
(* "END EXPORTED DEFINITIONS")
DONTEVAL@LOAD
(FILESLOAD (LOADCOMP)
LOOPSDATATYPES)
)
(DEFPRINT 'class 'PrintClass)
(DEFPRINT 'instance 'PrintInstance)
(* ;;; "Prettyprinting functions")
(* ;;
"PPObj is Called by the PreetyPrinter on instances. ObjectAlwaysPPFlag and ObjectDontPPFlag are used to determine if the PrettyPrint macro should be applied recursively within the scope of a pretty printing operation. ObjectDontPPFlag is bound to NIL in Object.PP to supress recursive prettyprinting on files and if objects don't have special PP Methods of there own."
)
(RPAQ? ObjectAlwaysPPFlag )
(RPAQ? ObjectDontPPFlag )
(RPAQ? WritingToEtherNet )
(DEFMACRO WITH.PP.OUTPUT (stream &BODY forms)
[Once-Only (stream)
`(RESETLST
[if (WINDOWP ,stream)
then [RESETSAVE NIL (LIST (FUNCTION WINDOWPROP)
,stream
'PROCESS
(WINDOWPROP ,stream 'PROCESS]
(RESETSAVE (TTYDISPLAYSTREAM ,stream))
(if (NOT (TTY.PROCESSP))
then (RESETSAVE (TTY.PROCESS (THIS.PROCESS]
,@forms)])
(DECLARE%: DOEVAL@COMPILE DONTCOPY
(SPECVARS ObjectAlwaysPPFlag ObjectDontPPFlag WritingToEtherNet)
)
(DEFINEQ
(EntityAddress
(LAMBDA (E) (* dgb%: "11-NOV-82 02:29")
(LOC E)))
(PrettyPrintLoopsForm
(LAMBDA (form) (* smL " 2-May-86 16:30")
(* * Pretty-print the Loops form)
(PRIN1 "(")
(PRIN2 (CAR form))
(SPACES 1)
(PRINTDEF (CDR form)
(POSITION)
T T)
(PRIN1 ")")
NIL))
(PrettyPrintClass
(LAMBDA (className file) (* ; "Edited 25-Jun-87 13:57 by smL")
(* ;;; "Called to prettyPrint a class definition on a file by the FILEPKGTYPE CLASSES and by the PP: method in Class")
(DECLARE (SPECVARS className))
(LET ((class (GetClassRec className)))
(COND
((NULL class)
(HELPCHECK className
" is not defined as a class.
Type OK to ignore this class and go on."))
(T (_ class FileOut file)
className)))))
(PrintDefInstances
(LAMBDA (instances file) (* dgb%: " 5-OCT-82 10:50")
(* * Does the INSTANCES command for the LISP file pkg.)
(TERPRI file)
(PRIN1 "[DEFINSTANCES " file)
(for inst instRec in instances do (SETQ instRec (GetObjectRec inst))
(PRIN2 (CONS (ClassName instRec)
(GetObjectNames instRec))
file)
(SPACES 1 file))
(PRIN1 "]" file)
(TERPRI file)
(TERPRI file)
instances))
(PrettyPrintInstance
[LAMBDA (self file) (* ; "Edited 9-Mar-88 11:55 by jrb:")
(* PrettyPrint an self definition on
file.)
(if self
then (if (CL:SYMBOLP self)
then (SETQ self ($! self)))
(_ self FileOut file))
self])
(PrttyClasses
(LAMBDA (classes) (* smL "15-Aug-86 10:21")
(* * Used by CLASSES command to print out rereadable versions of class
definitions on files)
(PRINT (CONS 'DEFCLASSES classes))
(TERPRI)
(for className in classes do (PrettyPrintClass className (OUTPUT)))))
(PrttyInstances
(LAMBDA (instances) (* smL "15-Aug-86 10:23")
(* * Prettyprint a list of named instances to a file.
OutInstances is bound here, although usually a free variable when printing an
instance)
(LET ((OutInstances (LCONC NIL (for name obj in instances collect obj
when (SETQ obj (OR (GetObjectRec name)
(NULL (HELPCHECK name
" not defined as an instance.
Type OK to ignore and go on."))))))))
(DECLARE (SPECVARS OutInstances))
(for obj in (CAR OutInstances) do (PrettyPrintInstance obj (OUTPUT))
(TERPRI)
(TERPRI)))))
(PrintLoopsEvalAtLoad
[LAMBDA (FORM) (* ;
"Edited 28-Jun-93 16:20 by sybalsky:mv:envos")
(PRIN1 "#,")
(PRIN2 (CADR FORM))
NIL])
(PPC
(LAMBDA (className) (* smL "11-Apr-86 17:11")
(* * PrettyPrint the class)
(LET ((class (GetClassRec className)))
(if class
then (_ class PP)
else (ERROR "No such class" className)))))
(PPObj
[LAMBDA (instance) (* ; "Edited 2-Dec-87 16:22 by jrb:")
(* ;;; "Called by the PrettyPrinter on instances.")
[LET ((FOO *STANDARD-OUTPUT*))
(COND
(ObjectAlwaysPPFlag (* ; "Don't suppress PPing")
(_ instance PP *STANDARD-OUTPUT*))
(ObjectDontPPFlag (* ; "Suppress PPing")
(PRIN2 instance))
((EQ *STANDARD-OUTPUT* *TERMINAL-IO*) (* ; "Displaying for the user, so PP it")
(_ instance PP *STANDARD-OUTPUT*))
(T (* ;
"No reason to PP to a file, so dont")
(PRIN2 instance]
NIL])
)
(RPAQ? UnnamedInstances NIL)
(DECLARE%: DOEVAL@COMPILE DONTCOPY
(GLOBALVARS UnnamedInstances)
)
(ADDTOVAR PRETTYPRINTYPEMACROS (instance . PPObj))
(ADDTOVAR PRETTYPRINTMACROS (@ . PrettyPrintLoopsForm)
(_@ . PrettyPrintLoopsForm)
(_ . PrettyPrintLoopsForm)
(SEND . PrettyPrintLoopsForm)
(_IV . PrettyPrintLoopsForm)
(_Proto . PrettyPrintLoopsForm)
(_New . PrettyPrintLoopsForm)
(_Super . PrettyPrintLoopsForm)
(_! . PrettyPrintLoopsForm)
(_Process . PrettyPrintLoopsForm)
(_Process! . PrettyPrintLoopsForm))
(* ;;;
"Set up macros so that references to classes and instances seen by HPRINT don't recur into their structure."
)
(DEFINEQ
(HPRINTCLASS
(LAMBDA (EXPR FILE) (* dgb%: "18-MAR-83 16:35")
(* Used by HPRINT to print out an expression which will be read back in as a
class)
(PRIN1 '(HREADCLASS) FILE)
(PRIN2 (ClassName EXPR))))
(HPRINTINSTANCE
(LAMBDA (EXPR FILE) (* dgb%: "18-MAR-83 16:36")
(* Used by HPRINT to print out an expression referring to an instance, provided
instance is dumped eleewhere)
(PRIN1 '(HREADINSTANCE) FILE)
(PRIN2 (UID EXPR))))
(HREADCLASS
(LAMBDA (FILE) (* dgb%: "13-DEC-82 15:13")
(GetObjectRec (HREAD FILE))))
(HREADINSTANCE
(LAMBDA (FILE) (* dgb%: " 8-Oct-84 13:28")
(GetObjectRec (HREAD FILE))))
)
(ADDTOVAR HPRINTMACROS (class . HPRINTCLASS)
(instance . HPRINTINSTANCE))
(DECLARE%: DONTEVAL@LOAD DOEVAL@COMPILE DONTCOPY COMPILERVARS
(ADDTOVAR NLAMA $&)
(ADDTOVAR NLAML $C $)
(ADDTOVAR LAMA )
)
(PUTPROPS LOOPSPRINT COPYRIGHT ("Venue & Xerox Corporation" 1983 1984 1985 1986 1987 1988 1990 1991
1993))
(DECLARE%: DONTCOPY
(FILEMAP (NIL (3377 6517 (HashMacro 3387 . 4593) (PPDefault 4595 . 4839) (SETALLSYNTAX 4841 . 5381) (
$& 5383 . 5960) ($ 5962 . 6127) ($C 6129 . 6515)) (6710 9602 (PrintClass 6720 . 7440) (PrintInstance
7442 . 9600)) (9674 9765 (TTYStream? 9674 . 9765)) (10458 11063 (WITH.PP.OUTPUT 10458 . 11063)) (11167
15878 (EntityAddress 11177 . 11294) (PrettyPrintLoopsForm 11296 . 11603) (PrettyPrintClass 11605 .
12156) (PrintDefInstances 12158 . 12795) (PrettyPrintInstance 12797 . 13260) (PrttyClasses 13262 .
13614) (PrttyInstances 13616 . 14473) (PrintLoopsEvalAtLoad 14475 . 14710) (PPC 14712 . 15000) (PPObj
15002 . 15876)) (16821 17696 (HPRINTCLASS 16831 . 17111) (HPRINTINSTANCE 17113 . 17419) (HREADCLASS
17421 . 17555) (HREADINSTANCE 17557 . 17694)))))
STOP