Rather than canonifying to an integer result, effective methods with
`and' and `or' method combination now return the decisive value -- which
means that they can be used with any scalar return type (so the type
restriction has been removed).
Most significantly, the `or' combination is very useful with pointer
returns: it returns the result of the most specific direct method which
returns a non-null value.
(emit-inst codegen (make-if-inst (format nil "~A < ~A" acc val)
(make-set-inst acc val) nil))))
(emit-inst codegen (make-if-inst (format nil "~A < ~A" acc val)
(make-set-inst acc val) nil))))
-(define-aggregating-method-combination :and ((ret val) :codegen codegen)
- :return-type int
+(define-aggregating-method-combination :and ((ret) :codegen codegen)
:around (lambda (body)
(codegen-push codegen)
:around (lambda (body)
(codegen-push codegen)
- (deliver-expr codegen ret 0)
- (deliver-expr codegen ret 1)
(emit-inst codegen
(make-do-while-inst (codegen-pop-block codegen) 0)))
:methods (lambda (invoke)
(emit-inst codegen
(make-do-while-inst (codegen-pop-block codegen) 0)))
:methods (lambda (invoke)
- (funcall invoke val)
- (emit-inst codegen (make-if-inst (format nil "!~A" val)
+ (funcall invoke ret)
+ (emit-inst codegen (make-if-inst (format nil "!~A" ret)
(make-break-inst) nil))))
(make-break-inst) nil))))
-(define-aggregating-method-combination :or ((ret val) :codegen codegen)
- :return-type int
+(define-aggregating-method-combination :or ((ret) :codegen codegen)
:around (lambda (body)
(codegen-push codegen)
:around (lambda (body)
(codegen-push codegen)
- (deliver-expr codegen ret 1)
- (deliver-expr codegen ret 0)
(emit-inst codegen
(make-do-while-inst (codegen-pop-block codegen) 0)))
:methods (lambda (invoke)
(emit-inst codegen
(make-do-while-inst (codegen-pop-block codegen) 0)))
:methods (lambda (invoke)
- (funcall invoke val)
- (emit-inst codegen (make-if-inst val (make-break-inst) nil))))
+ (funcall invoke ret)
+ (emit-inst codegen (make-if-inst ret (make-break-inst) nil))))
;;;--------------------------------------------------------------------------
;;; A customizable aggregating method combination.
;;;--------------------------------------------------------------------------
;;; A customizable aggregating method combination.