Generate the ``make-self'' calls for the fields of a product type.
(defmake-self-gen-sum-case type prod
member-names fty-table make-self-table)
→
termFunction:
(defun defmake-self-gen-sum-case-loop (type fields member-names fty-table make-self-table) (declare (xargs :guard (and (symbolp type) (flexprod-field-listp fields) (symbol-listp member-names) (alistp fty-table) (alistp make-self-table)))) (let ((__function__ 'defmake-self-gen-sum-case-loop)) (declare (ignorable __function__)) (b* (((when (endp fields)) nil) (field (car fields)) (recog (flexprod-field->type field)) ((unless (symbolp recog)) (raise "Internal error: malformed field recognizer ~x0." recog)) (info (flextype-with-recognizer recog fty-table)) (field-type (and info (flextype->name info))) (accessor (flexprod-field->acc-name field)) ((unless field-type) (b* ((make-selfs (defmake-self-gen-sum-case-loop type (cdr fields) member-names fty-table make-self-table))) (cons (cons accessor (cons type 'nil)) make-selfs))) ((mv erp field-type-make-self) (defmake-self-get-make-self-fn field-type make-self-table)) ((when erp) (raise "~@0~%" erp)) (make-self (cons field-type-make-self (cons (cons accessor (cons type 'nil)) 'nil))) (make-selfs (defmake-self-gen-sum-case-loop type (cdr fields) member-names fty-table make-self-table))) (cons make-self make-selfs))))
Theorem:
(defthm true-listp-of-defmake-self-gen-sum-case-loop (b* ((make-selfs (defmake-self-gen-sum-case-loop type fields member-names fty-table make-self-table))) (true-listp make-selfs)) :rule-classes :rewrite)
Function:
(defun defmake-self-gen-sum-case (type prod member-names fty-table make-self-table) (declare (xargs :guard (and (symbolp type) (flexprod-p prod) (symbol-listp member-names) (alistp fty-table) (alistp make-self-table)))) (let ((__function__ 'defmake-self-gen-sum-case)) (declare (ignorable __function__)) (b* ((fields (flexprod->fields prod)) ((unless (flexprod-field-listp fields)) (raise "Internal error: malformed fields ~x0." fields)) (make-selfs (defmake-self-gen-sum-case-loop type fields member-names fty-table make-self-table))) (list* 'list (list 'quote (flexprod->ctor-name prod)) make-selfs))))