Turn the body of a tail-recursive method into a loop.
(atj-elim-tailrec name params body) → new-block
This is called only on tail-recursive methods.
We replace the recursive calls in the block
and we surround the block with a
Under suitable conditions,
it should be possible to generate more idiomatic
Because of the constant
Function:
(defun atj-elim-tailrec (name params body) (declare (xargs :guard (and (stringp name) (jparam-listp params) (jblockp body)))) (let ((__function__ 'atj-elim-tailrec)) (declare (ignorable __function__)) (list (make-jstatem-while :test (jexpr-literal-true) :body (atj-elim-tailrec-in-jblock body params name)))))
Theorem:
(defthm jblockp-of-atj-elim-tailrec (b* ((new-block (atj-elim-tailrec name params body))) (jblockp new-block)) :rule-classes :rewrite)