Changeset 496


Ignore:
Timestamp:
Feb 7, 2004, 2:20:17 PM (21 years ago)
Author:
Gary Byers
Message:

Define CCL::CONDITIONAL-STORE, for use by CLX (and maybe other things,
if it learns how to decode more "places".)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ccl/lib/macros.lisp

    r472 r496  
    29022902               (progn (psetq ,@(nreverse psetform)) ,@body)
    29032903               (psetq ,@(nreverse restoreform)))))))))
     2904;;; From CLX.
     2905
     2906;;; The good news is that this uses an interlocked load/store sequence
     2907;;; and is fairly efficient.
     2908;;; The bad news is that it only handles a few types of "place" forms.
     2909;;; The good news is that CLX only uses a few types of "place" forms.
     2910
     2911(defmacro conditional-store (place old-value new-value &environment env)
     2912  (setq place (macroexpand place env))
     2913  (if (atom place)
     2914    ;; CLX uses special variables' value cells as place forms.
     2915    (if (and (symbolp place)
     2916             (eq :special (ccl::variable-information place env)))
     2917      (let* ((base (gensym))
     2918             (offset (gensym)))
     2919        `(multiple-value-bind (,base ,offset)
     2920          (ccl::%symbol-binding-address ',place)
     2921          (ccl::%store-node-conditional ,offset ,base ,old-value ,new-value)))
     2922      (error "~s is not a special variable ." place))
     2923    (let* ((sym (car place))
     2924           (struct-transform (or (ccl::environment-structref-info sym env)
     2925                                 (gethash sym ccl::%structure-refs%))))
     2926      (if struct-transform
     2927        (setq place (ccl::defstruct-ref-transform struct-transform (cdr place))
     2928              sym (car place)))
     2929      (if (member  sym '(svref ccl::%svref ccl::struct-ref))
     2930        (let* ((v (gensym)))
     2931          `(let* ((,v ,(cadr place)))
     2932            (ccl::store-gvector-conditional ,(caddr place)
     2933             ,v ,old-value ,new-value)))
     2934        (error "Don't know how to do conditional store to ~s" place)))))
Note: See TracChangeset for help on using the changeset viewer.