(and (binary-port? object)
(port-input-buffer object)
#t))
+(register-predicate! binary-input-port? 'binary-input-port
+ '<= binary-port?)
(define (binary-output-port? object)
(and (binary-port? object)
(port-output-buffer object)
#t))
+(register-predicate! binary-output-port? 'binary-output-port
+ '<= binary-port?)
(define (binary-i/o-port? object)
(and (binary-port? object)
(port-input-buffer object)
(port-output-buffer object)
#t))
-
-(add-boot-init!
- (lambda ()
- (register-predicate! binary-input-port? 'binary-input-port
- '<= binary-port?)
- (register-predicate! binary-output-port? 'binary-output-port
- '<= binary-port?)
- (register-predicate! binary-i/o-port? 'binary-i/o-port
- '<= binary-input-port?
- '<= binary-output-port?)))
+(register-predicate! binary-i/o-port? 'binary-i/o-port
+ '<= binary-input-port?
+ '<= binary-output-port?)
(define-unparser-method binary-port?
(standard-unparser-method
(and (fix:= (output-sink-custom-length sink) 2)
(eq? bytevector-output-port-tag
(output-sink-custom-ref sink 0))))))
+(register-predicate! bytevector-output-port? 'bytevector-output-port
+ '<= binary-output-port?)
(define bytevector-output-port-tag
(list 'bytevector-output-port-tag))
-(add-boot-init!
- (lambda ()
- (register-predicate! bytevector-output-port? 'bytevector-output-port
- '<= binary-output-port?)))
-
(define (call-with-output-bytevector procedure)
(let ((port (open-output-bytevector)))
(procedure port)
(define (positionable-binary-port? object)
(and (binary-port? object)
(binary-port-positionable? object)))
+(register-predicate! positionable-binary-port? 'positionable-binary-port
+ '<= binary-port?)
(define (binary-port-positionable? port)
(let ((ib (port-input-buffer port))
(channel-type=file? ic))
(channel-type=file? (or ic oc)))))))
-(add-boot-init!
- (lambda ()
- (register-predicate! positionable-binary-port? 'positionable-binary-port
- '<= binary-port?)))
-
(define (binary-port-length port)
(guarantee positionable-binary-port? port 'port-length)
(channel-file-length (or (let ((ib (port-input-buffer port)))
(define (input-source? object)
(and (source/sink? object)
(eq? 'source (source/sink-flavor object))))
-
-(add-boot-init!
- (lambda ()
- (register-predicate! input-source? 'input-source '<= source/sink?)))
+(register-predicate! input-source? 'input-source '<= source/sink?)
(define input-source-channel source/sink-channel)
(define input-source-port source/sink-port)
(define (output-sink? object)
(and (source/sink? object)
(eq? 'sink (source/sink-flavor object))))
-
-(add-boot-init!
- (lambda ()
- (register-predicate! output-sink? 'output-sink '<= source/sink?)))
+(register-predicate! output-sink? 'output-sink '<= source/sink?)
(define output-sink-channel source/sink-channel)
(define output-sink-port source/sink-port)
(procedure (cddr objects)))
(lose))))
\f
+;;;; Predicate registrations
+
+(define predicate?)
+(define register-predicate!)
+(let ((predicates '()))
+ (set! predicate?
+ (lambda (object)
+ (if (memq object predicates) #t #f)))
+ (set! register-predicate!
+ (lambda (predicate name . keylist)
+ (defer-boot-action 'predicate-registrations
+ (lambda ()
+ (apply register-predicate! predicate name keylist)))
+ (set! predicates (cons predicate predicates))
+ unspecific))
+ unspecific)
+
;;;; Miscellany
(define (object-constant? object)
(cdr p))))
object)
(alist-has-unique-keys? object)))
+(register-predicate! elements? 'interface-elements)
(define-record-type <bundle-interface>
(%make-bundle-interface tag name element-names element-properties)
(symbol? (car p)))
object)
(alist-has-unique-keys? object)))
+(register-predicate! bundle-alist? 'bundle-alist '<= alist?)
(define-record-type <bundle-metadata>
(make-bundle-metadata interface values)
(and (entity? object)
(bundle-metadata? (entity-extra object))))
+(defer-boot-action 'predicate-registrations
+ (lambda ()
+ (register-predicate! bundle? 'bundle '<= entity?)))
+
(define (bundle-interface bundle)
(bundle-metadata-interface (entity-extra bundle)))
(list name (bundle-ref bundle name)))
(bundle-names bundle))))
-(define bundle-printers)
-(add-boot-init!
- (lambda ()
- (set! bundle-printers (make-key-weak-eqv-hash-table))
- (register-predicate! bundle-interface? 'bundle-interface '<= predicate?)
- (register-predicate! elements? 'interface-elements)
- (register-predicate! bundle? 'bundle '<= entity?)
- (register-predicate! bundle-alist? 'bundle-alist '<= alist?)))
\ No newline at end of file
+(define-deferred bundle-printers
+ (make-key-weak-eqv-hash-table))
\ No newline at end of file
(declare (usual-integrations))
\f
-(defer-boot-action 'predicate-registrations
- (lambda ()
- (register-predicate! u8? 'u8 '<= index-fixnum?)
- (register-predicate! u16? 'u16 '<= index-fixnum?)
- (register-predicate! u32? 'u32 '<= (if (fix:fixnum? #xFFFFFFFF)
- index-fixnum?
- exact-nonnegative-integer?))))
-
(define (u8? object)
(and (index-fixnum? object)
(fix:< object #x100)))
+(register-predicate! u8? 'u8 '<= index-fixnum?)
(define-primitives
(allocate-bytevector 1)
(define (u16? object)
(and (index-fixnum? object)
(fix:< object #x10000)))
+(register-predicate! u16? 'u16 '<= index-fixnum?)
(define (bytevector-u16be-ref bytevector index)
(if (not (fix:< (fix:+ index 1) (bytevector-length bytevector)))
(define (u32? object)
(and (index-fixnum? object)
- (fix:<= object #xFFFFFFFF))))
+ (fix:<= object #xFFFFFFFF)))
+ (register-predicate! u32? 'u32 '<= index-fixnum?))
;; Must use bignums:
(begin
(define-integrable (bytes->u32be b0 b1 b2 b3)
(define (u32? object)
(and (exact-nonnegative-integer? object)
- (int:<= object #xFFFFFFFF)))))
+ (int:<= object #xFFFFFFFF)))
+
+ (add-boot-init!
+ (lambda ()
+ (register-predicate! u32? 'u32 '<= exact-nonnegative-integer?)))))
+
\f
(define-integrable (bytes->u32le b0 b1 b2 b3) (bytes->u32be b3 b2 b1 b0))
(define-integrable u32le-byte0 u32be-byte3)
(let ((table (make-hashed-metadata-table)))
(set! compound-operator? (table 'has?))
(set! compound-operator-builder (table 'get))
- (set! define-compound-operator (table 'put!))
- unspecific)
+ (set! define-compound-operator (table 'put!)))
(register-predicate! compound-operator? 'compound-predicate '<= symbol?)))
(add-boot-init!
(RUNTIME FLOATING-POINT-ENVIRONMENT)
((RUNTIME THREAD) INITIALIZE-HIGH!)
;; I/O
- (RUNTIME BINARY-PORT)
(RUNTIME PORT)
(RUNTIME OUTPUT-PORT)
(RUNTIME GENERIC-I/O-PORT)
(pair? (cdr object))
(procedure? (cadr object))
(null? (cddr object))))
-
-(add-boot-init!
- (lambda ()
- (register-predicate! textual-port-type-operation? 'port-type-operation)))
+(register-predicate! textual-port-type-operation? 'port-type-operation)
\f
(define (parse-operations-list operations parent-type)
(parse-operations-list-1
(and (textual-port? object)
(port-type-supports-input? (textual-port-type object))
#t))
+(register-predicate! textual-input-port? 'textual-input-port
+ '<= textual-port?)
(define (textual-output-port? object)
(and (textual-port? object)
(port-type-supports-output? (textual-port-type object))
#t))
+(register-predicate! textual-output-port? 'textual-output-port
+ '<= textual-port?)
(define (textual-i/o-port? object)
(and (textual-port? object)
(and (port-type-supports-input? type)
(port-type-supports-output? type)
#t))))
-
-(add-boot-init!
- (lambda ()
- (register-predicate! textual-input-port? 'textual-input-port
- '<= textual-port?)
- (register-predicate! textual-output-port? 'textual-output-port
- '<= textual-port?)
- (register-predicate! textual-i/o-port? 'textual-i/o-port
- '<= textual-port?)))
+(register-predicate! textual-i/o-port? 'textual-i/o-port
+ '<= textual-port?)
(define-unparser-method textual-port?
(standard-unparser-method
(define (blocking-mode? object)
(or (eq? 'blocking object)
(eq? 'nonblocking object)))
+(register-predicate! blocking-mode? 'blocking-mode)
(define (channel-blocking-mode channel)
(if channel
(define (terminal-mode? object)
(or (eq? 'cooked object)
(eq? 'raw object)))
+(register-predicate! terminal-mode? 'terminal-mode)
(define (channel-terminal-mode channel)
(if (and channel (channel-type=terminal? channel))
(and channel (channel-type=terminal? channel)))
channel-terminal-mode
set-channel-terminal-mode!))
-
-(add-boot-init!
- (lambda ()
- (register-predicate! blocking-mode? 'blocking-mode)
- (register-predicate! terminal-mode? 'terminal-mode)))
\f
;;;; Standard Ports
(declare (usual-integrations))
\f
-(define (predicate? object)
- (any (lambda (reg)
- (eqv? (car reg) object))
- boot-registrations))
-
-(define (register-predicate! predicate name . keylist)
- (set! boot-registrations
- (cons (cons* predicate name keylist)
- boot-registrations))
- unspecific)
-
-(define (run-deferred-predicate-registrations!)
- (for-each (lambda (reg)
- (apply register-predicate! reg))
- (reverse! boot-registrations))
- (set! boot-registrations)
- unspecific)
-
-(define boot-registrations '())
-
(define get-predicate-tag)
(define set-predicate-tag!)
(add-boot-init!
(set-tag<=! tag (predicate->tag superset)))
(get-keyword-values keylist '<=))
tag)))
-\f
+
(define (predicate-name predicate)
(tag-name (predicate->tag predicate 'predicate-name)))
(simple-unparser-method 'tag
(lambda (tag)
(list (tag-name tag)))))
-\f
+
(define (tag-description tag)
(or (%tag-description tag)
(object->description (tag-name tag))))
(register-predicate! weak-list? 'weak-list)
(register-predicate! weak-pair? 'weak-pair)
- (run-deferred-boot-actions 'predicate-registrations)))
-
-(add-boot-init! run-deferred-predicate-registrations!)
\ No newline at end of file
+ (run-deferred-boot-actions 'predicate-registrations)))
\ No newline at end of file
\f
(define-integrable (tagged-object? object)
(object-type? (ucode-type tagged-object) object))
+(register-predicate! tagged-object? 'tagged-object)
(define (object-tagger predicate)
(let ((tag (predicate->tag predicate)))
(define unparser-methods)
(add-boot-init!
(lambda ()
- (register-predicate! tagged-object? 'tagged-object)
(set! unparser-methods (make-key-weak-eqv-hash-table))
unspecific))
interrupt-mask/timer-ok
object-constant?
object-pure?
+ predicate?
+ register-predicate!
simple-parser-method
simple-unparser-method
standard-unparser-method
predicate-tagger
predicate-tagging-strategy
predicate-untagger
- predicate?
- register-predicate!
set-predicate<=!)
(export (runtime)
event:predicate-metadata
(define (absolute-uri? object)
(and (uri? object)
(uri-absolute? object)))
+(register-predicate! absolute-uri? 'absolute-uri '<= uri?)
(define (relative-uri? object)
(and (uri? object)
(uri-relative? object)))
+(register-predicate! relative-uri? 'relative-uri '<= uri?)
(define-guarantee uri "URI")
(define-guarantee absolute-uri "absolute URI")
(string->char-set ";/?:@&=")))
(set! uri-merge-defaults (make-uri-merge-defaults))
- (register-predicate! absolute-uri? 'absolute-uri '<= uri?)
- (register-predicate! relative-uri? 'relative-uri '<= uri?)))
+ unspecific))
\f
;;;; Partial URIs
((slice? string) (not (slice-mutable? string)))
(else (fail))))
-(defer-boot-action 'predicate-registrations
- (lambda ()
- (register-predicate! mutable-string? 'mutable-string '<= string?)
- (register-predicate! immutable-string? 'immutable-string '<= string?)
- (register-predicate! nfc-string? 'nfc-string '<= string?)
- (register-predicate! legacy-string? 'legacy-string
- '<= string?
- '<= mutable-string?)
- (register-predicate! ustring? 'unicode-string '<= string?)
- (register-predicate! slice? 'string-slice '<= string?)
- (register-predicate! 8-bit-string? '8-bit-string '<= string?)))
+(add-boot-init!
+ (lambda ()
+ (register-predicate! mutable-string? 'mutable-string '<= string?)
+ (register-predicate! immutable-string? 'immutable-string '<= string?)
+ (register-predicate! nfc-string? 'nfc-string '<= string?)
+ (register-predicate! legacy-string? 'legacy-string
+ '<= string?
+ '<= mutable-string?)
+ (register-predicate! ustring? 'unicode-string '<= string?)
+ (register-predicate! slice? 'string-slice '<= string?)
+ (register-predicate! 8-bit-string? '8-bit-string '<= string?)))
\f
;;;; Unicode string layout