• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Community
    • Proof-automation
    • ACL2
    • Macro-libraries
    • Interfacing-tools
    • Hardware-verification
    • Software-verification
      • Kestrel-books
        • Crypto-hdwallet
        • Apt
        • Error-checking
        • Fty-extensions
        • Isar
        • Kestrel-utilities
        • Set
        • Soft
        • C
        • Bv
        • Imp-language
        • Event-macros
        • Java
          • Atj
            • Atj-implementation
              • Atj-types
              • Atj-java-primitive-array-model
              • Atj-java-abstract-syntax
              • Atj-input-processing
              • Atj-java-pretty-printer
              • Atj-code-generation
                • Atj-gen-test-method
                • Atj-shallow-code-generation
                • Atj-common-code-generation
                • Atj-shallow-quoted-constant-generation
                • Atj-pre-translation
                • Atj-gen-everything
                • Atj-name-translation
                • Atj-gen-test-cunit
                • Atj-gen-test-class
                • Atj-gen-main-file
                • Atj-post-translation
                  • Atj-post-translation-remove-array-write-calls
                  • Atj-post-translation-cache-const-methods
                    • Atj-cache-const-methods
                    • Atj-post-translation-tailrec-elimination
                    • Atj-post-translation-fold-returns
                    • Atj-post-translate-body
                    • Atj-post-translation-lift-loop-tests
                    • Atj-post-translation-simplify-conds
                    • Atj-post-translate-jcbody-elements
                    • Atj-post-translation-remove-continue
                  • Atj-deep-code-generation
                  • Atj-gen-test-methods
                  • Atj-gen-test-file
                  • Atj-gen-env-file
                  • Atj-gen-output-subdir
                • Atj-java-primitives
                • Atj-java-primitive-arrays
                • Atj-type-macros
                • Atj-java-syntax-operations
                • Atj-fn
                • Atj-library-extensions
                • Atj-java-input-types
                • Atj-test-structures
                • Aij-notions
                • Atj-macro-definition
              • Atj-tutorial
            • Aij
            • Language
          • Bitcoin
          • Ethereum
          • Yul
          • Zcash
          • ACL2-programming-language
          • Prime-fields
          • Json
          • Syntheto
          • File-io-light
          • Cryptography
          • Number-theory
          • Lists-light
          • Axe
          • Builtins
          • Solidity
          • Helpers
          • Htclient
          • Typed-lists-light
          • Arithmetic-light
        • X86isa
        • Axe
        • Execloader
      • Math
      • Testing-utilities
    • Atj-post-translation-cache-const-methods

    Atj-cache-const-methods

    Cache constant methods in static final fields, in a list of Java class body declarations.

    Signature
    (atj-cache-const-methods elems) → new-elems
    Arguments
    elems — Guard (jcbody-element-listp elems).
    Returns
    new-elems — Type (jcbody-element-listp new-elems).

    We leave member fields, member classes, and static initializers unchanged. If a member method satisfies the conditions described in atj-post-translation-cache-const-methods, we replace it with a field and a modified method as also explained there. Otherwise, we leave the method unchanged.

    Definitions and Theorems

    Function: atj-cache-const-methods

    (defun atj-cache-const-methods (elems)
     (declare (xargs :guard (jcbody-element-listp elems)))
     (let ((__function__ 'atj-cache-const-methods))
      (declare (ignorable __function__))
      (b* (((when (endp elems)) nil)
           (elem (car elems))
           ((when (jcbody-element-case elem :init))
            (cons (jcbody-element-fix elem)
                  (atj-cache-const-methods (cdr elems))))
           (memb (jcbody-element-member->get elem))
           ((when (or (jcmember-case memb :field)
                      (jcmember-case memb :class)))
            (cons (jcbody-element-fix elem)
                  (atj-cache-const-methods (cdr elems))))
           (meth (jcmember-method->get memb))
           ((when (consp (jmethod->params meth)))
            (cons (jcbody-element-fix elem)
                  (atj-cache-const-methods (cdr elems))))
           (body (jmethod->body meth))
           ((unless (= (len body) 1))
            (cons (jcbody-element-fix elem)
                  (atj-cache-const-methods (cdr elems))))
           (stmt (car body))
           ((unless (jstatem-case stmt :return))
            (cons (jcbody-element-fix elem)
                  (atj-cache-const-methods (cdr elems))))
           (expr (jstatem-return->expr? stmt))
           ((unless expr)
            (raise "Internal error: method ~x0 returns nothing."
                   meth))
           ((when (consp (jexpr-methods expr)))
            (cons (jcbody-element-fix elem)
                  (atj-cache-const-methods (cdr elems))))
           (result (jmethod->result meth))
           ((when (jresult-case result :void))
            (raise "Internal error: method ~x0 returns void."
                   meth))
           (type (jresult-type->get result))
           (name (jmethod->name meth))
           (fld (make-jfield :access (jaccess-private)
                             :static? t
                             :final? t
                             :transient? nil
                             :volatile? nil
                             :type type
                             :name name
                             :init? expr))
           (meth (change-jmethod
                      meth
                      :body (list (jstatem-return (jexpr-name name))))))
        (list* (jcbody-element-member (jcmember-field fld))
               (jcbody-element-member (jcmember-method meth))
               (atj-cache-const-methods (cdr elems))))))

    Theorem: jcbody-element-listp-of-atj-cache-const-methods

    (defthm jcbody-element-listp-of-atj-cache-const-methods
      (b* ((new-elems (atj-cache-const-methods elems)))
        (jcbody-element-listp new-elems))
      :rule-classes :rewrite)