block))
\f
(define-vector-tag-unparser block-tag
- (simple-unparser-method "LIAR:block"
+ (standard-print-method "LIAR:block"
(lambda (block)
(cons (enumeration/index->name block-types (block-type block))
(let ((procedure (block-procedure block)))
(make-scfg application '())))
(define-vector-tag-unparser application-tag
- (simple-unparser-method
+ (standard-print-method
(lambda (application)
(case (application-type application)
((COMBINATION) "LIAR:combination")
(define-structure (enumerand
(conc-name enumerand/)
(print-procedure
- (simple-unparser-method "LIAR:enumerand"
+ (standard-print-method "LIAR:enumerand"
(lambda (enumerand)
(list (enumerand/name enumerand))))))
(enumeration false read-only true)
(variable-normal-offset variable)))
(define-vector-tag-unparser variable-tag
- (simple-unparser-method "LIAR:variable"
+ (standard-print-method "LIAR:variable"
(lambda (variable)
(list (variable-name variable)))))
(let ((root-tag (%make-vector-tag false 'OBJECT false false)))
(set-vector-tag-%unparser!
root-tag
- (simple-unparser-method
+ (standard-print-method
(lambda (object)
- (string "LIAR:" (vector-tag-name (tagged-vector/tag object))))
- #f))
+ (string "LIAR:" (vector-tag-name (tagged-vector/tag object))))))
(named-lambda (make-vector-tag parent name enumeration)
(let ((tag
(%make-vector-tag (or parent root-tag)
(lambda (procedure)
(enumeration/index->name continuation-types
(procedure-type procedure)))))
- (simple-unparser-method
+ (standard-print-method
(lambda (procedure)
(if (eq? (get-type procedure) 'PROCEDURE)
"LIAR:procedure"
constant))))
(define-vector-tag-unparser constant-tag
- (simple-unparser-method "LIAR:constant"
+ (standard-print-method "LIAR:constant"
(lambda (constant)
(list (constant-value constant)))))
(make-rvalue reference-tag block lvalue safe?))
(define-vector-tag-unparser reference-tag
- (simple-unparser-method "LIAR:reference"
+ (standard-print-method "LIAR:reference"
(lambda (reference)
(list (variable-name (reference-lvalue reference))))))
(make-rvalue unassigned-test-tag block lvalue))
(define-vector-tag-unparser unassigned-test-tag
- (simple-unparser-method "LIAR:unassigned-test"
+ (standard-print-method "LIAR:unassigned-test"
(lambda (unassigned-test)
(list (unassigned-test-lvalue unassigned-test)))))
(constructor virtual-continuation/%make)
(conc-name virtual-continuation/)
(print-procedure
- (simple-unparser-method "LIAR:virtual-continuation"
+ (standard-print-method "LIAR:virtual-continuation"
(lambda (continuation)
(let ((type (virtual-continuation/type continuation)))
(if type
(constructor make-rtl-expr
(rgraph label entry-edge debugging-info))
(print-procedure
- (simple-unparser-method "LIAR:rtl-expr"
+ (standard-print-method "LIAR:rtl-expr"
(lambda (expression)
(list (rtl-expr/label expression))))))
(rgraph false read-only true)
debugging-info
next-continuation-offset stack-leaf?))
(print-procedure
- (simple-unparser-method "LIAR:rtl-procedure"
+ (standard-print-method "LIAR:rtl-procedure"
(lambda (procedure)
(list (rtl-procedure/label procedure))))))
(rgraph false read-only true)
next-continuation-offset
debugging-info))
(print-procedure
- (simple-unparser-method "LIAR:rtl-continuation"
+ (standard-print-method "LIAR:rtl-continuation"
(lambda (continuation)
(list (rtl-continuation/label continuation))))))
(rgraph false read-only true)
(conc-name value-class/)
(constructor %make-value-class (name parent))
(print-procedure
- (simple-unparser-method 'VALUE-CLASS
+ (standard-print-method 'VALUE-CLASS
(lambda (class)
(list (value-class/name class))))))
(name false read-only true)
(define-structure (element
(constructor %make-element)
(constructor make-element (expression))
- (print-procedure (simple-unparser-method "LIAR:element" #f)))
+ (print-procedure (standard-print-method "LIAR:element")))
(expression false read-only true)
(cost false)
(in-memory? false)
(define-structure (quantity
(copier quantity-copy)
(print-procedure
- (simple-unparser-method "LIAR:quantity" #f)))
+ (standard-print-method "LIAR:quantity")))
(number false read-only true)
(first-register false)
(last-register false))
(conc-name rnode/)
(constructor make-rnode (register))
(print-procedure
- (simple-unparser-method 'RNODE
+ (standard-print-method 'RNODE
(lambda (rnode)
(list (rnode/register rnode))))))
(register false read-only true)
(constructor make-package (name parent))
(conc-name package/)
(print-procedure
- (simple-unparser-method 'package
+ (standard-print-method 'package
(lambda (package)
(list (package/name package))))))
(name #f read-only #t)
(constructor %make-binding (package name value-cell new?))
(conc-name binding/)
(print-procedure
- (simple-unparser-method 'binding
+ (standard-print-method 'binding
(lambda (binding)
(list (binding/name binding)
(package/name (binding/package binding)))))))
(constructor %make-reference (package name))
(conc-name reference/)
(print-procedure
- (simple-unparser-method 'reference
+ (standard-print-method 'reference
(lambda (reference)
(list (reference/name reference)
(package/name (reference/package reference)))))))
(define-structure (unparser-literal
(conc-name unparser-literal/)
(print-procedure
- (general-unparser-method
- (lambda (instance port)
- (write-string (unparser-literal/string instance)
- port))))
+ (lambda (instance port)
+ (write-string (unparser-literal/string instance)
+ port)))
(constructor unparser-literal/make))
string)
(define-structure (outline
(constructor %make-outline)
(print-procedure
- (standard-unparser-method 'OUTLINE
+ (bracketed-print-method 'OUTLINE
(lambda (outline port)
(write-string "index: " port)
(write (outline-index-length outline) port)
(define-structure (o3
(constructor %make-o3)
(print-procedure
- (standard-unparser-method 'O3
+ (bracketed-print-method 'O3
(lambda (o3 port)
(write-string "index: " port)
(write (o3-index o3) port)
(define-structure (special-key (constructor %make-special-key)
(conc-name special-key/)
(print-procedure
- (standard-unparser-method 'special-key
- (lambda (key port)
- (write-char #\space port)
- (write-string (special-key/name key)
- port)))))
+ (standard-print-method 'special-key
+ (lambda (key)
+ (list (special-key/name key))))))
(symbol #f read-only #t)
(bucky-bits #f read-only #t))
(list->vector (map car transforms))
(list->vector (map cdr transforms))
(make-vector (length transforms) (lambda () #f))
- (standard-unparser-method name #f)
+ (standard-print-method name)
class
object-size))
class))))
(define-structure (command
(constructor %make-command ())
(print-procedure
- (simple-unparser-method 'COMMAND
+ (standard-print-method 'COMMAND
(lambda (command)
(list (command-name command))))))
name
(define-structure (variable
(constructor %make-variable ())
(print-procedure
- (simple-unparser-method 'VARIABLE
+ (standard-print-method 'VARIABLE
(lambda (variable)
(list (variable-name variable))))))
name
(conc-name display-type/)
(constructor %make-display-type)
(print-procedure
- (simple-unparser-method 'DISPLAY-TYPE
+ (standard-print-method 'DISPLAY-TYPE
(lambda (display-type)
(list (display-type/name display-type))))))
(name false read-only true)
(constructor make-input-event (type operator . operands))
(conc-name input-event/)
(print-procedure
- (standard-unparser-method
- 'input-event
- (lambda (event port)
- (write-char #\space port)
- (write (input-event/type event) port)))))
+ (standard-print-method 'input-event
+ (lambda (event)
+ (list (input-event/type event))))))
(type #f read-only #t)
(operator #f read-only #t)
(operands #f read-only #t))
(define (button-name button)
(symbol->string (button-symbol button)))
-(define-unparser-method button?
- (simple-unparser-method (record-type-name <button>)
+(define-print-method button?
+ (standard-print-method (record-type-name <button>)
(lambda (button)
(list (button-symbol button)))))
(keyword-constructor make-keyparser-fragment)
(conc-name keyparser-fragment/)
(print-procedure
- (simple-unparser-method 'KEYPARSER-FRAGMENT
+ (standard-print-method 'KEYPARSER-FRAGMENT
(lambda (fragment)
(list (keyparser-fragment/keyword fragment))))))
;; Keyword that introduces the structure.
(define-structure (keyparser-stack-entry
(conc-name keyparser-stack-entry/)
(print-procedure
- (simple-unparser-method 'KEYPARSER-STACK-ENTRY
+ (standard-print-method 'KEYPARSER-STACK-ENTRY
(lambda (entry)
(list (keyparser-stack-entry/keyword entry))))))
(pattern #f read-only #t)
(name major? display-name super-mode
%description initialization comtabs))
(print-procedure
- (simple-unparser-method 'MODE
+ (standard-print-method 'MODE
(lambda (mode)
(cons (mode-name mode)
(if (mode-major? mode)
(define-structure (mark
(constructor make-temporary-mark)
(print-procedure
- (simple-unparser-method 'MARK
+ (standard-print-method 'MARK
(lambda (mark)
(list (or (mark-buffer mark)
(mark-group mark))
(vector-set! inferior 4 redisplay-flags))
(unparser/set-tagged-vector-method! %inferior-tag
- (standard-unparser-method 'INFERIOR
+ (bracketed-print-method 'INFERIOR
(lambda (inferior port)
(write-string " " port)
(write (inferior-window inferior) port)
\f
(define-structure (gdbf (constructor make-gdbf)
(print-procedure
- (simple-unparser-method 'GDBF
+ (standard-print-method 'GDBF
(lambda (gdbf)
(list (gdbf-filename gdbf))))))
;; Note that communicating through this malloced-per-GDBM_FILE
(safe-accessors #t)
(constructor #f)
(print-procedure
- (simple-unparser-method 'HEADER-FIELD
+ (standard-print-method 'HEADER-FIELD
(lambda (header)
(list (header-field-name header))))))
(name #f read-only #t)
(define-structure (mime-encoding
(conc-name mime-encoding/)
(print-procedure
- (simple-unparser-method 'MIME-ENCODING
+ (standard-print-method 'MIME-ENCODING
(lambda (encoding)
(list (mime-encoding/name encoding)))))
(constructor %make-mime-encoding))
'<= binary-input-port?
'<= binary-output-port?)
-(define-unparser-method binary-port?
- (standard-unparser-method
+(define-print-method binary-port?
+ (standard-print-method
(lambda (port)
(cond ((binary-i/o-port? port) 'binary-i/o-port)
((binary-input-port? port) 'binary-input-port)
((binary-output-port? port) 'binary-output-port)
- (else 'binary-port)))
- #f))
+ (else 'binary-port)))))
\f
;;;; Bytevector input ports
\f
;;;; Printing
-(define (define-unparser-method predicate unparser)
- (defer-boot-action 'unparser-methods
+(define (define-print-method predicate print-method)
+ (defer-boot-action 'print-methods
(lambda ()
- (define-unparser-method predicate unparser))))
+ (define-print-method predicate print-method))))
+
+(define (standard-print-method name #!optional get-parts)
+ (%record standard-print-method-tag
+ name
+ (if (and get-parts (not (default-object? get-parts)))
+ get-parts
+ (lambda (object)
+ (declare (ignore object))
+ '()))))
+
+;;; Would have used normal records here but the record abstraction is defined
+;;; after this is needed.
+
+(define (standard-print-method? object)
+ (and (%record? object)
+ (fix:= 3 (%record-length object))
+ (eq? standard-print-method-tag (%record-ref object 0))))
+
+(define (standard-print-method-name spm object)
+ (let ((name (%record-ref spm 1)))
+ (if (procedure? name)
+ (name object)
+ name)))
+
+(define (standard-print-method-parts spm object)
+ ((%record-ref spm 2) object))
+
+(define-integrable standard-print-method-tag
+ '|#[standard-print-method-tag]|)
+
+(define (bracketed-print-method name printer)
+ (lambda (object port)
+ (if (get-param:print-with-maximum-readability?)
+ (begin
+ (write-string "#@" port)
+ (write (hash-object object) port))
+ (begin
+ (write-string "#[" port)
+ (display (if (procedure? name) (name object) name) port)
+ (write-char #\space port)
+ (write (hash-object object) port)
+ (if printer (printer object port))
+ (write-char #\] port)))))
(define (define-pp-describer predicate describer)
(defer-boot-action 'pp-describers
(lambda ()
(define-pp-describer predicate describer))))
-(define (unparser-method? object)
- (and (procedure? object)
- (procedure-arity-valid? object 2)))
-
-(define (general-unparser-method procedure)
- (lambda (state object)
- (with-current-unparser-state state
- (lambda (port)
- (if (get-param:print-with-maximum-readability?)
- (begin
- (write-string "#@" port)
- (write (hash-object object) port))
- (procedure object port))))))
-
-(define (bracketed-unparser-method procedure)
- (general-unparser-method
- (lambda (object port)
- (write-string "#[" port)
- (procedure object port)
- (write-char #\] port))))
-
-(define (standard-unparser-method name procedure)
- (bracketed-unparser-method
- (lambda (object port)
- (display (if (procedure? name)
- (name object)
- name)
- port)
- (write-char #\space port)
- (write (hash-object object) port)
- (if procedure (procedure object port)))))
-
-(define (simple-unparser-method name get-parts)
- (standard-unparser-method name
- (and get-parts
- (lambda (object port)
- (for-each (lambda (object)
- (write-char #\space port)
- (write object port))
- (get-parts object))))))
-
(define (simple-parser-method procedure)
(lambda (objects lose)
(or (and (pair? (cdr objects))
bundle?
(alist bundle-alist))
-(define-unparser-method bundle?
- (standard-unparser-method
- (lambda (bundle)
- (record-type-name (record-type-descriptor bundle)))
- (lambda (bundle port)
- (let ((handler (bundle-ref bundle 'write-self #f)))
- (if handler
- (handler port))))))
+(define-print-method bundle?
+ (standard-print-method
+ (lambda (bundle)
+ (record-type-name (record-type-descriptor bundle)))
+ (lambda (bundle)
+ (let ((handler (bundle-ref bundle 'summarize-self #f)))
+ (if handler
+ (handler)
+ '())))))
(define-pp-describer bundle?
(lambda (bundle)
(constructor %make-condition-variable
(name waiter-head waiter-tail))
(print-procedure
- (simple-unparser-method 'condition-variable
+ (standard-print-method 'condition-variable
(lambda (condvar)
(cond ((condition-variable-name condvar) => list)
(else '()))))))
(symbol (parser-context/name context) '?))
(define (default-unparser-text context)
- `(,(absolute 'standard-unparser-method context)
- ',(parser-context/name context)
- #f))
+ `(,(absolute 'standard-print-method context)
+ ',(parser-context/name context)))
(define (default-type-name context)
(symbol 'rtd: (parser-context/name context)))
(or (structure/record-type? structure)
(structure/tagged? structure)))
(let ((context (structure/context structure)))
- `((define-unparser-method
+ `((define-print-method
,(close (structure/predicate structure) context)
,(close (structure/print-procedure structure) context))))
'()))
\ No newline at end of file
(guarantee dispatch-tag? superset 'add-dispatch-tag-superset)
(%add-to-weak-set superset (%tag-supersets tag)))
-(define-unparser-method dispatch-tag?
- (simple-unparser-method
+(define-print-method dispatch-tag?
+ (standard-print-method
(lambda (tag)
(if (dispatch-metatag? tag) 'dispatch-metatag 'dispatch-tag))
(lambda (tag)
(constructor %make-condition-type
(name field-indexes number-of-fields reporter))
(print-procedure
- (standard-unparser-method 'condition-type
- (lambda (type port)
- (write-char #\space port)
- (write-string (%condition-type/name type) port)))))
+ (standard-print-method 'condition-type
+ (lambda (type)
+ (list (%condition-type/name type))))))
(name #f read-only #t)
generalizations
(field-indexes #f read-only #t)
(compute-field-indexes generalization field-names))
(lambda (n-fields field-indexes)
(%make-condition-type
- (cond ((string? name) (string-copy name))
+ (cond ((string? name) (string->immutable name))
((symbol? name) (symbol->string name))
((not name) "(anonymous)")
(else
(constructor %%make-condition
(type continuation restarts field-values))
(print-procedure
- (standard-unparser-method 'condition
- (lambda (condition port)
- (write-char #\space port)
- (write-string
- (%condition-type/name (%condition/type condition))
- port)))))
+ (standard-print-method 'condition
+ (lambda (condition)
+ (list (%condition-type/name
+ (%condition/type condition)))))))
(type #f read-only #t)
(continuation #f read-only #t)
(restarts #f read-only #t)
(constructor %make-restart
(name reporter effector interactor))
(print-procedure
- (standard-unparser-method 'restart
- (lambda (restart port)
- (write-char #\space port)
+ (standard-print-method 'restart
+ (lambda (restart)
(let ((name (%restart/name restart)))
(if name
- (write name port)
- (write-string "(anonymous)" port)))))))
+ (list name)
+ '()))))))
(name #f read-only #t)
(reporter #f read-only #t)
(effector #f read-only #t)
;; two digits representing a larger number, then RADIX is their base.
(define %radix)
-(define-unparser-method alien?
- (standard-unparser-method
+(define-print-method alien?
+ (bracketed-print-method
'alien
(lambda (alien port)
(write-char #\space port)
;; To be fasdump/loadable.
(type vector) (named 'alien-function)
(print-procedure
- (standard-unparser-method 'alien-function
+ (bracketed-print-method 'alien-function
(lambda (alienf port)
(write-char #\space port)
(write-string (%alien-function/name alienf)
opt val)))
(define-structure (gdbf
- (print-procedure (simple-unparser-method 'gdbf
+ (print-procedure (standard-print-method 'gdbf
(lambda (gdbf)
(list (gdbf-filename gdbf))))))
descriptor
operation/set-line-style
custom-operations))
(print-procedure
- (simple-unparser-method 'graphics-type
+ (standard-print-method 'graphics-type
(lambda (type)
(list (graphics-device-type/name type))))))
(name false read-only true)
(list (cons 'name name) ...)))))
env))
+ (if (unbound? env 'standard-print-method)
+ (eval '(define (standard-print-method name #!optional get-parts)
+ (simple-unparser-method name
+ (if (default-object? get-parts)
+ #f
+ get-parts)))
+ env))
+ (provide-rename env 'standard-unparser-method 'bracketed-print-method)
+
(for-each (lambda (old-name)
(provide-rename env old-name (symbol 'scode- old-name)))
'(access-environment
(guarantee-headers&body headers body 'make-http-request)
(%make-http-request method uri version headers body)))
-(define-unparser-method http-request?
- (simple-unparser-method 'http-request
+(define-print-method http-request?
+ (standard-print-method 'http-request
(lambda (request)
(list (http-request-method request)
(uri->string (http-request-uri request))))))
(guarantee-headers&body headers body 'make-http-response)
(%make-http-response version status reason headers body)))
-(define-unparser-method http-response?
- (simple-unparser-method 'http-response
+(define-print-method http-response?
+ (standard-print-method 'http-response
(lambda (response)
(list (http-response-status response)))))
(define-guarantee http-header "HTTP header field")
-(define-unparser-method http-header?
- (simple-unparser-method 'http-header
+(define-print-method http-header?
+ (standard-print-method 'http-header
(lambda (header)
(list (http-header-name header)))))
(make-record-type "package" '(parent children name environment))))
(set! package-tag rtd)
(for-each (lambda (p) (%record-set! p 0 rtd)) *packages*)
- (define-unparser-method (record-predicate rtd)
- (simple-unparser-method 'package
+ (define-print-method (record-predicate rtd)
+ (standard-print-method 'package
(lambda (package)
(list (package/name package)))))))
\f
(define-guarantee pathname "pathname")
-(define-unparser-method pathname?
- (simple-unparser-method 'pathname
+(define-print-method pathname?
+ (standard-print-method 'pathname
(lambda (pathname)
(list (->namestring pathname)))))
(define (initialize-unparser!)
(unparser/set-tagged-pair-method! population-tag
- (standard-unparser-method 'population #f)))
+ (standard-print-method 'population)))
(define bogus-false '(bogus-false))
(define population-tag '(population))
'<= procedure?)
(register-predicate! procedure-arity? 'procedure-arity)
(register-predicate! thunk? 'thunk '<= procedure?)
- (register-predicate! unary-procedure? 'unary-procedure '<= procedure?)
- (register-predicate! unparser-method? 'unparser-method '<= procedure?)))
+ (register-predicate! unary-procedure? 'unary-procedure '<= procedure?)))
\f
(add-boot-init!
(lambda ()
(let ((table (make-strong-eq-hash-table)))
(define (walk object)
- (cond ((pair? object)
+ (cond ((get-print-method-parts object)
+ => (lambda (parts)
+ (if (mark! object)
+ (for-each walk parts))))
+ ((pair? object)
(if (mark! object)
(begin
(walk (car object))
(print-number (cdr label) context)
(*print-char (if def? #\= #\#) context)
def?))
+\f
+(define (print-object-1 object context)
+ (let ((print-method (get-print-method object)))
+ (cond ((standard-print-method? print-method)
+ (*print-with-brackets
+ (standard-print-method-name print-method object)
+ object
+ context
+ (lambda (context*)
+ (for-each (lambda (part)
+ (*print-char #\space context*)
+ (print-object part context*))
+ (standard-print-method-parts print-method object)))))
+ (print-method
+ (parameterize* (list (cons initial-context context))
+ (lambda ()
+ (print-method object (context-port context)))))
+ (else
+ ((vector-ref dispatch-table
+ ((ucode-primitive primitive-object-type 1) object))
+ object
+ context)))))
-(define-deferred print-object-1
- (standard-predicate-dispatcher 'print-object-1 2))
+(define (get-print-method-parts object)
+ (let ((print-method (get-print-method object)))
+ (and (standard-print-method? print-method)
+ (standard-print-method-parts print-method object))))
+
+(define-deferred get-print-method
+ (standard-predicate-dispatcher 'get-print-method 1))
(add-boot-init!
(lambda ()
- (define-predicate-dispatch-default-handler print-object-1
- (lambda (object context)
- ((vector-ref dispatch-table
- ((ucode-primitive primitive-object-type 1) object))
- object
- context)))
- (set! define-unparser-method
- (named-lambda (define-unparser-method predicate unparser)
- (define-predicate-dispatch-handler print-object-1
- (list predicate context?)
- unparser)))
- (run-deferred-boot-actions 'unparser-methods)))
+ (set! define-print-method
+ (named-lambda (define-print-method predicate print-method)
+ (define-predicate-dispatch-handler get-print-method
+ (list predicate)
+ (lambda (object)
+ (declare (ignore object))
+ print-method))))
+ (define-predicate-dispatch-default-handler get-print-method
+ (lambda (object)
+ (declare (ignore object))
+ #f))
+ (run-deferred-boot-actions 'print-methods)))
\f
(define dispatch-table)
(add-boot-init!
(char-in-set? char (context-char-set context)))
(define (*print-with-brackets name object context procedure)
- (if (or (and (get-param:print-with-maximum-readability?) object)
- (context-in-brackets? context))
+ (if (and (get-param:print-with-maximum-readability?) object)
(*print-readable-hash object context)
(begin
(*print-string "#[" context)
(*print-char #\space context*)
(*print-hash object context*)))
(cond (procedure
- (*print-char #\space context*)
(procedure context*))
((get-param:print-with-datum?)
(*print-char #\space context*)
((non-pointer)
(*print-with-brackets type object context
(lambda (context*)
+ (*print-char #\space context*)
(*print-datum object context*))))
(else ;UNDEFINED, GC-INTERNAL
(*print-with-brackets type #f context
(lambda (context*)
+ (*print-char #\space context*)
(*print-datum object context*)))))))
(define (user-object-type object)
(print-symbol-name (symbol->string symbol) context)
(*print-with-brackets 'uninterned-symbol symbol context
(lambda (context*)
+ (*print-char #\space context*)
(*print-string (symbol->string symbol) context*)))))
(define (print-symbol symbol context)
(begin
(*print-char #\space context*)
(print-object (safe-vector-ref vector index)
- context*)
+ context*)
(loop (fix:+ index 1))))))
(*print-char #\) context*))
(*print-string "#()" context*))))))))
(begin
(*print-char #\space context*)
(print-number (bytevector-u8-ref bytevector index)
- context*)
+ context*)
(loop (fix:+ index 1))))))
(*print-char #\) context*))
(*print-string "#u8()" context*))))))
required optional rest body
(and (not (eq? name scode-lambda-name:unnamed))
(lambda (context*)
+ (*print-char #\space context*)
(print-object name context*))))))))
(define (print-primitive-procedure procedure context)
((get-param:print-with-maximum-readability?)
(*print-readable-hash procedure context))
(else
- (*print-with-brackets 'primitive-procedure #f context print-name)))))
+ (*print-with-brackets 'primitive-procedure #f context
+ (lambda (context*)
+ (*print-char #\space context*)
+ (print-name context*)))))))
(define (print-compiled-entry entry context)
(let* ((type (compiled-entry-type entry))
(let ((name (and procedure? (compiled-procedure/name entry))))
(receive (filename block-number)
(compiled-entry/filename-and-index entry)
+ (*print-char #\space context*)
(*print-char #\( context*)
(if name
(*print-string name context*))
(define (print-return-address return-address context)
(*print-with-brackets 'return-address return-address context
(lambda (context*)
+ (*print-char #\space context*)
(print-object (return-address/name return-address) context*))))
(define (print-assignment assignment context)
(*print-with-brackets 'assignment assignment context
(lambda (context*)
+ (*print-char #\space context*)
(print-object (scode-assignment-name assignment) context*))))
(define (print-definition definition context)
(*print-with-brackets 'definition definition context
(lambda (context*)
+ (*print-char #\space context*)
(print-object (scode-definition-name definition) context*))))
(define (print-lambda lambda-object context)
(*print-with-brackets 'lambda lambda-object context
(lambda (context*)
+ (*print-char #\space context*)
(print-object (scode-lambda-name lambda-object) context*))))
(define (print-variable variable context)
(*print-with-brackets 'variable variable context
(lambda (context*)
+ (*print-char #\space context*)
(print-object (scode-variable-name variable) context*))))
(define (print-number object context)
(if limit
(min length limit)
length))))
- (print-flonum ((ucode-primitive floating-vector-ref) v 0)
+ (*print-char #\space context*)
+ (print-flonum ((ucode-primitive floating-vector-ref) v 0)
context*)
(do ((i 1 (+ i 1)))
((>= i limit))
(define (named-arity-dispatched-procedure name)
(*print-with-brackets 'arity-dispatched-procedure entity context
(lambda (context*)
- (*print-string name context*))))
+ (*print-char #\space context*)
+ (*print-string name context*))))
(cond ((continuation? entity)
(plain 'continuation))
(*print-with-brackets 'promise promise context
(if (promise-forced? promise)
(lambda (context*)
- (*print-string "(evaluated) " context*)
+ (*print-string " (evaluated) " context*)
(print-object (promise-value promise) context*))
(lambda (context*)
- (*print-string "(unevaluated)" context*)
+ (*print-string " (unevaluated)" context*)
(if (get-param:print-with-datum?)
(begin
(*print-char #\space context*)
(define (print-tagged-object object context)
(*print-with-brackets 'tagged-object object context
(lambda (context*)
+ (*print-char #\space context*)
(print-object (let ((tag (%tagged-object-tag object)))
(if (dispatch-tag? tag)
(dispatch-tag-name tag)
tag))
context*)
- (*print-string " " context*)
- (print-object (%tagged-object-datum object) context*))))
\ No newline at end of file
+ (*print-char #\space context*)
+ (print-object (%tagged-object-datum object) context*))))
(define (initialize-unparser!)
(unparser/set-tagged-pair-method! 1d-table-tag
- (standard-unparser-method '1d-table #f)))
+ (standard-print-method '1d-table)))
(define population-of-1d-tables)
'#(index borrow vector)
'#(1 2 3)
(make-vector 3 (lambda () #f))
- (standard-unparser-method 'random-state #f)
+ (standard-print-method 'random-state)
random-state-tag
4)))
\ No newline at end of file
#f)))
(if (and unparser-method
(not (default-object? unparser-method)))
- (define-unparser-method (record-predicate type) unparser-method))
+ (define-print-method (record-predicate type) unparser-method))
type))
(define (list-of-unique-symbols? object)
\f
;;;; Printing
-(define-unparser-method %record?
- (standard-unparser-method '%record #f))
+(define-print-method %record?
+ (standard-print-method '%record))
-(define-unparser-method record?
- (standard-unparser-method
+(define-print-method record?
+ (standard-print-method
(lambda (record)
(strip-angle-brackets
- (dispatch-tag-name (record-type-descriptor record))))
- #f))
+ (dispatch-tag-name (record-type-descriptor record))))))
(add-boot-init!
(lambda ()
- (define-unparser-method record-type?
- (simple-unparser-method 'record-type
+ (define-print-method record-type?
+ (standard-print-method 'record-type
(lambda (type)
(list (dispatch-tag-name type)))))))
;;; For backwards compatibility:
(define (set-record-type-unparser-method! record-type method)
- (define-unparser-method (record-predicate record-type)
+ (define-print-method (record-predicate record-type)
method))
\f
;;;; Runtime support for DEFINE-STRUCTURE
(define structure-type/length)
(add-boot-init!
(lambda ()
- ;; unparser-method arg should be removed after 9.3 is released.
+ ;; unparser-method field should be removed after 9.3 is released.
(set! rtd:structure-type
(make-record-type "structure-type"
'(physical-type name field-names field-indexes
(type vector)
(named '|#[(runtime reference-trap)reference-trap]|)
(print-procedure
- (simple-unparser-method 'reference-trap
+ (standard-print-method 'reference-trap
(lambda (trap)
(list (let ((kind (reference-trap-kind trap)))
(or (reference-trap-kind-name kind)
(define-guarantee rfc2822-header "RFC 2822 header field")
-(define-unparser-method rfc2822-header?
- (simple-unparser-method 'rfc2822-header
+(define-print-method rfc2822-header?
+ (standard-print-method 'rfc2822-header
(lambda (header)
(list (rfc2822-header-name header)))))
(define-package (runtime boot-definitions)
(files "boot")
(parent (runtime))
+ (export () deprecated:boot-definitions
+ (define-unparser-method define-print-method)
+ (simple-unparser-method standard-print-method)
+ (standard-unparser-method bracketed-print-method))
(export ()
%false->weak-false
%make-record
%weak-false->false
%weak-false?
%weak-set-car!
- bracketed-unparser-method
+ bracketed-print-method
bytes-per-object
default-object
default-object?
define-pp-describer
- define-unparser-method
+ define-print-method
error:not-a
error:not-a-list-of
gc-space-status
- general-unparser-method
guarantee
guarantee-list-of
interrupt-bit/after-gc
set-dispatch-tag<=!
set-predicate<=!
simple-parser-method
- simple-unparser-method
- standard-unparser-method
- unparser-method?
+ standard-print-method
weak-car
weak-cdr
weak-cons
%weak-car)
(export (runtime predicate)
set-predicate-tag!)
+ (export (runtime printer)
+ standard-print-method-name
+ standard-print-method-parts
+ standard-print-method?)
(export (runtime rep)
finished-booting!)
(export (runtime tagged-dispatch)
(import (runtime save/restore)
time-world-restored)
(export ()
- world-report))
\ No newline at end of file
+ world-report))
(define top-level-mime-types
'#(text image audio video application multipart message))
-(define-unparser-method mime-type?
- (standard-unparser-method 'mime-type
- (lambda (mime-type port)
- (write-char #\space port)
- (write-string (mime-type->string mime-type) port))))
+(define-print-method mime-type?
+ (standard-print-method 'mime-type
+ (lambda (mime-type)
+ (list (mime-type->string mime-type)))))
(define interned-mime-types)
(define unusual-interned-mime-types)
(rename senv-rename)
(describe senv-describe))
-(define-unparser-method syntactic-environment?
- (simple-unparser-method 'syntactic-environment
+(define-print-method syntactic-environment?
+ (standard-print-method 'syntactic-environment
(lambda (senv)
(list ((senv-get-type senv))))))
var-item?
(id var-item-id))
-(define-unparser-method var-item?
- (simple-unparser-method 'var-item
+(define-print-method var-item?
+ (standard-print-method 'var-item
(lambda (item)
(list (var-item-id item)))))
(value defn-item-value)
(syntax? defn-item-syntax?))
-(define-unparser-method defn-item?
- (simple-unparser-method 'defn-item
+(define-print-method defn-item?
+ (standard-print-method 'defn-item
(lambda (item)
(list (defn-item-id item)
(defn-item-value item)))))
(flush-output port-type-operation:flush-output)
(discretionary-flush-output port-type-operation:discretionary-flush-output))
-(define-unparser-method textual-port-type?
- (standard-unparser-method
+(define-print-method textual-port-type?
+ (standard-print-method
(lambda (type)
(if (port-type-supports-input? type)
(if (port-type-supports-output? type)
'textual-input-port-type)
(if (port-type-supports-output? type)
'textual-output-port-type
- 'textual-port-type)))
- #f))
+ 'textual-port-type)))))
(define (port-type-supports-input? type)
(port-type-operation:read-char type))
(register-predicate! textual-i/o-port? 'textual-i/o-port
'<= textual-port?)
-(define-unparser-method textual-port?
- (standard-unparser-method
+(define-print-method textual-port?
+ (bracketed-print-method
(lambda (port)
(cond ((textual-i/o-port? port) 'textual-i/o-port)
((textual-input-port? port) 'textual-input-port)
(define-structure (thread-queue (constructor %make-thread-queue)
(conc-name %thread-queue/)
(print-procedure
- (standard-unparser-method
+ (bracketed-print-method
'thread-queue
(lambda (queue port)
(print-thread-queue queue port)))))
'#(waiting-threads owner)
'#(1 2)
(vector 2 (lambda () #f))
- (standard-unparser-method 'thread-mutex #f)
+ (standard-print-method 'thread-mutex)
thread-mutex-tag
3))
(named-structure/set-tag-description! link-tag
'#(prev next item)
'#(1 2 3)
(vector 3 (lambda () #f))
- (standard-unparser-method 'link #f)
+ (standard-print-method 'link)
link-tag
4)))
(host uri-authority-host)
(port uri-authority-port))
-(define-unparser-method uri-authority?
- (simple-unparser-method 'uri-authority
+(define-print-method uri-authority?
+ (standard-print-method 'uri-authority
(lambda (authority)
(list (call-with-output-string
(lambda (port)
(fragment partial-uri-fragment set-partial-uri-fragment!)
(extra partial-uri-extra set-partial-uri-extra!))
-(define-unparser-method partial-uri?
- (standard-unparser-method 'partial-uri
+(define-print-method partial-uri?
+ (bracketed-print-method 'partial-uri
(lambda (puri port)
(write-char #\space port)
(write-partial-uri puri port))))
(constructor %make-registry-key (parent name handle))
(predicate win32-registry/key?)
(print-procedure
- (simple-unparser-method 'registry-key
+ (standard-print-method 'registry-key
(lambda (key)
(list (registry-key-name key))))))
(name #f read-only #t)
(define-structure (registry-value
(print-procedure
- (simple-unparser-method 'registry-value
+ (standard-print-method 'registry-value
(lambda (key)
(list (registry-value-name key))))))
(name #f read-only #t)
(conc-name x-display/)
(constructor make-x-display (name xd))
(print-procedure
- (simple-unparser-method 'x-display
+ (standard-print-method 'x-display
(lambda (display)
(list (x-display/name display))))))
(name #f read-only #t)
(conc-name variable/)
(constructor variable/make (block name flags))
(print-procedure
- (simple-unparser-method 'variable
+ (standard-print-method 'variable
(lambda (var)
(list (variable/name var))))))
block
(conc-name reference/)
(constructor reference/make)
(print-procedure
- (simple-unparser-method 'reference
+ (standard-print-method 'reference
(lambda (ref)
(list (variable/name (reference/variable ref)))))))
(scode #f read-only #t)
(unparser/set-tagged-pair-method!
pathname-map/tag
- (standard-unparser-method "PATHNAME-MAP" #f))
+ (standard-print-method "PATHNAME-MAP"))
(declare (integrate-operator node/make))
(constructor %make-class
(name direct-superclasses direct-slots))
(print-procedure
- (simple-unparser-method 'CLASS
+ (standard-print-method 'CLASS
(lambda (class)
(let ((name (class-name class)))
(if name
(thunk))
(write-char #\] port))
\f
-(define-unparser-method instance?
- (general-unparser-method write-instance))
+(define-print-method instance?
+ write-instance)
(define (instance-description instance)
(map (lambda (slot)
(conc-name module/)
(constructor %make-module)
(print-procedure
- (simple-unparser-method 'MODULE
+ (standard-print-method 'MODULE
(lambda (module)
(list (module/load-name module))))))
load-name
(conc-name x-display/)
(constructor make-x-display (name xd))
(print-procedure
- (simple-unparser-method 'X-DISPLAY
+ (standard-print-method 'X-DISPLAY
(lambda (display)
(list (x-display/name display))))))
(name #f read-only #t)
(define-guarantee rdf-bnode "RDF bnode")
-(define-unparser-method rdf-bnode?
- (standard-unparser-method 'RDF-BNODE
- (lambda (bnode port)
- (write-char #\space port)
- (write-string (rdf-bnode-name bnode) port))))
+(define-print-method rdf-bnode?
+ (standard-print-method 'rdf-bnode
+ (lambda (bnode)
+ (list (rdf-bnode-name bnode)))))
(define (make-rdf-bnode #!optional name)
(if (default-object? name)
(and (not (absolute-uri? type))
type)))
-(define-unparser-method rdf-literal?
- (standard-unparser-method 'RDF-LITERAL
+(define-print-method rdf-literal?
+ (bracketed-print-method 'RDF-LITERAL
(lambda (literal port)
(write-char #\space port)
(write-rdf/nt-literal literal port))))
(qname combo-name-qname)
(expanded combo-name-expanded))
-(define-unparser-method combo-name?
- (simple-unparser-method 'XML-NAME
+(define-print-method combo-name?
+ (standard-print-method 'XML-NAME
(lambda (name)
(list (combo-name-qname name)))))
(indent-attributes? ctx-indent-attributes?)
(indent-dtd? ctx-indent-dtd?))
-(define-unparser-method ctx?
- (standard-unparser-method 'xml-output-context #f))
+(define-print-method ctx?
+ (standard-print-method 'xml-output-context))
(define (emit-char char ctx)
(let ((port (ctx-port ctx)))
(let ((name (cadr form))
(accessor (caddr form)))
(let ((root (symbol 'XML- name)))
- `(define-unparser-method
+ `(define-print-method
,(close-syntax (symbol root '?) environment)
- (SIMPLE-UNPARSER-METHOD ',root
+ (standard-print-method ',root
(LAMBDA (,name)
(LIST (,(close-syntax accessor environment) ,name)))))))
(ill-formed-syntax form)))))