Safely add a dependency onto a package. If the package doesn't exist, add a warning instead of a dependency.
(vl-immdeps-add-pkgdep pkgname ans &key (ss 'ss) (ctx 'ctx)) → new-ans
Function:
(defun vl-immdeps-add-pkgdep-fn (pkgname ans ss ctx) (declare (xargs :guard (and (stringp pkgname) (vl-immdeps-p ans) (vl-scopestack-p ss) (any-p ctx)))) (let ((__function__ 'vl-immdeps-add-pkgdep)) (declare (ignorable __function__)) (b* ((pkgname (string-fix pkgname)) (pkg (vl-scopestack-find-package pkgname ss)) ((unless pkg) (vl-immdeps-add-error ans :type :vl-missing-package :msg "~a0: reference to unknown package ~a1." :args (list ctx pkgname) :fatalp t)) (ans (vl-immdeps-add-raw-dependency pkgname ans))) ans)))
Theorem:
(defthm vl-immdeps-p-of-vl-immdeps-add-pkgdep (b* ((new-ans (vl-immdeps-add-pkgdep-fn pkgname ans ss ctx))) (vl-immdeps-p new-ans)) :rule-classes :rewrite)
Theorem:
(defthm vl-immdeps-add-pkgdep-fn-of-str-fix-pkgname (equal (vl-immdeps-add-pkgdep-fn (str-fix pkgname) ans ss ctx) (vl-immdeps-add-pkgdep-fn pkgname ans ss ctx)))
Theorem:
(defthm vl-immdeps-add-pkgdep-fn-streqv-congruence-on-pkgname (implies (streqv pkgname pkgname-equiv) (equal (vl-immdeps-add-pkgdep-fn pkgname ans ss ctx) (vl-immdeps-add-pkgdep-fn pkgname-equiv ans ss ctx))) :rule-classes :congruence)
Theorem:
(defthm vl-immdeps-add-pkgdep-fn-of-vl-immdeps-fix-ans (equal (vl-immdeps-add-pkgdep-fn pkgname (vl-immdeps-fix ans) ss ctx) (vl-immdeps-add-pkgdep-fn pkgname ans ss ctx)))
Theorem:
(defthm vl-immdeps-add-pkgdep-fn-vl-immdeps-equiv-congruence-on-ans (implies (vl-immdeps-equiv ans ans-equiv) (equal (vl-immdeps-add-pkgdep-fn pkgname ans ss ctx) (vl-immdeps-add-pkgdep-fn pkgname ans-equiv ss ctx))) :rule-classes :congruence)
Theorem:
(defthm vl-immdeps-add-pkgdep-fn-of-vl-scopestack-fix-ss (equal (vl-immdeps-add-pkgdep-fn pkgname ans (vl-scopestack-fix ss) ctx) (vl-immdeps-add-pkgdep-fn pkgname ans ss ctx)))
Theorem:
(defthm vl-immdeps-add-pkgdep-fn-vl-scopestack-equiv-congruence-on-ss (implies (vl-scopestack-equiv ss ss-equiv) (equal (vl-immdeps-add-pkgdep-fn pkgname ans ss ctx) (vl-immdeps-add-pkgdep-fn pkgname ans ss-equiv ctx))) :rule-classes :congruence)
Theorem:
(defthm vl-immdeps-add-pkgdep-fn-of-identity-ctx (equal (vl-immdeps-add-pkgdep-fn pkgname ans ss (identity ctx)) (vl-immdeps-add-pkgdep-fn pkgname ans ss ctx)))
Theorem:
(defthm vl-immdeps-add-pkgdep-fn-equal-congruence-on-ctx (implies (equal ctx ctx-equiv) (equal (vl-immdeps-add-pkgdep-fn pkgname ans ss ctx) (vl-immdeps-add-pkgdep-fn pkgname ans ss ctx-equiv))) :rule-classes :congruence)