Tail-recursive, executable loop for vl-read-file.
(vl-read-file-loop-aux channel filename line col len nrev &key (state 'state)) → (mv nrev len state)
You should never need to reason about this function directly, because it is typically rewritten into vl-read-file-loop using the following rule:
Theorem:
(defthm vl-read-file-loop-aux-redef (equal (vl-read-file-loop-aux channel filename line col len acc) (b* (((mv data & state) (vl-read-file-loop channel filename line col))) (mv (append acc data) (+ (lnfix len) (len data)) state))))
Function:
(defun vl-read-file-loop-aux-fn (channel filename line col len nrev state) (declare (xargs :stobjs (nrev state))) (declare (type string filename) (type (integer 1 *) line) (type (integer 0 *) col) (type (integer 0 *) len)) (declare (xargs :guard (and (stringp filename) (posp line) (natp col) (natp len) (and (symbolp channel) (open-input-channel-p channel :byte state))))) (declare (xargs :split-types t)) (let ((__function__ 'vl-read-file-loop-aux)) (declare (ignorable __function__)) (b* ((nrev (nrev-fix nrev)) (len (lnfix len)) ((unless (mbt (state-p state))) (mv nrev len state)) ((mv byte state) (read-byte$ channel state)) ((unless byte) (mv nrev len state)) ((the character char) (code-char (the (unsigned-byte 8) byte))) (echar (make-vl-echar-fast :char char :filename filename :line line :col col)) (newlinep (eql char #\Newline)) (next-line (if newlinep (the (integer 0 *) (+ 1 line)) line)) (next-col (if newlinep 0 (the (integer 0 *) (+ 1 col)))) (next-len (the (integer 0 *) (+ 1 len))) (nrev (nrev-push echar nrev))) (vl-read-file-loop-aux channel filename next-line next-col next-len nrev))))
Theorem:
(defthm natp-of-vl-read-file-loop-aux.len (b* (((mv acl2::?nrev acl2::?len acl2::?state) (vl-read-file-loop-aux-fn channel filename line col len nrev state))) (natp len)) :rule-classes :type-prescription)