Ticket #1581: record-tag-fun.diff
File record-tag-fun.diff, 6.9 KB (added by , 6 years ago) |
---|
-
coops/trunk/coops-module.scm
13 13 slot-initialized? 14 14 <standard-class> 15 15 <standard-object> 16 coops-instance 16 17 make 17 18 make-class 18 19 generic-procedure? -
coops/trunk/coops.egg
4 4 (author "Dorai Sitaram and felix winkelmann") 5 5 (dependencies matchable miscmacros record-variants srfi-1) 6 6 (test-dependencies test) 7 (components (extension coops (source "coops-module.scm")) 7 (components (extension coops 8 (source "coops-module.scm") 9 (source-dependencies "coops.scm")) 8 10 (extension coops-primitive-objects (component-dependencies coops)))) -
coops/trunk/coops.scm
14 14 (only miscmacros ensure)) 15 15 (import-for-syntax matchable (chicken plist) srfi-1) 16 16 17 ;; this will be overridden 18 (define-record coops-instance class slots) 19 17 20 (define-record-variant coops-instance (unsafe inline unchecked) 18 21 class ; CLASS (instance) 19 22 slots) ; #(SLOT-VALUE1 ...) … … 32 35 (set! method-definition-counter (fx+ method-definition-counter 1))) 33 36 34 37 (define-inline (check-instance x loc) 35 (##sys#check-structure x 'coops-instance loc))38 (##sys#check-structure x coops-instance loc)) 36 39 37 40 (define <standard-class> 38 41 ;;all classes are instances of standard-class … … 157 160 (primitive-class-hook o))) 158 161 159 162 (define-inline (fast-class-of o) 160 (if (##sys#structure? o 'coops-instance)163 (if (##sys#structure? o coops-instance) 161 164 (##sys#slot o 1) 162 165 (primitive-class-hook o))) 163 166 -
record-variants/trunk/record-variants.scm
100 100 `(,%define 101 101 ,(string->symbol (string-append "make-" prefix)) 102 102 (,%lambda ,slots 103 (##sys#make-structure ',original-name ,@slots)))103 (##sys#make-structure ,original-name ,@slots))) 104 104 `(,%begin)) 105 105 (,%define 106 106 ,(string->symbol (string-append prefix "?")) 107 (,%lambda (x) (##sys#structure? x ',original-name)))107 (,%lambda (x) (##sys#structure? x ,original-name))) 108 108 (,%define 109 109 ,(string->symbol (string-append "check-" prefix)) 110 110 (,%lambda (x) 111 (##core#check (##sys#check-structure x ',original-name))111 (##core#check (##sys#check-structure x ,original-name)) 112 112 x)) 113 113 ,@(let loop ((slots slots) (i 1)) 114 114 (if (eq? slots '()) … … 126 126 ,(if unchecked? 127 127 `(,%begin) 128 128 `(##core#check (##sys#check-structure 129 x ',original-name)))129 x ,original-name))) 130 130 ,(if unsafe? 131 131 `(##sys#setslot x ,i val) 132 132 `(##sys#block-set! x ,i val)))) … … 138 138 ,(if unchecked? 139 139 `(,%begin) 140 140 `(##core#check (##sys#check-structure 141 x ',original-name)))141 x ,original-name))) 142 142 ,(if unsafe? 143 143 `(##sys#slot x ,i) 144 144 `(##sys#block-ref x ,i))) … … 147 147 ,(if unchecked? 148 148 `(,%begin) 149 149 `(##core#check (##sys#check-structure 150 x ',original-name)))150 x ,original-name))) 151 151 ,(if unsafe? 152 152 `(##sys#slot x ,i) 153 153 `(##sys#block-ref x ,i)))))) … … 192 192 ,(if constructor? 193 193 `(,%define ,conser 194 194 (##sys#make-structure 195 ',t195 ,t 196 196 ,@(map (lambda (sname) 197 197 (if (memq sname vars) 198 198 sname … … 199 199 '(##core#undefined))) 200 200 slotnames))) 201 201 `(,%begin)) 202 (,%define (,pred ,x) (##sys#structure? ,x ',t))202 (,%define (,pred ,x) (##sys#structure? ,x ,t)) 203 203 ,(if checker 204 204 `(,%define (,checker ,x) 205 (##core#check (##sys#check-structure ,x ',t)))205 (##core#check (##sys#check-structure ,x ,t))) 206 206 `(,%begin)) 207 207 ,@(let loop ([slots slots] [i 1]) 208 208 (if (null? slots) … … 214 214 ,(if unchecked? 215 215 `(,%begin) 216 216 `(##core#check 217 (##sys#check-structure ,x ',t)))217 (##sys#check-structure ,x ,t))) 218 218 ,(if unsafe? 219 219 `(##sys#slot ,x ,i) 220 220 `(##sys#block-ref ,x ,i))))) … … 223 223 ,(if unchecked? 224 224 `(,%begin) 225 225 `(##core#check 226 (##sys#check-structure ,x ',t)))226 (##sys#check-structure ,x ,t))) 227 227 ,(if unsafe? 228 228 `(##sys#setslot ,x ,i ,y) 229 229 `(##sys#block-set! ,x ,i ,y))))