Expand uses of defines like
(vl-expand-define name echars loc ppst) → (mv successp new-echars ppst)
Note that variables in `define are lazy, e.g., if you do:
`define foo 3 `define bar `foo `define foo 4
Then from here on
Subtle. If we simply inserted the echars stored in the defines table,
then locations on these characters would refer to their original position in
the file. This might lead to confusing error messages, telling you that
something is wrong and showing you line numbers for a
Function:
(defun vl-expand-define (name echars loc ppst) (declare (xargs :stobjs (ppst))) (declare (xargs :guard (and (stringp name) (vl-echarlist-p echars) (vl-location-p loc)))) (let ((__function__ 'vl-expand-define)) (declare (ignorable __function__)) (b* ((echars (vl-echarlist-fix echars)) (lookup (vl-find-define name (vl-ppst->defines))) ((unless lookup) (let ((ppst (vl-ppst-fatal :msg "~a0: `~s1 is not defined." :args (list loc name)))) (mv nil echars ppst))) ((vl-define lookup)) ((when (atom lookup.formals)) (b* (((mv okp rev-replacement-body ppst) (vl-substitute-into-macro-text (vl-change-echarlist-locations (vl-echarlist-from-str lookup.body) loc) nil name loc nil ppst)) ((unless okp) (mv nil echars ppst)) (replacement-body (rev rev-replacement-body)) (echars (append replacement-body echars))) (mv t echars ppst))) ((mv ?ws echars) (vl-read-while-whitespace echars)) ((unless (and (consp echars) (eql (vl-echar->char (car echars)) #\())) (let ((ppst (vl-ppst-fatal :msg "~a0: `~s1 requires arguments." :args (list loc name)))) (mv nil echars ppst))) (echars (cdr echars)) ((mv successp actuals echars ppst) (vl-parse-define-actuals name echars loc ppst)) ((unless successp) (mv nil echars ppst)) ((mv successp subst ppst) (vl-line-up-define-formals-and-actuals lookup.formals actuals name loc ppst)) ((unless successp) (mv nil echars ppst)) ((mv okp rev-replacement-body ppst) (vl-substitute-into-macro-text (vl-change-echarlist-locations (vl-echarlist-from-str lookup.body) loc) subst name loc nil ppst)) ((unless okp) (mv nil echars ppst)) (replacement-body (rev rev-replacement-body)) (echars (append replacement-body echars))) (mv t echars ppst))))
Theorem:
(defthm booleanp-of-vl-expand-define.successp (b* (((mv ?successp ?new-echars ?ppst) (vl-expand-define name echars loc ppst))) (booleanp successp)) :rule-classes :type-prescription)
Theorem:
(defthm vl-echarlist-p-of-vl-expand-define.new-echars (b* (((mv ?successp ?new-echars ?ppst) (vl-expand-define name echars loc ppst))) (vl-echarlist-p new-echars)) :rule-classes :rewrite)