Changeset 14501
- Timestamp:
- Dec 21, 2010, 7:53:00 PM (14 years ago)
- File:
-
- 1 edited
-
trunk/source/lib/defstruct-lds.lisp (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/lib/defstruct-lds.lisp
r14258 r14501 70 70 ;There's too much state to keep around here to break it up into little 71 71 ;functions, so what the hell, let's do it all inline... 72 (prog (struct-name type conc-name constructor copier predicate include72 (prog (struct-name type conc-name constructors copier predicate include 73 73 print-function print-object named initial-offset boa-constructors print-p 74 74 documentation (slot-list ()) (offset 0) superclasses sd … … 79 79 (setq struct-name (pop options))) 80 80 (unless (symbolp struct-name) (signal-program-error $XNotSym struct-name)) 81 (let (name args constructor-p predicate-p)81 (let (name args no-constructors-p predicate-p) 82 82 (while options 83 83 (if (atom (car options)) … … 92 92 (when (cddr args) (go bad-options)) 93 93 (cond ((cdr args) (push args boa-constructors)) 94 (t (when constructor (go dup-options)) 95 (unless (symbolp (%car args)) (go bad-options)) 96 (setq constructor-p t constructor args)))) 94 ((null args) 95 (push (concat-pnames "MAKE-" struct-name) constructors)) 96 ((eq (%car args) nil) 97 (setq no-constructors-p t)) 98 (t (unless (symbolp (%car args)) (go bad-options)) 99 (push (%car args) constructors)))) 97 100 (:copier 98 101 (when copier (go dup-options)) … … 158 161 (if (null conc-name) (%str-cat (symbol-name struct-name) "-") 159 162 (if (%car conc-name) (string (%car conc-name))))) 160 (unless (and boa-constructors (not constructor-p)) 161 (setq constructor 162 (if (null constructor) 163 (concat-pnames "MAKE-" struct-name) (%car constructor)))) 163 (when (and no-constructors-p 164 (or constructors boa-constructors)) 165 (error "~s combined with other ~s options" 166 '(:constructor nil) :constructor)) 167 (unless no-constructors-p 168 (unless (or boa-constructors constructors) 169 (push (concat-pnames "MAKE-" struct-name) constructors))) 164 170 (setq copier 165 171 (if (null copier) (concat-pnames "COPY-" struct-name) (%car copier)))) … … 241 247 refnames))) 242 248 (setq refnames (nreverse refnames))) 243 (setq sd (vector type slot-list superclasses offset constructor() refnames))249 (setq sd (vector type slot-list superclasses offset (car constructors) () refnames)) 244 250 (return 245 251 `(progn … … 263 269 ,.(%defstruct-compile sd refnames env) 264 270 ,.(defstruct-boa-constructors sd boa-constructors env) 265 ,.(if constructor (list (defstruct-constructor sd constructor env)))271 ,.(defstruct-constructors sd constructors env) 266 272 ;; Wait until slot accessors are defined, to avoid 267 273 ;; undefined function warnings in the print function/method. … … 301 307 `',(mapcar (lambda (name) (find-class-cell name t)) (cadr class-names)) 302 308 class-names)) 309 310 (defun defstruct-constructors (sd constructors env &aux (list ())) 311 (dolist (c constructors list) 312 (push (defstruct-constructor sd c env) list))) 303 313 304 314 (defun defstruct-constructor (sd constructor env &aux (offset 0)
Note:
See TracChangeset
for help on using the changeset viewer.
