Transform an external declaration list.
(extdecl-list-wrap-fn extdecls target-name wrapper-name? blacklist) → (mv er? foundp found-satp extdecls$)
This searches for an external declaration matching the target function. When it finds one, it creates the function wrapper. It then substitutes the wrapper function for the original function in direct function calls occurring in the remainder of the translation unit.
Function:
(defun extdecl-list-wrap-fn (extdecls target-name wrapper-name? blacklist) (declare (xargs :guard (and (extdecl-listp extdecls) (identp target-name) (ident-optionp wrapper-name?) (ident-setp blacklist)))) (declare (xargs :guard (extdecl-list-annop extdecls))) (b* (((reterr) nil nil nil) ((when (endp extdecls)) (retok nil nil nil)) (extdecl (extdecl-fix (first extdecls))) ((erp uid? wrapper? wrapper-name?$) (extdecl-wrap-fn-add-wrapper-def extdecl target-name wrapper-name? blacklist)) ((when (and uid? wrapper?)) (retok t t (list* extdecl (extdecl-fundef wrapper?) (extdecl-list-rename-fn (rest extdecls) uid? wrapper-name?$)))) ((erp foundp$ found-satp extdecls$) (extdecl-list-wrap-fn (rest extdecls) target-name wrapper-name? blacklist))) (retok (if uid? t foundp$) found-satp (cons extdecl extdecls$))))
Theorem:
(defthm maybe-msgp-of-extdecl-list-wrap-fn.er? (b* (((mv ?er? ?foundp ?found-satp ?extdecls$) (extdecl-list-wrap-fn extdecls target-name wrapper-name? blacklist))) (maybe-msgp er?)) :rule-classes :rewrite)
Theorem:
(defthm booleanp-of-extdecl-list-wrap-fn.foundp (b* (((mv ?er? ?foundp ?found-satp ?extdecls$) (extdecl-list-wrap-fn extdecls target-name wrapper-name? blacklist))) (booleanp foundp)) :rule-classes :type-prescription)
Theorem:
(defthm booleanp-of-extdecl-list-wrap-fn.found-satp (b* (((mv ?er? ?foundp ?found-satp ?extdecls$) (extdecl-list-wrap-fn extdecls target-name wrapper-name? blacklist))) (booleanp found-satp)) :rule-classes :type-prescription)
Theorem:
(defthm extdecl-listp-of-extdecl-list-wrap-fn.extdecls$ (b* (((mv ?er? ?foundp ?found-satp ?extdecls$) (extdecl-list-wrap-fn extdecls target-name wrapper-name? blacklist))) (extdecl-listp extdecls$)) :rule-classes :rewrite)
Theorem:
(defthm true-listp-of-extdecl-list-wrap-fn.extdecls$ (b* (((mv ?er? ?foundp ?found-satp ?extdecls$) (extdecl-list-wrap-fn extdecls target-name wrapper-name? blacklist))) (true-listp extdecls$)) :rule-classes :type-prescription)
Theorem:
(defthm extdecl-list-wrap-fn-of-extdecl-list-fix-extdecls (equal (extdecl-list-wrap-fn (extdecl-list-fix extdecls) target-name wrapper-name? blacklist) (extdecl-list-wrap-fn extdecls target-name wrapper-name? blacklist)))
Theorem:
(defthm extdecl-list-wrap-fn-extdecl-list-equiv-congruence-on-extdecls (implies (c$::extdecl-list-equiv extdecls extdecls-equiv) (equal (extdecl-list-wrap-fn extdecls target-name wrapper-name? blacklist) (extdecl-list-wrap-fn extdecls-equiv target-name wrapper-name? blacklist))) :rule-classes :congruence)
Theorem:
(defthm extdecl-list-wrap-fn-of-ident-fix-target-name (equal (extdecl-list-wrap-fn extdecls (ident-fix target-name) wrapper-name? blacklist) (extdecl-list-wrap-fn extdecls target-name wrapper-name? blacklist)))
Theorem:
(defthm extdecl-list-wrap-fn-ident-equiv-congruence-on-target-name (implies (c$::ident-equiv target-name target-name-equiv) (equal (extdecl-list-wrap-fn extdecls target-name wrapper-name? blacklist) (extdecl-list-wrap-fn extdecls target-name-equiv wrapper-name? blacklist))) :rule-classes :congruence)
Theorem:
(defthm extdecl-list-wrap-fn-of-ident-option-fix-wrapper-name? (equal (extdecl-list-wrap-fn extdecls target-name (ident-option-fix wrapper-name?) blacklist) (extdecl-list-wrap-fn extdecls target-name wrapper-name? blacklist)))
Theorem:
(defthm extdecl-list-wrap-fn-ident-option-equiv-congruence-on-wrapper-name? (implies (c$::ident-option-equiv wrapper-name? wrapper-name?-equiv) (equal (extdecl-list-wrap-fn extdecls target-name wrapper-name? blacklist) (extdecl-list-wrap-fn extdecls target-name wrapper-name?-equiv blacklist))) :rule-classes :congruence)
Theorem:
(defthm extdecl-list-wrap-fn-of-ident-set-fix-blacklist (equal (extdecl-list-wrap-fn extdecls target-name wrapper-name? (ident-set-fix blacklist)) (extdecl-list-wrap-fn extdecls target-name wrapper-name? blacklist)))
Theorem:
(defthm extdecl-list-wrap-fn-ident-set-equiv-congruence-on-blacklist (implies (c$::ident-set-equiv blacklist blacklist-equiv) (equal (extdecl-list-wrap-fn extdecls target-name wrapper-name? blacklist) (extdecl-list-wrap-fn extdecls target-name wrapper-name? blacklist-equiv))) :rule-classes :congruence)