1
;;; -*- Mode:Lisp; Package:USER; Base:10; Syntax:Common-lisp -*-
5
(setq c::optimize-speed 3)
6
(setq c::optimize-safety 0)
7
(setq c::optimize-space 0)
9
(remprop 'macroexpand 'c::fdesc)
10
(remprop 'macroexpand-1 'c::fdesc)
13
;;; this is here to fix the printer so it will find the print
14
;;; functions on structures that have 'em.
18
(defun %write-structure (struct output-stream print-vars level)
19
(let* ((name (svref struct 0))
20
(pfun (or (let ((temp (get name 'structure-descriptor)))
21
(and temp (dd-print-function temp)))
22
(get name :print-function))))
23
(declare (symbol name))
26
(funcall pfun struct output-stream level))
27
((and (pv-level print-vars) (>= level (pv-level print-vars)))
28
(write-char #\# output-stream))
29
((and (pv-circle print-vars)
30
(%write-circle struct output-stream (pv-circle print-vars))))
32
(let ((pv-length (pv-length print-vars))
33
(pv-pretty (pv-pretty print-vars)))
35
(pp-push-level pv-pretty))
37
(write-string "#s(" output-stream)
39
((and pv-length (>= 0 pv-length))
42
(%write-symbol name output-stream print-vars)
45
(slots (dd-slots (get name 'structure-descriptor))
48
(declare (fixnum i n) (list slots))
50
(pp-insert-break pv-pretty *structure-keyword-slot-spec* t))
51
(write-char #\space output-stream)
52
(when (and pv-length (>= (incf n) pv-length))
53
(write-string "..." output-stream)
55
(write-char #\: output-stream)
57
(symbol-name (dsd-name (first slots))) output-stream print-vars)
59
(pp-insert-break pv-pretty *structure-data-slot-spec* nil))
60
(write-char #\space output-stream)
61
(when (and pv-length (>= (incf n) pv-length))
62
(write-string "..." output-stream)
65
(svref struct (dsd-index (first slots)))
66
output-stream print-vars level))))
67
(write-char #\) output-stream)
69
(pp-pop-level pv-pretty)))))))
71
(eval-when (eval) (compile '%write-structure))
74
;;; Apparently, whoever implemented the TIME macro didn't consider that
75
;;; someone might want to use it in a non-null lexical environment. Of
76
;;; course this fix is a loser since it binds a whole mess of variables
77
;;; around the evaluation of form, but it will do for now.
82
`(LET (IGNORE START FINISH S-HSEC F-HSEC S-SEC F-SEC S-MIN F-MIN VALS)
83
(FORMAT *trace-output* "~&Evaluating: ~A" ,form)
84
;; read the start time.
85
(MULTIPLE-VALUE-SETQ (IGNORE IGNORE IGNORE S-MIN START)
86
(SYS::%SYSINT #X21 #X2C00 0 0 0))
88
(SETQ VALS (MULTIPLE-VALUE-LIST (progn ,form)))
90
(MULTIPLE-VALUE-SETQ (IGNORE IGNORE IGNORE F-MIN FINISH)
91
(SYS::%SYSINT #X21 #X2C00 0 0 0))
92
;; Unpack start and end times.
93
(SETQ S-HSEC (LOGAND START #X0FF)
94
F-HSEC (LOGAND FINISH #X0FF)
97
S-MIN (LOGAND #X0FF S-MIN)
98
F-MIN (LOGAND #X0FF F-MIN))
99
(SETQ F-HSEC (- F-HSEC S-HSEC)) ; calc hundreths
101
(SETQ F-HSEC (+ F-HSEC 100)
103
(SETQ F-SEC (- F-SEC S-SEC)) ; calc seconds
105
(SETQ F-SEC (+ F-SEC 60)
107
(SETQ F-MIN (- F-MIN S-MIN)) ; calc minutes
108
(IF (MINUSP F-MIN) (INCF F-MIN 60))
109
(FORMAT *trace-output* "~&Elapsed time: ~D:~:[~D~;0~D~].~:[~D~;0~D~]~%"
110
F-MIN (< F-SEC 10.) F-SEC (< F-HSEC 10) F-HSEC)
116
(in-package sys::*compiler-package-load*)
118
;;; This is a fully portable (though not very efficient)
119
;;; implementation of PROGV as a macro. It does its own special
120
;;; binding (shallow binding) by saving the original values in a
121
;;; list, and marking things that were originally unbound.
123
(defun PORTABLE-PROGV-BIND (symbol old-vals place-holder)
124
(let ((val-to-save '#:value-to-save))
125
`(let ((,val-to-save (if (boundp ,symbol)
126
(symbol-value ,symbol)
129
(rplacd (last ,old-vals) (ncons ,val-to-save))
130
(setq ,old-vals (ncons ,val-to-save))))))
132
(defun PORTABLE-PROGV-UNBIND (symbol old-vals place-holder)
133
(let ((val-to-restore '#:value-to-restore))
134
`(let ((,val-to-restore (pop ,old-vals)))
135
(if (eq ,val-to-restore ,place-holder)
137
(setf (symbol-value ,symbol) ,val-to-restore)))))
140
(deftransform PROGV PORTABLE-PROGV-TRANSFORM
141
(symbols-form values-form &rest body)
142
(let ((symbols-lst '#:symbols-list)
143
(values-lst '#:values-list)
147
(old-vals '#:old-values)
148
(unbound-holder ''#:unbound-holder))
149
`(let ((,symbols-lst ,symbols-form)
150
(,values-lst ,values-form)
152
(unless (and (listp ,symbols-lst) (listp ,values-lst))
153
(error "PROGV: Both symbols and values must be lists"))
155
(do ((,syms ,symbols-lst (cdr ,syms))
156
(,vals ,values-lst (cdr ,vals))
158
((null ,syms) (progn ,@body))
159
(setq ,sym (car ,syms))
161
,(PORTABLE-PROGV-BIND sym old-vals unbound-holder)
162
(error "PROGV: Object to be bound not a symbol: ~S" ,sym))
164
(setf (symbol-value ,sym) (first ,vals))
166
(dolist (,sym ,symbols-lst)
167
,(PORTABLE-PROGV-UNBIND sym old-vals unbound-holder))))))