Given a HID expression denoting a variable of the input type, create a trace showing the type of each field select/indexing operation.
(vl-follow-data-selects x type trace) → (mv err seltrace)
Implementation notes: This function only
Function:
(defun vl-follow-data-selects (x type trace) (declare (xargs :guard (and (vl-hidexpr-p x) (vl-datatype-p type) (vl-seltrace-p trace)))) (declare (xargs :guard (vl-datatype-resolved-p type))) (let ((__function__ 'vl-follow-data-selects)) (declare (ignorable __function__)) (b* ((type (vl-datatype-fix type)) (trace (vl-seltrace-fix trace)) ((when (vl-hidexpr-case x :end)) (mv nil trace)) ((vl-hidexpr-dot x)) ((mv err rev-idxtrace) (vl-follow-array-indices (vl-hidindex->indices x.first) type)) ((when err) (mv err nil)) (trace (revappend rev-idxtrace trace)) (type (if (consp rev-idxtrace) (vl-selstep->type (car trace)) type)) (type (vl-maybe-usertype-resolve type)) ((mv ok members) (vl-datatype->structmembers type)) (nextname (vl-hidexpr-case x.rest :end x.rest.name :dot (vl-hidindex->name x.rest.first))) ((unless (and ok (atom (vl-datatype->udims type)) (atom (vl-datatype->pdims type)))) (mv (vmsg "Dot-indexing (field ~s0) into a non-struct/union datatype: ~a1" nextname type) nil)) ((when (eq nextname :vl-$root)) (mv (vmsg "Can't use $root to index into a data structure: ~a0" (vl-hidexpr-fix x)) nil)) (member (vl-find-structmember nextname members)) ((unless member) (mv (vmsg "Dot-indexing failed: struct/union member ~ ~s0 not found in type ~a1" nextname (vl-datatype-fix type)) nil)) (membtype (vl-structmember->type member)) (next-frame (make-vl-selstep :select (make-vl-select-field :name nextname) :type membtype)) (trace (cons next-frame trace))) (vl-follow-data-selects x.rest membtype trace))))
Theorem:
(defthm return-type-of-vl-follow-data-selects.err (b* (((mv ?err ?seltrace) (vl-follow-data-selects x type trace))) (iff (vl-msg-p err) err)) :rule-classes :rewrite)
Theorem:
(defthm vl-seltrace-p-of-vl-follow-data-selects.seltrace (b* (((mv ?err ?seltrace) (vl-follow-data-selects x type trace))) (vl-seltrace-p seltrace)) :rule-classes :rewrite)
Theorem:
(defthm vl-seltrace-usertypes-ok-of-vl-follow-data-selects (b* (((mv ?err ?seltrace) (vl-follow-data-selects x type trace))) (implies (and (vl-datatype-resolved-p type) (vl-seltrace-usertypes-ok trace)) (vl-seltrace-usertypes-ok seltrace))))
Theorem:
(defthm vl-seltrace-indices-of-vl-follow-data-selects (b* (((mv ?err ?seltrace) (vl-follow-data-selects x type trace))) (implies (not err) (equal (vl-seltrace->indices seltrace) (revappend (vl-hidexpr->subexprs x) (vl-seltrace->indices trace))))))
Theorem:
(defthm vl-follow-data-selects-of-vl-hidexpr-fix-x (equal (vl-follow-data-selects (vl-hidexpr-fix x) type trace) (vl-follow-data-selects x type trace)))
Theorem:
(defthm vl-follow-data-selects-vl-hidexpr-equiv-congruence-on-x (implies (vl-hidexpr-equiv x x-equiv) (equal (vl-follow-data-selects x type trace) (vl-follow-data-selects x-equiv type trace))) :rule-classes :congruence)
Theorem:
(defthm vl-follow-data-selects-of-vl-datatype-fix-type (equal (vl-follow-data-selects x (vl-datatype-fix type) trace) (vl-follow-data-selects x type trace)))
Theorem:
(defthm vl-follow-data-selects-vl-datatype-equiv-congruence-on-type (implies (vl-datatype-equiv type type-equiv) (equal (vl-follow-data-selects x type trace) (vl-follow-data-selects x type-equiv trace))) :rule-classes :congruence)
Theorem:
(defthm vl-follow-data-selects-of-vl-seltrace-fix-trace (equal (vl-follow-data-selects x type (vl-seltrace-fix trace)) (vl-follow-data-selects x type trace)))
Theorem:
(defthm vl-follow-data-selects-vl-seltrace-equiv-congruence-on-trace (implies (vl-seltrace-equiv trace trace-equiv) (equal (vl-follow-data-selects x type trace) (vl-follow-data-selects x type trace-equiv))) :rule-classes :congruence)