; ************************************************************************* ; Copyright (c) 1992 Xerox Corporation. ; All Rights Reserved. ; ; Use, reproduction, and preparation of derivative works are permitted. ; Any copy of this software or of any derivative work must include the ; above copyright notice of Xerox Corporation, this paragraph and the ; one after it. Any distribution of this software or derivative works ; must comply with all applicable United States export control laws. ; ; This software is made available AS IS, and XEROX CORPORATION DISCLAIMS ; ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE ; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR ; PURPOSE, AND NOTWITHSTANDING ANY OTHER PROVISION CONTAINED HEREIN, ANY ; LIABILITY FOR DAMAGES RESULTING FROM THE SOFTWARE OR ITS USE IS ; EXPRESSLY DISCLAIMED, WHETHER ARISING IN CONTRACT, TORT (INCLUDING ; NEGLIGENCE) OR STRICT LIABILITY, EVEN IF XEROX CORPORATION IS ADVISED ; OF THE POSSIBILITY OF SUCH DAMAGES. ; ************************************************************************* ; ; port to R6RS -- 2007 Christian Sloma ; (library (clos bootstrap standard-classes) (export bootstrap-make) (import (only (rnrs) define quote begin lambda let cond or eq? else error list if null? car pair? boolean? symbol? procedure? number? vector? char? string? input-port? output-port?) (clos private allocation) (clos private core-class-layout) (clos slot-access) (clos introspection) (clos std-protocols make) (clos std-protocols allocate-instance) (clos std-protocols initialize) (clos std-protocols class-initialization)) (define (really-allocate-instance 'ignore core-class-slot-count)) (define (really-allocate-instance core-class-slot-count)) (define (really-allocate-instance core-class-slot-count)) (define bootstrap-initialize (begin (set-instance-class-to-self! ) (register-class-of-classes! ) (lambda (inst init-args) (let ((class (class-of inst))) (cond ((or (eq? class ) (eq? class ) (eq? class ) (eq? class )) (class-initialize inst init-args class-compute-precedence-list class-compute-slots class-compute-getter-and-setter)) ((eq? class ) (generic-initialize inst init-args)) ((eq? class ) (method-initialize inst init-args)) (else (error 'bootstrap-initialize "cannot initialize instance of class ~a" class))))))) (define bootstrap-allocate-instance (begin (bootstrap-initialize (list 'definition-name ' 'direct-supers (list) 'direct-slots (list))) (bootstrap-initialize (list 'definition-name ' 'direct-supers (list ) 'direct-slots (list))) (bootstrap-initialize (list 'definition-name ' 'direct-supers (list ) 'direct-slots core-class-slot-names)) (lambda (class) (let ((class-of-class (class-of class))) (cond ((eq? class-of-class ) (class-allocate-instance class)) ((eq? class-of-class ) (entity-class-allocate-instance class)) (else (error 'bootstrap-allocate-instance "cannot allocate instance for class ~a" class))))))) (define (bootstrap-make class . init-args) (class-make class init-args bootstrap-allocate-instance bootstrap-initialize)) (define (bootstrap-make 'definition-name ' 'direct-supers (list ) 'direct-slots (list))) (define (bootstrap-make 'definition-name ' 'direct-supers (list ) 'direct-slots (list))) (define (bootstrap-make 'definition-name ' 'direct-supers (list ) 'direct-slots (list 'methods))) (define (bootstrap-make 'definition-name ' 'direct-supers (list ) 'direct-slots (list 'specializers 'qualifier 'procedure))) (define (bootstrap-make 'definition-name ' 'direct-supers (list ) 'direct-slots (list))) (define (make-primitive-class name . class) (bootstrap-make (if (null? class) (car class)) 'definition-name name 'direct-supers (list ) 'direct-slots (list))) (define (make-primitive-class ')) (define (make-primitive-class ')) (define (make-primitive-class ')) (define (make-primitive-class ')) (define (make-primitive-class ' )) (define (make-primitive-class ')) (define (make-primitive-class ')) (define (make-primitive-class ')) (define (make-primitive-class ')) (define (make-primitive-class ')) (define (make-primitive-class ')) (define (primitive-class-of x) (cond ((pair? x) ) ;If all Schemes were IEEE ((null? x) ) ;compliant, the order of ((boolean? x) ) ;these wouldn't matter? ((symbol? x) ) ((procedure? x) ) ((number? x) ) ((vector? x) ) ((char? x) ) ((string? x) ) ((input-port? x) ) ((output-port? x) ) (else ))) (set-primitive-class-of! primitive-class-of) ) ;; library (clos bootstrap standard-classes)