#| -*-Scheme-*-
-$Id: defstr.scm,v 14.22 1992/12/28 21:56:38 cph Exp $
+$Id: defstr.scm,v 14.23 1993/03/07 20:56:20 cph Exp $
-Copyright (c) 1988-1992 Massachusetts Institute of Technology
+Copyright (c) 1988-93 Massachusetts Institute of Technology
This material was developed by the Scheme project at the Massachusetts
Institute of Technology, Department of Electrical Engineering and
(keyword-constructors '())
(copier-name false)
(predicate-name (symbol-append name '?))
- (print-procedure `(,(absolute 'UNPARSER/STANDARD-METHOD) ',name))
+ (print-procedure default)
(type 'RECORD)
(type-name name)
(tag-expression)
(cdr option-seen))))))
(if predicate-name
(check (assq 'PREDICATE options-seen)))
- (if print-procedure
+ (if (and (not (eq? print-procedure default)) print-procedure)
(check (assq 'PRINT-PROCEDURE options-seen)))))
(make-structure name
conc-name
'()))
copier-name
(and named? predicate-name)
- (and named? print-procedure)
+ (and named?
+ (cond ((not (eq? print-procedure default))
+ print-procedure)
+ ((eq? type 'RECORD)
+ false)
+ (else
+ `(,(absolute 'UNPARSER/STANDARD-METHOD)
+ ',name))))
type
named?
(and named? type-name)
(and named? tag-expression)
offset
slots)))))
+
+(define default
+ (list 'DEFAULT))
\f
;;;; Parse Slot-Descriptions
#| -*-Scheme-*-
-$Id: make.scm,v 14.44 1993/03/01 17:40:20 gjr Exp $
+$Id: make.scm,v 14.45 1993/03/07 20:56:21 cph Exp $
Copyright (c) 1988-1993 Massachusetts Institute of Technology
("list" . (RUNTIME LIST))
("symbol" . ())
("uproc" . (RUNTIME PROCEDURE))
+ ("poplat" . (RUNTIME POPULATION))
("record" . (RUNTIME RECORD))))
(files2
'(("defstr" . (RUNTIME DEFSTRUCT))
- ("poplat" . (RUNTIME POPULATION))
("prop1d" . (RUNTIME 1D-PROPERTY))
("events" . (RUNTIME EVENT-DISTRIBUTOR))
("gdatab" . (RUNTIME GLOBAL-DATABASE))))
'CONSTANT-SPACE/BASE
constant-space/base)
(package-initialize '(RUNTIME LIST) 'INITIALIZE-PACKAGE! true)
+ (package-initialize '(RUNTIME POPULATION) 'INITIALIZE-PACKAGE! true)
(package-initialize '(RUNTIME RECORD) 'INITIALIZE-PACKAGE! true)
(package-initialize '(PACKAGE) 'FINALIZE-PACKAGE-RECORD-TYPE! true)
(load-files files2)
- (package-initialize '(RUNTIME POPULATION) 'INITIALIZE-PACKAGE! true)
(package-initialize '(RUNTIME 1D-PROPERTY) 'INITIALIZE-PACKAGE! true)
(package-initialize '(RUNTIME EVENT-DISTRIBUTOR) 'INITIALIZE-PACKAGE! true)
(package-initialize '(RUNTIME GLOBAL-DATABASE) 'INITIALIZE-PACKAGE! true)
#| -*-Scheme-*-
-$Id: record.scm,v 1.19 1992/12/17 00:05:34 cph Exp $
+$Id: record.scm,v 1.20 1993/03/07 20:56:21 cph Exp $
-Copyright (c) 1989-1992 Massachusetts Institute of Technology
+Copyright (c) 1989-93 Massachusetts Institute of Technology
This material was developed by the Scheme project at the Massachusetts
Institute of Technology, Department of Electrical Engineering and
(primitive-object-set! 3)
(primitive-object-set-type 2))
+(define record-type-type)
+(define record-type-population)
+(define record-type-initialization-hook)
+
+(define (initialize-package!)
+ (set! record-type-type
+ (let ((record-type-type
+ (%record false
+ false
+ "record-type"
+ '(RECORD-TYPE-APPLICATION-METHOD
+ RECORD-TYPE-NAME
+ RECORD-TYPE-FIELD-NAMES
+ RECORD-TYPE-METHODS
+ RECORD-TYPE-CLASS-WRAPPER)
+ '()
+ false)))
+ (%record-set! record-type-type 0 record-type-type)
+ (%record-type-has-application-method! record-type-type)
+ record-type-type))
+ (set! record-type-population (make-population))
+ (set! record-type-initialization-hook false)
+ (add-to-population! record-type-population record-type-type))
+
(define-integrable (%record? object)
(object-type? (ucode-type record) object))
false
(->string type-name)
(list-copy field-names)
+ false
false)))
(%record-type-has-application-method! record-type)
+ (add-to-population! record-type-population record-type)
+ (if record-type-initialization-hook
+ (record-type-initialization-hook record-type))
record-type))
(define (record-type? object)
(%record-ref record-type 3))
(define (record-type-unparser-method record-type)
- (guarantee-record-type record-type 'RECORD-TYPE-UNPARSER-METHOD)
- (%record-type/unparser-method record-type))
-
-(define-integrable (%record-type/unparser-method record-type)
- (%record-ref record-type 4))
+ (record-type-method record-type 'UNPARSER))
(define (set-record-type-unparser-method! record-type method)
- (guarantee-record-type record-type 'SET-RECORD-TYPE-UNPARSER-METHOD!)
(if (not (or (not method) (procedure? method)))
(error:wrong-type-argument method "unparser method"
'SET-RECORD-TYPE-UNPARSER-METHOD!))
- (%record-set! record-type 4 method))
-
-(define record-type-type)
-
-(define (initialize-package!)
- (set! record-type-type
- (let ((record-type-type
- (%record false
- false
- "record-type"
- '(RECORD-TYPE-APPLICATION-METHOD
- RECORD-TYPE-NAME
- RECORD-TYPE-FIELD-NAMES
- RECORD-TYPE-UNPARSER-METHOD)
- false)))
- (%record-set! record-type-type 0 record-type-type)
- (%record-type-has-application-method! record-type-type)
- record-type-type))
- unspecific)
+ (set-record-type-method! record-type 'UNPARSER method))
+
+(define (record-type-method record-type keyword)
+ (guarantee-record-type record-type 'RECORD-TYPE-METHOD)
+ (let ((entry (assq keyword (%record-ref record-type 4))))
+ (and entry
+ (cdr entry))))
+
+(define (set-record-type-method! record-type keyword method)
+ (guarantee-record-type record-type 'SET-RECORD-TYPE-METHOD!)
+ (let ((methods (%record-ref record-type 4)))
+ (let ((entry (assq keyword methods)))
+ (if method
+ (if entry
+ (set-cdr! entry method)
+ (%record-set! record-type 4
+ (cons (cons keyword method) methods)))
+ (if entry
+ (%record-set! record-type 4 (delq! entry methods)))))))
(define (record-type-field-index record-type field-name procedure-name)
(let loop ((field-names (%record-type/field-names record-type)) (index 1))
(guarantee-record record 'RECORD-COPY)
(%record-copy record))
-(define (%record-unparser-method record)
- ;; Used by unparser. Assumes RECORD has type-code RECORD.
- (let ((type (%record-ref record 0)))
- (and (record-type? type)
- (or (%record-type/unparser-method type)
- (unparser/standard-method (record-type-name type))))))
-
(define (record-description record)
(let ((type (record-type-descriptor record)))
- (map (lambda (field-name)
- `(,field-name ,((record-accessor type field-name) record)))
- (record-type-field-names type))))
+ (let ((method (record-type-method type 'DESCRIPTION)))
+ (if method
+ (method record)
+ (map (lambda (field-name)
+ `(,field-name ,((record-accessor type field-name) record)))
+ (record-type-field-names type))))))
(define (record-predicate record-type)
(guarantee-record-type record-type 'RECORD-PREDICATE)
#| -*-Scheme-*-
-$Id: runtime.pkg,v 14.174 1993/01/29 16:42:08 cph Exp $
+$Id: runtime.pkg,v 14.175 1993/03/07 20:56:22 cph Exp $
Copyright (c) 1988-1993 Massachusetts Institute of Technology
%record-ref
%record-set!
%record-type-has-application-method!
- %record-unparser-method
%record?
make-record-type
record-accessor
record-type-application-method
record-type-descriptor
record-type-field-names
+ record-type-method
record-type-name
record-type-unparser-method
record-type?
record-updater
record?
set-record-type-application-method!
+ set-record-type-method!
set-record-type-unparser-method!)
(initialization (initialize-package!)))
#| -*-Scheme-*-
-$Id: unpars.scm,v 14.29 1992/12/07 19:07:00 cph Exp $
+$Id: unpars.scm,v 14.30 1993/03/07 20:56:23 cph Exp $
-Copyright (c) 1988-92 Massachusetts Institute of Technology
+Copyright (c) 1988-93 Massachusetts Institute of Technology
This material was developed by the Scheme project at the Massachusetts
Institute of Technology, Department of Electrical Engineering and
(set! string-delimiters
(char-set-union char-set:not-graphic (char-set #\" #\\)))
(set! hook/interned-symbol unparse-symbol)
+ (set! hook/unparse-record false)
+ (set! hook/procedure-unparser false)
(set! *unparser-radix* 10)
(set! *unparser-list-breadth-limit* false)
(set! *unparser-list-depth-limit* false)
(vector-ref vector index))
(define (unparse/record record)
- (let ((method (%record-unparser-method record)))
- (if method
- (invoke-user-method method record)
- (unparse/default record))))
+ (if (record? record)
+ (let ((type (record-type-descriptor record)))
+ (let ((method
+ (or (record-type-unparser-method type)
+ hook/unparse-record)))
+ (if method
+ (invoke-user-method method record)
+ (*unparse-with-brackets (record-type-name type) record #f))))
+ (unparse/default record)))
+
+(define hook/unparse-record)
\f
(define (unparse/pair pair)
(let ((prefix (unparse-list/prefix-pair? pair)))
\f
;;;; Procedures and Environments
+(define hook/procedure-unparser)
+
+(define (unparse-procedure procedure usual-method)
+ (let ((method
+ (and hook/procedure-unparser
+ (hook/procedure-unparser procedure))))
+ (if method
+ (invoke-user-method method procedure)
+ (usual-method))))
+
(define (unparse/compound-procedure procedure)
- (*unparse-with-brackets 'COMPOUND-PROCEDURE procedure
- (lambda-components* (procedure-lambda procedure)
- (lambda (name required optional rest body)
- required optional rest body
+ (unparse-procedure procedure
+ (lambda ()
+ (*unparse-with-brackets 'COMPOUND-PROCEDURE procedure
(and *unparse-compound-procedure-names?*
- (not (eq? name lambda-tag:unnamed))
- (lambda () (*unparse-object name)))))))
+ (lambda-components* (procedure-lambda procedure)
+ (lambda (name required optional rest body)
+ required optional rest body
+ (and (not (eq? name lambda-tag:unnamed))
+ (lambda () (*unparse-object name))))))))))
(define (unparse/primitive-procedure procedure)
- (let ((unparse-name
- (lambda ()
- (*unparse-object (primitive-procedure-name procedure)))))
- (cond (*unparse-primitives-by-name?*
- (unparse-name))
- (*unparse-with-maximum-readability?*
- (*unparse-readable-hash procedure))
- (else
- (*unparse-with-brackets 'PRIMITIVE-PROCEDURE false unparse-name)))))
+ (unparse-procedure procedure
+ (lambda ()
+ (let ((unparse-name
+ (lambda ()
+ (*unparse-object (primitive-procedure-name procedure)))))
+ (cond (*unparse-primitives-by-name?*
+ (unparse-name))
+ (*unparse-with-maximum-readability?*
+ (*unparse-readable-hash procedure))
+ (else
+ (*unparse-with-brackets 'PRIMITIVE-PROCEDURE false
+ unparse-name)))))))
(define (unparse/compiled-entry entry)
(let* ((type (compiled-entry-type entry))
+ (procedure? (eq? type 'COMPILED-PROCEDURE))
(closure?
- (and (eq? type 'COMPILED-PROCEDURE)
+ (and procedure?
(compiled-code-block/manifest-closure?
- (compiled-code-address->block entry)))))
- (*unparse-with-brackets
- (if closure? 'COMPILED-CLOSURE type)
- entry
- (lambda ()
- (let ((name
- (and (eq? type 'COMPILED-PROCEDURE)
- (compiled-procedure/name entry))))
- (with-values (lambda () (compiled-entry/filename entry))
- (lambda (filename block-number)
- (*unparse-char #\()
- (if name
- (*unparse-string name))
- (if filename
- (begin
- (if name
- (*unparse-char #\Space))
- (*unparse-object (pathname-name filename))
- (if block-number
- (begin
- (*unparse-char #\Space)
- (*unparse-hex block-number)))))
- (*unparse-char #\)))))
- (*unparse-char #\Space)
- (*unparse-hex (compiled-entry/offset entry))
- (*unparse-char #\Space)
- (if closure?
- (begin (*unparse-datum (compiled-closure->entry entry))
- (*unparse-char #\Space)))
- (*unparse-datum entry)))))
+ (compiled-code-address->block entry))))
+ (usual-method
+ (lambda ()
+ (*unparse-with-brackets (if closure? 'COMPILED-CLOSURE type)
+ entry
+ (lambda ()
+ (let ((name (and procedure? (compiled-procedure/name entry))))
+ (with-values (lambda () (compiled-entry/filename entry))
+ (lambda (filename block-number)
+ (*unparse-char #\()
+ (if name
+ (*unparse-string name))
+ (if filename
+ (begin
+ (if name
+ (*unparse-char #\Space))
+ (*unparse-object (pathname-name filename))
+ (if block-number
+ (begin
+ (*unparse-char #\Space)
+ (*unparse-hex block-number)))))
+ (*unparse-char #\)))))
+ (*unparse-char #\Space)
+ (*unparse-hex (compiled-entry/offset entry))
+ (if closure?
+ (begin
+ (*unparse-char #\Space)
+ (*unparse-datum (compiled-closure->entry entry))))
+ (*unparse-char #\Space)
+ (*unparse-datum entry))))))
+ (if procedure?
+ (unparse-procedure entry usual-method)
+ (usual-method))))
\f
;;;; Miscellaneous
#| -*-Scheme-*-
-$Id: make.scm,v 14.44 1993/03/01 17:40:20 gjr Exp $
+$Id: make.scm,v 14.45 1993/03/07 20:56:21 cph Exp $
Copyright (c) 1988-1993 Massachusetts Institute of Technology
("list" . (RUNTIME LIST))
("symbol" . ())
("uproc" . (RUNTIME PROCEDURE))
+ ("poplat" . (RUNTIME POPULATION))
("record" . (RUNTIME RECORD))))
(files2
'(("defstr" . (RUNTIME DEFSTRUCT))
- ("poplat" . (RUNTIME POPULATION))
("prop1d" . (RUNTIME 1D-PROPERTY))
("events" . (RUNTIME EVENT-DISTRIBUTOR))
("gdatab" . (RUNTIME GLOBAL-DATABASE))))
'CONSTANT-SPACE/BASE
constant-space/base)
(package-initialize '(RUNTIME LIST) 'INITIALIZE-PACKAGE! true)
+ (package-initialize '(RUNTIME POPULATION) 'INITIALIZE-PACKAGE! true)
(package-initialize '(RUNTIME RECORD) 'INITIALIZE-PACKAGE! true)
(package-initialize '(PACKAGE) 'FINALIZE-PACKAGE-RECORD-TYPE! true)
(load-files files2)
- (package-initialize '(RUNTIME POPULATION) 'INITIALIZE-PACKAGE! true)
(package-initialize '(RUNTIME 1D-PROPERTY) 'INITIALIZE-PACKAGE! true)
(package-initialize '(RUNTIME EVENT-DISTRIBUTOR) 'INITIALIZE-PACKAGE! true)
(package-initialize '(RUNTIME GLOBAL-DATABASE) 'INITIALIZE-PACKAGE! true)
#| -*-Scheme-*-
-$Id: runtime.pkg,v 14.174 1993/01/29 16:42:08 cph Exp $
+$Id: runtime.pkg,v 14.175 1993/03/07 20:56:22 cph Exp $
Copyright (c) 1988-1993 Massachusetts Institute of Technology
%record-ref
%record-set!
%record-type-has-application-method!
- %record-unparser-method
%record?
make-record-type
record-accessor
record-type-application-method
record-type-descriptor
record-type-field-names
+ record-type-method
record-type-name
record-type-unparser-method
record-type?
record-updater
record?
set-record-type-application-method!
+ set-record-type-method!
set-record-type-unparser-method!)
(initialization (initialize-package!)))