chiark / gitweb /
lib/sod-hosted.c (sod_makev): Use two statements rather than tricky expression.
[sod] / src / method-impl.lisp
index 7fdceb1d552e6d94bab39499b8fa7bfa3df24915..c1e1b248f3f19981880ff22be25f02ccd93423c1 100644 (file)
@@ -60,6 +60,11 @@ (defmethod sod-message-method-class
       ((nil) (error "How odd: a primary method slipped through the net"))
       (t (error "Unknown method role ~A" role)))))
 
+(defmethod sod-message-receiver-type ((message sod-message)
+                                     (class sod-class))
+  (c-type (* (class class
+                   (and (sod-message-readonly-p message) :const)))))
+
 (export 'simple-message)
 (defclass simple-message (basic-message)
   ()
@@ -149,7 +154,8 @@ (define-on-demand-slot basic-direct-method function-type (method)
     (when (keyword-message-p message)
       (setf method-args (fix-up-keyword-method-args method method-args)))
     (c-type (fun (lisp (c-type-subtype type))
-                ("me" (* (class (sod-method-class method))))
+                ("me" (lisp (sod-message-receiver-type
+                             message (sod-method-class method))))
                 . method-args))))
 
 (defmethod sod-method-description ((method basic-direct-method))
@@ -218,7 +224,8 @@ (define-on-demand-slot delegating-direct-method next-method-type (method)
                          (t
                           msgargs))))
     (c-type (fun (lisp return-type)
-                ("me" (* (class (sod-method-class method))))
+                ("me" (lisp (sod-message-receiver-type
+                             message (sod-method-class method))))
                 . arguments))))
 
 (define-on-demand-slot delegating-direct-method function-type (method)
@@ -243,7 +250,8 @@ (define-on-demand-slot delegating-direct-method function-type (method)
          (t
           (push next-method-arg method-args)))
     (c-type (fun (lisp (c-type-subtype type))
-                ("me" (* (class (sod-method-class method))))
+                ("me" (lisp (sod-message-receiver-type
+                             message (sod-method-class method))))
                 . method-args))))
 
 ;;;--------------------------------------------------------------------------
@@ -291,7 +299,7 @@ (defmethod shared-initialize :after
 
 (export '(basic-effective-method
          effective-method-around-methods effective-method-before-methods
-         effective-method-after-methods))
+         effective-method-after-methods effective-method-functions))
 (defclass basic-effective-method (effective-method)
   ((around-methods :initarg :around-methods :initform nil
                   :type list :reader effective-method-around-methods)
@@ -443,7 +451,8 @@ (defmethod method-entry-function-type ((entry method-entry))
                 ((nil) raw-tail)
                 (:valist (reify-variable-argument-tail raw-tail)))))
     (c-type (fun (lisp (c-type-subtype type))
-                ("me" (* (class (method-entry-chain-tail entry))))
+                ("me" (lisp (sod-message-receiver-type
+                             message (method-entry-chain-tail entry))))
                 . tail))))
 
 (defgeneric effective-method-keyword-parser-function-name (method)
@@ -676,7 +685,10 @@ (defmethod compute-method-entry-functions ((method basic-effective-method))
 
         ;; Effective method function details.
         (emf-name (effective-method-function-name method))
-        (ilayout-type (c-type (* (struct (ilayout-struct-tag class)))))
+        (ilayout-type (c-type (* (struct (ilayout-struct-tag class)
+                                         (and (sod-message-readonly-p
+                                               message)
+                                              :const)))))
         (emf-type (c-type (fun (lisp return-type)
                                ("sod__obj" (lisp ilayout-type))
                                . entry-args))))
@@ -690,10 +702,11 @@ (defmethod compute-method-entry-functions ((method basic-effective-method))
               (deliver-call codegen :void "SOD__IGNORE" "sod__obj")))
           (finish-entry (tail)
             (let* ((head (sod-class-chain-head tail))
+                   (my-type (sod-message-receiver-type message tail))
                    (role (if parm-n :valist nil))
                    (name (method-entry-function-name method head role))
                    (type (c-type (fun (lisp return-type)
-                                      ("me" (* (class tail)))
+                                      ("me" (lisp my-type))
                                       . entry-args))))
               (codegen-pop-function codegen name type
                "~@(~@[~A ~]entry~) function ~:_~
@@ -712,7 +725,7 @@ (defmethod compute-method-entry-functions ((method basic-effective-method))
                                    (mapcar #'argument-name entry-args)))
                       (main (method-entry-function-name method head nil))
                       (main-type (c-type (fun (lisp return-type)
-                                              ("me" (* (class tail)))
+                                              ("me" (lisp my-type))
                                               . raw-entry-args))))
                   (codegen-push codegen)
                   (ensure-var codegen *sod-ap* c-type-va-list)