process an ops method's prototype once

Registering a method processed its prototype only for the signature it
records, and a method called from above was processed again to be
declared ahead.
This commit is contained in:
2026-10-19 18:21:10 +03:00
parent 64db505e6b
commit a4880f1b96

View File

@@ -425,12 +425,16 @@
(sex-error form "ops needs a type name" form))
(let* ((methods (map (lambda (m) (register-op type m)) (cddr form)))
(fns (remove comment-form? methods))
;; the signatures too, which a call's receiver is fitted to
(protos (map (lambda (m) (process-fn (sex-fn-prototype m) (list))) fns))
(bodies (map (lambda (m)
(if (comment-form? m) (list m) (process-fn m (list))))
methods))
(early (filter (lambda (m) (called-before? m methods bodies)) fns)))
(append (append-map identity (reverse bodies))
(fold (lambda (m acc) (process-fn (sex-fn-prototype m) acc)) acc early)))))
(early (filter-map (lambda (m proto)
(and (called-before? m methods bodies) proto))
fns protos)))
(append (concatenate (reverse bodies))
(fold append acc early)))))
;;; The method's fn form, renamed to vec2/length, once it is registered
;;; under `length'; a comment is passed along
@@ -447,8 +451,6 @@
(let* ((qualified (qualify-op type name))
(renamed (rename-fn form qualified)))
(add-method! type name qualified)
;; its signature too, which a call's receiver is fitted to
(process-fn (sex-fn-prototype renamed) (list))
renamed)))))
;;; Does a body written above METHOD call it?