Changeset 14769


Ignore:
Timestamp:
May 2, 2011, 6:31:56 PM (9 years ago)
Author:
gb
Message:

In RLET, just use (setf uvref) to set the type ordinal.

New macros (that should probably have better names): WITH-CONSTRAINED-{SINGLE,DOUBLE}-FLOATS:
stack-allocate a vector of the indicated type, define symbol-macros to refer to its elements.
(Have spoken about getting the compiler to do something similar, without symbol-macro issues.)

File:
1 edited

Legend:

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

    r14741 r14769  
    31153115                           `(foreign-type-ordinal (load-time-value (%foreign-type-or-record ',record-name))))))
    31163116      (when (eq *host-backend* *target-backend*)
    3117         (setq result (nconc result `((%set-macptr-type ,name ,ordinal-form)))))
     3117        (setq result (nconc result `((setf (uvref ,name target::macptr.type-cell) ,ordinal-form)))))
    31183118      (if (typep ftype 'foreign-record-type)
    31193119        (setq result
     
    32093209      ,ptr)))
    32103210
    3211    
     3211(defun with-constrained-values (type specs body env)
     3212  (multiple-value-bind (body decls) (parse-body body env)
     3213    (collect ((inits))
     3214      (dolist (spec specs)
     3215        (when (cdr spec)
     3216          (inits `(setq ,(car spec) ,(cadr spec)))))       
     3217  (let* ((vector (gensym))
     3218         (idx -1))
     3219    `(let* ((,vector (make-array ,(length specs) :element-type ',type)))
     3220      (declare (dynamic-extent ,vector))
     3221      (symbol-macrolet ,(mapcar (lambda (spec) `(,(car spec) (aref ,vector ,(incf idx)))) specs)
     3222        ,@decls
     3223        ,@(inits)
     3224        ,@body)))))) 
     3225
     3226(defmacro with-constrained-double-floats (specs &body body &environment env)
     3227  (with-constrained-values 'double-float specs body env))
     3228
     3229
     3230(defmacro with-constrained-single-floats (specs &body body &environment env)
     3231  (with-constrained-values 'single-float specs body env))
    32123232
    32133233(defmacro with-terminal-input (&body body)
Note: See TracChangeset for help on using the changeset viewer.