Generate a term representing the ending computation state after the execution of a C function.
(atc-gen-fun-endstate affect typed-formals compst-var prec-objs) → term
This is similar to atc-gen-cfun-final-compustate, which eventually will be removed in favor of this one, once the new modular proof approach works for every C function generated by ATC.
The correctness theorem of a C function says that
executing the function on a generic computation state
(satisfying conditions in the hypotheses of the theorem)
and on generic arguments
yields an optional result (absent if the function is
The parameter
We add the suffix
Function:
(defun atc-gen-fun-endstate (affect typed-formals compst-var prec-objs) (declare (xargs :guard (and (symbol-listp affect) (atc-symbol-varinfo-alistp typed-formals) (symbolp compst-var) (atc-string-objinfo-alistp prec-objs)))) (let ((__function__ 'atc-gen-fun-endstate)) (declare (ignorable __function__)) (b* (((when (endp affect)) compst-var) (formal (car affect)) (info (cdr (assoc-eq formal typed-formals))) ((when (not info)) (raise "Internal error: formal ~x0 not found." formal)) (type (atc-var-info->type info)) ((unless (or (type-case type :pointer) (type-case type :array) (atc-var-info->externalp info))) (raise "Internal error: affected formal ~x0 has type ~x1 and is not an external object." formal type)) (var (add-suffix-to-fn formal "-NEW"))) (if (consp (assoc-equal (symbol-name formal) prec-objs)) (cons 'write-static-var (cons (cons 'ident (cons (symbol-name formal) 'nil)) (cons var (cons (atc-gen-fun-endstate (cdr affect) typed-formals compst-var prec-objs) 'nil)))) (cons 'write-object (cons (add-suffix-to-fn formal "-OBJDES") (cons var (cons (atc-gen-fun-endstate (cdr affect) typed-formals compst-var prec-objs) 'nil))))))))