3 ;;; Infrastructure for effective method generation
5 ;;; (c) 2009 Straylight/Edgeware
8 ;;;----- Licensing notice ---------------------------------------------------
10 ;;; This file is part of the Simple Object Definition system.
12 ;;; SOD is free software; you can redistribute it and/or modify
13 ;;; it under the terms of the GNU General Public License as published by
14 ;;; the Free Software Foundation; either version 2 of the License, or
15 ;;; (at your option) any later version.
17 ;;; SOD is distributed in the hope that it will be useful,
18 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;;; GNU General Public License for more details.
22 ;;; You should have received a copy of the GNU General Public License
23 ;;; along with SOD; if not, write to the Free Software Foundation,
24 ;;; Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
28 ;;;--------------------------------------------------------------------------
29 ;;; Function type protocol.
31 (defgeneric sod-message-argument-tail (message)
33 "Return the argument tail for the message, with invented argument names.
35 No `me' argument is prepended; any :ELLIPSIS is left as it is."))
37 (defgeneric sod-message-no-varargs-tail (message)
39 "Return the argument tail for the message with :ELLIPSIS substituted.
41 As with SOD-MESSAGE-ARGUMENT-TAIL, no `me' argument is prepended.
42 However, an :ELLIPSIS is replaced by an argument of type `va_list', named
45 (defgeneric direct-method-function-type (method)
47 "Return the C function type for the direct method.
49 This is called during initialization of a direct method object, and the
52 A default method is provided (by BASIC-DIRECT-METHOD) which simply
53 prepends an appropriate `me' argument to the user-provided argument list.
54 Fancy method classes may need to override this behaviour."))
56 (defgeneric direct-method-next-method-type (method)
58 "Return the C function type for the next-method trampoline.
60 This is called during initialization of a direct method object, and the
61 result is cached. It should return a function type, not a pointer type.
63 A default method is provided (by DELEGATING-DIRECT-METHOD) which should do
64 the right job. Very fancy subclasses might need to do something
67 (defgeneric direct-method-function-name (method)
69 "Return the C function name for the direct method."))
71 ;;;--------------------------------------------------------------------------
74 (defclass basic-message (sod-message)
75 ((argument-tail :type list :reader sod-message-argument-tail)
76 (no-varargs-tail :type list :reader sod-message-no-varargs-tail))
78 "Base class for built-in message classes.
80 Provides the basic functionality for the built-in method combinations.
81 This is a separate class so that `special effect' messages can avoid
82 inheriting its default behaviour.
84 The function type protocol is implemented on BASIC-MESSAGE using slot
85 reader methods. The actual values are computed on demand in methods
86 defined on SLOT-UNBOUND."))
88 ;;; Function type protocol.
90 (defmethod slot-unbound (class
91 (message basic-message)
92 (slot-name (eql 'argument-tail)))
95 (if (or (eq arg :ellipsis) (argument-name arg))
97 (make-argument (make-instance 'temporary-argument
98 :tag (prog1 seq (incf seq)))
99 (argument-type arg))))
100 (c-function-arguments (sod-message-type message)))))
102 (defmethod slot-unbound (class
103 (message basic-message)
104 (slot-name (eql 'no-varargs-tail)))
105 (mapcar (lambda (arg)
106 (if (eq arg :ellipsis)
107 (make-argument *sod-ap* (c-type va-list))
109 (sod-message-argument-tail message)))
111 ;;; Method class selection.
113 (defmethod sod-message-method-class
114 ((message basic-message) (class sod-class) pset)
115 (let ((role (get-property pset :role :keyword nil)))
117 ((:before :after) 'daemon-direct-method)
118 (:around 'delegating-direct-method)
119 ((nil) (error "How odd: a primary method slipped through the net"))
120 (t (error "Unknown method role ~A" role)))))
122 ;;; Utility functions.
124 (defun varargs-message-p (message)
125 "Answer whether the MESSAGE accepts a variable-length argument list.
127 We need to jump through some extra hoops in order to cope with varargs
128 messages, so this is useful to know."
129 (member :ellipsis (sod-message-argument-tail message)))
131 ;;;--------------------------------------------------------------------------
132 ;;; Direct method classes.
134 (defclass basic-direct-method (sod-method)
135 ((role :initarg :role
137 :reader sod-method-role)
138 (function-type :type c-function-type
139 :reader sod-method-function-type))
141 "Base class for built-in direct method classes.
143 Provides the basic functionality for the built-in direct-method classes.
144 This is a separate class so that `special effect' methods can avoid
145 inheriting its default behaviour and slots.
147 A basic method can be assigned a `role', which may be set either as an
148 initarg or using the :ROLE property. Roles are used for method
151 The function type protocol is implemented on BASIC-DIRECT-METHOD using
152 slot reader methods. The actual values are computed on demand in methods
153 defined on SLOT-UNBOUND."))
155 (defmethod shared-initialize :after
156 ((method basic-direct-method) slot-names &key pset)
157 (declare (ignore slot-names))
158 (default-slot (method 'role) (get-property pset :role :keyword nil)))
160 (defmethod slot-unbound
161 (class (method basic-direct-method) (slot-name (eql 'function-type)))
162 (let ((type (sod-method-type method)))
163 (setf (slot-value method 'function-type)
164 (c-type (fun (lisp (c-type-subtype type))
165 ("me" (* (class (sod-method-class method))))
166 . (c-function-arguments type))))))
168 (defmethod direct-method-function-name ((method basic-direct-method))
169 (with-slots (class role message) method
170 (format nil "~A__~@[~(~A~)_~]method_~A__~A" class role
171 (sod-class-nickname (sod-message-class message))
172 (sod-message-name message))))
174 (defclass daemon-direct-method (basic-direct-method)
177 "A daemon direct method is invoked for side effects and cannot override.
179 This is the direct method class for `before' and `after' methods, which
180 cannot choose to override the remaining methods and are not involved in
181 the computation of the final result.
183 In C terms, a daemon method must return `void', and is not passed a
184 `next_method' pointer."))
186 (defmethod check-method-type
187 ((method daemon-direct-method)
188 (message sod-message)
189 (type c-function-type))
190 (with-slots ((msgtype type)) message
191 (unless (c-type-equal-p (c-type-subtype type) (c-type void))
192 (error "Method return type ~A must be `void'" (c-type-subtype type)))
193 (unless (argument-lists-compatible-p (c-function-arguments msgtype)
194 (c-function-arguments type))
195 (error "Method arguments ~A don't match message ~A" type msgtype))))
197 (defclass delegating-direct-method (basic-direct-method)
198 ((next-method-type :type c-function-type
199 :reader sod-method-next-method-type))
201 "A delegating direct method can choose to override other methods.
203 This is the direct method class for `around' and standard-method-
204 combination primary methods, which are given the choice of computing the
205 entire method's result or delegating to (usually) less-specific methods.
207 In C terms, a delegating method is passed a `next_method' pointer so that
208 it can delegate part of its behaviour. (A delegating direct method for a
209 varargs message is also given an additional `va_list' argument,
210 conventionally named `sod__ap_master', which it is expected to pass on to
211 its `next_method' function if necessary.)
213 The function type protocol is implemented on DELEGATING-DIRECT-METHOD
214 using slot reader methods. The actual values are computed on demand in
215 methods defined on SLOT-UNBOUND."))
217 (defmethod slot-unbound (class
218 (method delegating-direct-method)
219 (slot-name (eql 'next-method-type)))
220 (let* ((message (sod-method-message method))
221 (type (sod-message-type message)))
222 (setf (slot-value method 'next-method-type)
223 (c-type (fun (lisp (c-type-subtype type))
224 ("me" (* (class (sod-method-class method))))
225 . (c-function-arguments type))))))
227 (defmethod slot-unbound (class
228 (method delegating-direct-method)
229 (slot-name (eql 'function-type)))
230 (let* ((message (sod-method-message method))
231 (type (sod-method-type method))
232 (method-args (c-function-arguments type)))
233 (setf (slot-value method 'function-type)
234 (c-type (fun (lisp (c-type-subtype type))
235 ("me" (* (class (sod-method-class method))))
236 ("next_method" (* (lisp (commentify-function-type
237 (sod-method-next-method-type
239 . (if (varargs-message-p message)
240 (cons (make-argument *sod-master-ap*
245 ;;;--------------------------------------------------------------------------
246 ;;; Effective method classes.
248 (defgeneric effective-method-basic-argument-names (method)
250 "Return a list of argument names to be passed to direct methods.
252 The argument names are constructed from the message's arguments returned
253 by SOD-MESSAGE-NO-VARARGS-TAIL. The basic arguments are the ones
254 immediately derived from the programmer's explicitly stated arguments; the
255 `me' argument is not included, and neither are more exotic arguments added
256 as part of the method delegation protocol."))
258 (defclass basic-effective-method (effective-method)
259 ((around-methods :initarg :around-methods
262 :reader effective-method-around-methods)
263 (before-methods :initarg :before-methods
266 :reader effective-method-before-methods)
267 (after-methods :initarg :after-methods
270 :reader effective-method-after-methods)
271 (basic-argument-names :type list
272 :reader effective-method-basic-argument-names)
273 (functions :type list :reader effective-method-functions))
275 "Base class for built-in effective method classes.
277 This class maintains lists of the applicable `before', `after' and
278 `around' methods and provides behaviour for invoking these methods
281 The argument names protocol is implemented on BASIC-EFFECTIVE-METHOD using
282 a slot reader method. The actual values are computed on demand in methods
283 defined on SLOT-UNBOUND."))
285 (defmethod slot-unbound (class
286 (method basic-effective-method)
287 (slot-name (eql 'basic-argument-names)))
288 (let ((message (effective-method-message method)))
289 (setf (slot-value method 'basic-argument-names)
290 (subst *sod-master-ap* *sod-ap*
291 (mapcar #'argument-name
292 (sod-message-no-varargs-tail message))))))
294 ;;;--------------------------------------------------------------------------
295 ;;; Method categorization.
297 (defmacro categorize ((itemvar items &key bind) categories &body body)
298 "Categorize ITEMS into lists and invoke BODY.
300 The ITEMVAR is a symbol; as the macro iterates over the ITEMS, ITEMVAR
301 will contain the current item. The BIND argument is a list of LET*-like
302 clauses. The CATEGORIES are a list of clauses of the form (SYMBOL
305 The behaviour of the macro is as follows. ITEMVAR is assigned (not
306 bound), in turn, each item in the list ITEMS. The PREDICATEs in the
307 CATEGORIES list are evaluated in turn, in an environment containing
308 ITEMVAR and the BINDings, until one of them evaluates to a non-nil value.
309 At this point, the item is assigned to the category named by the
310 corresponding SYMBOL. If none of the PREDICATEs returns non-nil then an
311 error is signalled; a PREDICATE consisting only of T will (of course)
312 match anything; it is detected specially so as to avoid compiler warnings.
314 Once all of the ITEMS have been categorized in this fashion, the BODY is
315 evaluated as an implicit PROGN. For each SYMBOL naming a category, a
316 variable named after that symbol will be bound in the BODY's environment
317 to a list of the items in that category, in the same order in which they
318 were found in the list ITEMS. The final values of the macro are the final
321 (let* ((cat-names (mapcar #'car categories))
322 (cat-match-forms (mapcar #'cadr categories))
323 (cat-vars (mapcar (lambda (name) (gensym (symbol-name name)))
325 (items-var (gensym "ITEMS")))
326 `(let ((,items-var ,items)
327 ,@(mapcar (lambda (cat-var) (list cat-var nil)) cat-vars))
328 (dolist (,itemvar ,items-var)
330 (cond ,@(mapcar (lambda (cat-match-form cat-var)
332 (push ,itemvar ,cat-var)))
333 cat-match-forms cat-vars)
334 ,@(and (not (member t cat-match-forms))
335 `((t (error "Failed to categorize ~A" ,itemvar)))))))
336 (let ,(mapcar (lambda (name var)
337 `(,name (nreverse ,var)))
341 ;;;--------------------------------------------------------------------------
344 (defclass method-codegen (codegen)
345 ((message :initarg :message :type sod-message :reader codegen-message)
346 (class :initarg :class :type sod-class :reader codegen-class)
347 (method :initarg :method :type effective-method :reader codegen-method)
348 (target :initarg :target :reader codegen-target))
350 "Augments CODEGEN with additional state regarding an effective method.
352 We store the effective method, and also its target class and owning
353 message, so that these values are readily available to the code-generating
356 (defmethod shared-initialize :after
357 ((codegen method-codegen) slot-names &key)
358 (with-slots (message target) codegen
360 (if (eq (c-type-subtype (sod-message-type message)) (c-type void))
364 (defgeneric compute-effective-method-body (method codegen target)
366 "Generates the body of an effective method.
368 Writes the function body to the code generator. It can (obviously)
369 generate auxiliary functions if it needs to.
371 The arguments are as specified by the SOD-MESSAGE-NO-VARARGS-TAIL, with an
372 additional argument `sod__obj' of type pointer-to-ilayout. The code
373 should deliver the result (if any) to the TARGET."))
375 (defun invoke-method (codegen target arguments-tail direct-method)
376 "Emit code to invoke DIRECT-METHOD, passing it ARGUMENTS-TAIL.
378 The code is generated in the context of CODEGEN, which can be any instance
379 of the CODEGEN class -- it needn't be an instance of METHOD-CODEGEN. The
380 DIRECT-METHOD is called with the given ARGUMENTS-TAIL (a list of argument
381 expressions), preceded by a `me' argument of type pointer-to-CLASS where
382 CLASS is the class on which the method was defined.
384 If the message accepts a variable-length argument list then a copy of the
385 prevailing master argument pointer is provided in place of the :ELLIPSIS."
387 (let* ((message (sod-method-message direct-method))
388 (class (sod-method-class direct-method))
389 (function (direct-method-function-name direct-method))
390 (arguments (cons (format nil "(~A *)&sod__obj.~A" class
392 (sod-class-chain-head class)))
394 (if (varargs-message-p message)
395 (convert-stmts codegen target
396 (c-type-subtype (sod-method-type direct-method))
398 (ensure-var codegen *sod-ap* (c-type va-list))
400 (make-va-copy-inst *sod-ap*
402 (deliver-expr codegen var
403 (make-call-inst function arguments))
405 (make-va-end-inst *sod-ap*))))
406 (deliver-expr codegen target (make-call-inst function arguments)))))
408 (definst convert-to-ilayout (stream) (class chain-head expr)
409 (format stream "SOD_ILAYOUT(~@<~A, ~_~A, ~_~A~:>)"
410 class (sod-class-nickname chain-head) expr))
412 (defun ensure-ilayout-var (codegen super)
413 "Define a variable `sod__obj' pointing to the class's ilayout structure.
415 CODEGEN is a METHOD-CODEGEN. The class in question is CODEGEN's class,
416 i.e., the target class for the effective method. SUPER is one of the
417 class's superclasses; it is assumed that `me' is a pointer to a SUPER
418 (i.e., to SUPER's ichain within the ilayout)."
420 (let* ((class (codegen-class codegen))
421 (super-head (sod-class-chain-head super)))
422 (ensure-var codegen "sod__obj"
423 (c-type (* (struct (ilayout-struct-tag class))))
424 (make-convert-to-ilayout-inst class super-head "me"))))
426 (defun make-trampoline (codegen super body)
427 "Construct a trampoline function and return its name.
429 CODEGEN is a METHOD-CODEGEN. SUPER is a superclass of the CODEGEN class.
430 We construct a new trampoline function (with an unimaginative name)
431 suitable for being passed to a direct method defined on SUPER as its
432 `next_method'. In particular, it will have a `me' argument whose type is
435 The code of the function is generated by BODY, which will be invoked with
436 a single argument which is the TARGET to which it should deliver its
439 The return value is the name of the generated function."
441 (let* ((message (codegen-message codegen))
442 (message-type (sod-message-type message))
443 (return-type (c-type-subtype message-type))
444 (arguments (mapcar (lambda (arg)
445 (if (eq (argument-name arg) *sod-ap*)
446 (make-argument *sod-master-ap*
449 (sod-message-no-varargs-tail message))))
450 (codegen-push codegen)
451 (ensure-ilayout-var codegen super)
452 (funcall body (codegen-target codegen))
453 (codegen-pop-function codegen (temporary-function)
454 (c-type (fun (lisp return-type)
455 ("me" (* (class super)))
458 (defun invoke-delegation-chain (codegen target basic-tail chain kernel)
459 "Invoke a chain of delegating methods.
461 CODEGEN is a METHOD-CODEGEN. BASIC-TAIL is a list of argument expressions
462 to provide to the methods. The result of the delegation chain will be
465 The CHAIN is a list of DELEGATING-DIRECT-METHOD objects. The behaviour is
466 as follows. The first method in the chain is invoked with the necessary
467 arguments (see below) including a `next_method' pointer. If KERNEL is nil
468 and there are no more methods in the chain then the `next_method' pointer
469 will be null; otherwise it will point to a `trampoline' function, whose
470 behaviour is to call the remaining methods on the chain as a delegation
471 chain. The method may choose to call this function with its arguments.
472 It will finally return a value, which will be delivered to the TARGET.
474 If the chain is empty, then the code generated by KERNEL (given a TARGET
475 argument) will be invoked. It is an error if both CHAIN and KERNEL are
478 (let* ((message (codegen-message codegen))
479 (argument-tail (if (varargs-message-p message)
480 (cons *sod-master-ap* basic-tail)
482 (labels ((next-trampoline (method chain)
483 (if (or kernel chain)
484 (make-trampoline codegen (sod-method-class method)
486 (invoke chain target)))
488 (invoke (chain target)
490 (funcall kernel target)
491 (let* ((trampoline (next-trampoline (car chain)
493 (invoke-method codegen target
494 (cons trampoline argument-tail)
496 (invoke chain target))))
498 (defun basic-effective-method-body (codegen target method body)
499 "Build the common method-invocation structure.
501 Writes to CODEGEN some basic method-invocation instructions. It invokes
502 the `around' methods, from most- to least-specific. If they all delegate,
503 then the `before' methods are run, most-specific first; next, the
504 instructions generated by BODY (invoked with a target argument); then, the
505 `after' methods are run, least-specific first; and, finally, the value
506 delivered by the BODY is returned to the `around' methods. The result
507 returned by the outermost `around' method -- or, if there are none,
508 delivered by the BODY -- is finally delivered to the TARGET."
510 (with-slots (message class before-methods after-methods around-methods)
512 (let* ((message-type (sod-message-type message))
513 (return-type (c-type-subtype message-type))
514 (voidp (eq return-type (c-type void)))
515 (basic-tail (effective-method-basic-argument-names method)))
516 (flet ((method-kernel (target)
517 (dolist (before before-methods)
518 (invoke-method codegen :void basic-tail before))
519 (if (or voidp (null after-methods))
520 (funcall body target)
521 (convert-stmts codegen target return-type
523 (funcall body target)
524 (dolist (after (reverse after-methods))
525 (invoke-method codegen :void
526 after basic-tail)))))))
527 (invoke-delegation-chain codegen target basic-tail
528 around-methods #'method-kernel)))))
530 ;;;--------------------------------------------------------------------------
531 ;;; Effective method entry points.
533 (defgeneric compute-method-entry-functions (method)
535 "Construct method entry functions.
537 Builds the effective method function (if there is one) and the necessary
538 method entries. Returns a list of functions (i.e., FUNCTION-INST objects)
539 which need to be defined in the generated source code."))
541 (defparameter *method-entry-inline-threshold* 20
542 "Threshold below which effective method bodies are inlined into entries.
544 After the effective method body has been computed, we calculate its
545 metric, multiply by the number of entries we need to generate, and compare
546 it with this threshold. If the metric is below the threshold then we
547 fold the method body into the entry functions; otherwise we split the
548 effective method out into its own function.")
550 (defgeneric effective-method-function-name (method)
552 "Returns the function name of an effective method."))
554 (defgeneric method-entry-function-name (method chain-head)
556 "Returns the function name of a method entry.
558 The method entry is given as an effective method/chain-head pair, rather
559 than as a method entry object because we want the function name before
560 we've made the entry object."))
562 (defmethod effective-method-function-name ((method effective-method))
563 (let* ((class (effective-method-class method))
564 (message (effective-method-message method))
565 (message-class (sod-message-class message)))
566 (format nil "~A__emethod_~A__~A"
568 (sod-class-nickname message-class)
569 (sod-message-name message))))
571 (defmethod method-entry-function-name
572 ((method effective-method) (chain-head sod-class))
573 (let* ((class (effective-method-class method))
574 (message (effective-method-message method))
575 (message-class (sod-message-class message)))
576 (format nil "~A__mentry_~A__~A__~A"
578 (sod-class-nickname message-class)
579 (sod-message-name message)
580 (sod-class-nickname chain-head))))
582 (defmethod compute-method-entry-functions ((method basic-effective-method))
584 ;; OK, there's quite a lot of this, so hold tight.
586 ;; The first thing we need to do is find all of the related objects. This
587 ;; is a bit verbose but fairly straightforward.
589 ;; Next, we generate the effective method body -- using COMPUTE-EFFECTIVE-
590 ;; METHOD-BODY of all things. This gives us the declarations and body for
591 ;; an effective method function, but we don't have an actual function yet.
593 ;; Now we look at the chains which are actually going to need a method
594 ;; entry: only those chains whose tail (most specific) class is a
595 ;; superclass of the class which defined the message need an entry. We
596 ;; build a list of these tail classes.
598 ;; Having done this, we decide whether it's better to generate a standalone
599 ;; effective-method function and call it from each of the method entries,
600 ;; or to inline the effective method body into each of the entries.
602 ;; Most of the complexity here comes from (a) dealing with the two
603 ;; different strategies for constructing method entry functions and (b)
604 ;; (unsurprisingly) the mess involved with dealing with varargs messages.
606 (let* ((message (effective-method-message method))
607 (class (effective-method-class method))
608 (message-class (sod-message-class message))
609 (return-type (c-type-subtype (sod-message-type message)))
610 (codegen (make-instance 'method-codegen
615 ;; Effective method function details.
616 (emf-name (effective-method-function-name method))
617 (ilayout-type (c-type (* (struct (ilayout-struct-tag class)))))
618 (emf-arg-tail (mapcar (lambda (arg)
619 (if (eq (argument-name arg) *sod-ap*)
620 (make-argument *sod-master-ap*
623 (sod-message-no-varargs-tail message)))
624 (emf-type (c-type (fun (lisp return-type)
625 ("sod__obj" (lisp ilayout-type))
626 . (sod-message-no-varargs-tail message))))
627 (result (if (eq return-type (c-type void)) nil
628 (temporary-var codegen return-type)))
629 (emf-target (or result :void))
631 ;; Method entry details.
632 (chain-tails (remove-if-not (lambda (super)
633 (sod-subclass-p super message-class))
635 (sod-class-chains class))))
636 (n-entries (length chain-tails))
637 (entry-args (sod-message-argument-tail message))
638 (parm-n (do ((prev "me" (car args))
639 (args entry-args (cdr args)))
641 (when (eq (car args) :ellipsis)
643 (entry-target (codegen-target codegen)))
645 (labels ((setup-entry (tail)
646 (let ((head (sod-class-chain-head tail)))
647 (codegen-push codegen)
648 (ensure-var codegen "sod__obj" ilayout-type
649 (make-convert-to-ilayout-inst class
652 (ensure-var codegen *sod-master-ap* (c-type va-list))
654 (make-va-start-inst *sod-master-ap* parm-n)))
656 (emit-inst codegen (make-va-end-inst *sod-master-ap*)))
658 (let* ((head (sod-class-chain-head tail))
659 (name (method-entry-function-name method head))
660 (type (c-type (fun (lisp return-type)
661 ("me" (* (class tail)))
663 (codegen-pop-function codegen name type))))
665 ;; Generate the method body. We'll work out what to do with it later.
666 (codegen-push codegen)
667 (compute-effective-method-body method codegen emf-target)
668 (multiple-value-bind (vars insts) (codegen-pop codegen)
669 (cond ((or (= n-entries 1)
670 (<= (* n-entries (reduce #'+ insts :key #'inst-metric))
671 *method-entry-inline-threshold*))
673 ;; The effective method body is simple -- or there's only one
674 ;; of them. We'll inline the method body into the entry
676 (dolist (tail chain-tails)
679 (ensure-var codegen (inst-name var)
680 (inst-type var) (inst-init var)))
681 (when parm-n (varargs-prologue))
682 (emit-insts codegen insts)
683 (when parm-n (varargs-epilogue))
684 (deliver-expr codegen entry-target result)
685 (finish-entry tail)))
689 ;; The effective method body is complicated and we'd need more
690 ;; than one copy. We'll generate an effective method function
691 ;; and call it a lot.
692 (codegen-build-function codegen emf-name emf-type vars
693 (nconc insts (and result (list (make-return-inst result)))))
695 (let ((call (make-call-inst emf-name
696 (cons "sod__obj" (mapcar #'argument-name
698 (dolist (tail chain-tails)
702 (convert-stmts codegen entry-target return-type
704 (deliver-expr codegen target call)
705 (varargs-epilogue))))
707 (deliver-expr codegen entry-target call)))
708 (finish-entry tail))))))
710 (codegen-functions codegen))))
712 (defmethod slot-unbound
713 (class (method basic-effective-method) (slot-name (eql 'functions)))
714 (setf (slot-value method 'functions)
715 (compute-method-entry-functions method)))
717 (defmethod make-method-entry
718 ((method basic-effective-method) (chain-head sod-class))
719 (make-instance 'method-entry :method method :chain-head chain-head))
721 ;;;----- That's all, folks --------------------------------------------------