;;;; coops-primitive-objects.scm (module coops-primitive-objects () (import scheme) (import (chicken base)) (import (chicken keyword)) (import (chicken module)) (import coops) (define-syntax defprim (syntax-rules () ((_ name pred) (defprim name pred )) ((_ name pred supers ...) (begin (export name) (define-primitive-class name (supers ...) pred))))) (defprim ##sys#immediate?) (defprim boolean? ) (defprim eof-object? ) (defprim char? ) (defprim (lambda (x) (and (not (##sys#immediate? x)) (##sys#generic-structure? x)))) (define (number-vector? x) (and (not (##sys#immediate? x)) (##sys#generic-structure? x) (memq (##sys#slot x 0) '(u8vector s8vector u16vector s16vector u32vector s32vector f32vector f64vector)))) (defprim (lambda (x) (or (null? x) (pair? x) (vector? x) (string? x) (and (not (##sys#immediate? x)) (##sys#generic-structure? x) (memq (##sys#slot x 0) '(u8vector s8vector u16vector s16vector u32vector s32vector f32vector f64vector queue)))))) (define-class ()) (defprim null? ) (defprim pair? ) (defprim vector? ) (defprim number-vector? ) (defprim (cut ##sys#structure? <> 'u8vector) ) (defprim (cut ##sys#structure? <> 's8vector) ) (defprim (cut ##sys#structure? <> 'u16vector) ) (defprim (cut ##sys#structure? <> 's16vector) ) (defprim (cut ##sys#structure? <> 'u32vector) ) (defprim (cut ##sys#structure? <> 's32vector) ) (defprim (cut ##sys#structure? <> 'f32vector) ) (defprim (cut ##sys#structure? <> 'f64vector) ) (defprim string? ) (defprim (cut ##sys#structure? <> 'char-set) ) (defprim symbol?) (defprim keyword? ) (defprim number?) (defprim integer? ) (defprim (lambda (x) (and (integer? x) (exact? x))) ) (defprim (lambda (x) (and (number? x) (inexact? x))) ) (defprim fixnum? ) (defprim flonum? ) (defprim (cut ##sys#structure? <> 'thread) ) (defprim (cut ##sys#structure? <> 'mutex) ) (defprim (cut ##sys#structure? <> 'condition-variable) ) (defprim (cut ##sys#structure? <> 'condition) ) (defprim (cut ##sys#structure? <> 'tcp-listener) ) (defprim (cut ##sys#structure? <> 'continuation) ) (defprim (cut ##sys#structure? <> 'regexp) ) (defprim (lambda (x) (and (not (##sys#immediate? x)) (##sys#pointer? x)))) (defprim (lambda (x) (##core#inline "C_i_locativep" x))) (defprim (cut ##sys#structure? <> 'promise) ) (defprim (cut ##sys#structure? <> 'queue) ) (defprim (cut ##sys#structure? <> 'hash-table) ) (defprim (lambda (x) (and (not (##sys#immediate? x)) (##core#inline "C_bytevectorp" x)))) (defprim port? ) (defprim (lambda (x) (and (port? x) (eq? 'stream (##sys#slot x 7)))) ) (defprim (lambda (x) (and (port? x) (eq? 'custom (##sys#slot x 7)))) ) (defprim (lambda (x) (and (port? x) (eq? 'string (##sys#slot x 7)))) ) (defprim (lambda (x) (and (port? x) (eq? 'tcp (##sys#slot x 7)))) ) )