Changeset 11533


Ignore:
Timestamp:
01/03/09 19:30:59 (12 years ago)
Author:
vvoutilainen
Message:

Helper macro for p2-test-minusp/plusp/zerop/oddp/evenp.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/abcl/src/org/armedbear/lisp/compiler-pass2.lisp

    r11532 r11533  
    31533153  (p2-test-predicate form "endp"))
    31543154
     3155(defmacro p2-test-integer-predicate (form predicate &body instructions)
     3156  (let ((tmpform (gensym)))
     3157    `(let ((,tmpform ,form))
     3158       (when (check-arg-count ,tmpform 1)
     3159   (let ((arg (%cadr ,tmpform)))
     3160     (cond ((fixnum-type-p (derive-compiler-type arg))
     3161      (compile-forms-and-maybe-emit-clear-values arg 'stack :int)
     3162      ,@instructions)
     3163     (t
     3164      (p2-test-predicate ,tmpform ,predicate))))))))
     3165
    31553166(defun p2-test-evenp (form)
    3156   (when (check-arg-count form 1)
    3157     (let ((arg (%cadr form)))
    3158       (cond ((fixnum-type-p (derive-compiler-type arg))
    3159        (compile-forms-and-maybe-emit-clear-values arg 'stack :int)
    3160              (emit-push-constant-int 1)
    3161              (emit 'iand)
    3162              'ifne)
    3163             (t
    3164              (p2-test-predicate form "evenp"))))))
     3167  (p2-test-integer-predicate form "evenp"
     3168           (emit-push-constant-int 1)
     3169           (emit 'iand)
     3170           'ifne))
    31653171
    31663172(defun p2-test-oddp (form)
    3167   (when (check-arg-count form 1)
    3168     (let ((arg (%cadr form)))
    3169       (cond ((fixnum-type-p (derive-compiler-type arg))
    3170        (compile-forms-and-maybe-emit-clear-values arg 'stack :int)
    3171              (emit-push-constant-int 1)
    3172              (emit 'iand)
    3173              'ifeq)
    3174             (t
    3175              (p2-test-predicate form "oddp"))))))
     3173  (p2-test-integer-predicate form "oddp"
     3174           (emit-push-constant-int 1)
     3175           (emit 'iand)
     3176           'ifeq))
    31763177
    31773178(defun p2-test-floatp (form)
     
    31943195             (p2-test-predicate form "listp"))))))
    31953196
    3196 (defun p2-test-minusp/plusp/zerop (form instruction predicate)
    3197   (when (check-arg-count form 1)
    3198     (let ((arg (%cadr form)))
    3199       (cond ((fixnum-type-p (derive-compiler-type arg))
    3200        (compile-forms-and-maybe-emit-clear-values arg 'stack :int)
    3201              instruction)
    3202             (t
    3203              (p2-test-predicate form predicate))))))
    3204 
    32053197(defun p2-test-minusp (form)
    3206   (p2-test-minusp/plusp/zerop form 'ifge "minusp"))
     3198  (p2-test-integer-predicate form "minusp" 'ifge))
    32073199
    32083200(defun p2-test-plusp (form)
    3209   (p2-test-minusp/plusp/zerop form 'ifle "plusp"))
     3201  (p2-test-integer-predicate form "plusp" 'ifle))
    32103202
    32113203(defun p2-test-zerop (form)
    3212   (p2-test-minusp/plusp/zerop form 'ifne "zerop"))
     3204  (p2-test-integer-predicate form "zerop" 'ifne))
    32133205
    32143206(defun p2-test-numberp (form)
Note: See TracChangeset for help on using the changeset viewer.