Changeset 888


Ignore:
Timestamp:
Sep 25, 2004, 5:31:48 PM (20 years ago)
Author:
Gary Byers
Message:

New support for funcallable instances, from Tim Moore.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ccl/level-1/l1-dcode.lisp

    r731 r888  
    384384)
    385385
     386#+ppc-target
     387(defppclapfunction funcallable-trampoline ()
     388  (svref nfn gf.dcode nfn)
     389  (lwz temp0 ppc32::misc-data-offset nfn)
     390  (mtctr temp0)
     391  (bctr))
     392
     393(defvar *fi-trampoline-code* (uvref #'funcallable-trampoline 0))
     394
     395#+ppc-target
     396(defppclapfunction unset-fin-trampoline ()
     397  (mflr loc-pc)
     398  (bla .SPheap-rest-arg)                ; cons up an &rest arg, vpush it
     399  (vpop arg_z)                          ; whoops, didn't really want to
     400  (bla .SPsavecontextvsp)
     401  (lwz arg_x '"Funcallable instance ~S was called with args ~s, but has no FUNCALLABLE-INSTANCE-FUNCTION" fn)
     402  (mr arg_y fn)
     403  (set-nargs 3)
     404  (lwz fname 'error fn)
     405  (bla .SPrestorecontext)
     406  (mtlr loc-pc)
     407  (ba .SPjmpsym))
     408
     409(defvar *unset-fin-code* (uvref #'unset-fin-trampoline 0))
     410
    386411
    387412#+ppc-target
     
    491516  (setf (combined-method.dcode cm) val))
    492517
    493 (defun generic-function-p (thing)
     518(defun funcallable-instance-p (thing)
    494519  (when (typep thing 'function)
    495520    (let ((bits (lfun-bits-known-function thing)))
     
    498523          (logand bits (logior (ash 1 $lfbits-gfn-bit)
    499524                               (ash 1 $lfbits-method-bit)))))))
     525
     526(defun generic-function-p (thing)
     527  (and (typep thing 'function)
     528       (let ((bits (lfun-bits-known-function thing)))
     529         (declare (fixnum bits))
     530         (eq (ash 1 $lfbits-gfn-bit)
     531             (logand bits (logior (ash 1 $lfbits-gfn-bit)
     532                                  (ash 1 $lfbits-method-bit)))))
     533       (or (eq (%class.own-wrapper *generic-function-class*)
     534               (gf.instance.class-wrapper thing))
     535           (memq  *generic-function-class*
     536                  (%inited-class-cpl (class-of thing))))))
     537
    500538
    501539(defun standard-generic-function-p (thing)
     
    524562
    525563(setf (type-predicate 'standard-generic-function) 'standard-generic-function-p)
     564(setf (type-predicate 'funcallable-standard-object) 'funcallable-instance-p)
    526565(setf (type-predicate 'combined-method) 'combined-method-p)
    527566
Note: See TracChangeset for help on using the changeset viewer.