• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
    • Hardware-verification
    • Software-verification
      • Kestrel-books
        • Crypto-hdwallet
        • Apt
        • Error-checking
        • Fty-extensions
        • Isar
        • Kestrel-utilities
        • Set
        • Soft
        • C
          • Syntax-for-tools
          • Atc
          • Language
          • Representation
          • Transformation-tools
            • Simpadd0
            • Deftrans
            • Splitgso
            • Constant-propagation
              • Value-to-expr
                • Const-prop-eval-impure-binop-expr
                • Env
                • Const-prop-eval-pure-binop-expr
                • Const-prop-filepath-transunit-map
                • Const-prop-eval-unop-expr
                • Const-prop-transunit-ensemble
                • Const-prop-fundef
                • Value-result-to-option
                • Const-prop-extdecl-list
                • Const-prop-extdecl
                • Zero-valuep
                • Iconst-to-value
                • Const-to-value
                • Expr-to-ident
                • Const-prop-transunit
                • Pure-binopp
                • Const-prop-initdeclor-list
                • Const-prop-initdeclor
                • Const-prop-structdeclor-list
                • Const-prop-structdecl-list
                • Const-prop-param-declon-list
                • Const-prop-initer-option
                • Const-prop-initer
                • Const-prop-expr-option
                • Const-prop-dirabsdeclor-option
                • Const-prop-dirabsdeclor
                • Const-prop-const-expr-option
                • Const-prop-absdeclor-option
                • Const-prop-type-spec
                • Const-prop-strunispec
                • Const-prop-structdeclor
                • Const-prop-structdecl
                • Const-prop-statassert
                • Const-prop-spec/qual-list
                • Const-prop-spec/qual
                • Const-prop-param-declor
                • Const-prop-param-declon
                • Const-prop-member-designor
                • Const-prop-genassoc-list
                • Const-prop-genassoc
                • Const-prop-expr-list
                • Const-prop-expr
                • Const-prop-enumspec
                • Const-prop-enumer-list
                • Const-prop-dirdeclor
                • Const-prop-desiniter-list
                • Const-prop-desiniter
                • Const-prop-designor-list
                • Const-prop-designor
                • Const-prop-declor-option
                • Const-prop-decl-spec-list
                • Const-prop-decl-spec
                • Const-prop-decl-list
                • Const-prop-block-item-list
                • Const-prop-align-spec
                • Const-prop-absdeclor
                • Const-prop-tyname
                • Const-prop-stmt
                • Const-prop-label
                • Const-prop-enumer
                • Const-prop-declor
                • Const-prop-decl
                • Const-prop-const-expr
                • Const-prop-block-item
              • Split-fn
              • Copy-fn
              • Specialize
              • Split-all-gso
              • Rename
              • Utilities
            • Insertion-sort
            • Pack
          • Bv
          • Imp-language
          • Event-macros
          • Java
          • 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
    • Constant-propagation

    Value-to-expr

    Convert a c::value to an c$::expr.

    Signature
    (value-to-expr value) → expr
    Arguments
    value — Guard (c::valuep value).
    Returns
    expr — Type (exprp expr).

    Definitions and Theorems

    Function: value-to-expr

    (defun value-to-expr (value)
     (declare (xargs :guard (c::valuep value)))
     (let ((__function__ 'value-to-expr))
      (declare (ignorable __function__))
      (c::value-case
       value :uchar
       (expr-const
            (c$::const-int
                 (c$::make-iconst
                      :core
                      (if (zp value.get)
                          (dec/oct/hex-const-oct 1 0)
                        (c$::dec/oct/hex-const-dec value.get))
                      :suffix? (c$::isuffix-u (c$::usuffix-locase-u)))))
       :schar
       (if
        (minusp value.get)
        (make-expr-unary
         :op (c::unop-minus)
         :arg
         (expr-const
            (c$::const-int
                 (c$::make-iconst
                      :core (c$::dec/oct/hex-const-dec (- value.get)))))
         :info nil)
        (expr-const
         (c$::const-int
           (c$::make-iconst :core
                            (if (zp value.get)
                                (dec/oct/hex-const-oct 1 0)
                              (c$::dec/oct/hex-const-dec value.get))))))
       :ushort
       (expr-const
            (c$::const-int
                 (c$::make-iconst
                      :core
                      (if (zp value.get)
                          (dec/oct/hex-const-oct 1 0)
                        (c$::dec/oct/hex-const-dec value.get))
                      :suffix? (c$::isuffix-u (c$::usuffix-locase-u)))))
       :sshort
       (if
        (minusp value.get)
        (make-expr-unary
         :op (c::unop-minus)
         :arg
         (expr-const
            (c$::const-int
                 (c$::make-iconst
                      :core (c$::dec/oct/hex-const-dec (- value.get)))))
         :info nil)
        (expr-const
         (c$::const-int
           (c$::make-iconst :core
                            (if (zp value.get)
                                (dec/oct/hex-const-oct 1 0)
                              (c$::dec/oct/hex-const-dec value.get))))))
       :uint
       (expr-const
            (c$::const-int
                 (c$::make-iconst
                      :core
                      (if (zp value.get)
                          (dec/oct/hex-const-oct 1 0)
                        (c$::dec/oct/hex-const-dec value.get))
                      :suffix? (c$::isuffix-u (c$::usuffix-locase-u)))))
       :sint
       (if
        (minusp value.get)
        (make-expr-unary
         :op (c::unop-minus)
         :arg
         (expr-const
            (c$::const-int
                 (c$::make-iconst
                      :core (c$::dec/oct/hex-const-dec (- value.get)))))
         :info nil)
        (expr-const
         (c$::const-int
           (c$::make-iconst :core
                            (if (zp value.get)
                                (dec/oct/hex-const-oct 1 0)
                              (c$::dec/oct/hex-const-dec value.get))))))
       :ulong
       (expr-const
           (c$::const-int
                (c$::make-iconst
                     :core
                     (if (zp value.get)
                         (dec/oct/hex-const-oct 1 0)
                       (c$::dec/oct/hex-const-dec value.get))
                     :suffix? (c$::isuffix-ul (c$::usuffix-locase-u)
                                              (c$::lsuffix-locase-l)))))
       :slong
       (if
        (minusp value.get)
        (make-expr-unary
         :op (c::unop-minus)
         :arg
         (expr-const
            (c$::const-int
                 (c$::make-iconst
                      :core (c$::dec/oct/hex-const-dec (- value.get))
                      :suffix? (c$::isuffix-l (c$::lsuffix-locase-l)))))
         :info nil)
        (expr-const
           (c$::const-int
                (c$::make-iconst
                     :core
                     (if (zp value.get)
                         (dec/oct/hex-const-oct 1 0)
                       (c$::dec/oct/hex-const-dec value.get))
                     :suffix? (c$::isuffix-l (c$::lsuffix-locase-l))))))
       :ullong
       (expr-const
          (c$::const-int
               (c$::make-iconst
                    :core
                    (if (zp value.get)
                        (dec/oct/hex-const-oct 1 0)
                      (c$::dec/oct/hex-const-dec value.get))
                    :suffix? (c$::isuffix-ul (c$::usuffix-locase-u)
                                             (c$::lsuffix-locase-ll)))))
       :sllong
       (if
        (minusp value.get)
        (make-expr-unary
         :op (c::unop-minus)
         :arg
         (expr-const
           (c$::const-int
                (c$::make-iconst
                     :core (c$::dec/oct/hex-const-dec (- value.get))
                     :suffix? (c$::isuffix-l (c$::lsuffix-locase-ll)))))
         :info nil)
        (expr-const
          (c$::const-int
               (c$::make-iconst
                    :core
                    (if (zp value.get)
                        (dec/oct/hex-const-oct 1 0)
                      (c$::dec/oct/hex-const-dec value.get))
                    :suffix? (c$::isuffix-l (c$::lsuffix-locase-ll))))))
       :pointer (prog2$ (raise "TODO: pointer case not yet implemented")
                        (irr-expr))
       :array (prog2$ (raise "TODO: array case not yet implemented")
                      (irr-expr))
       :struct (prog2$ (raise "TODO: struct case not yet implemented")
                       (irr-expr)))))

    Theorem: exprp-of-value-to-expr

    (defthm exprp-of-value-to-expr
      (b* ((expr (value-to-expr value)))
        (exprp expr))
      :rule-classes :rewrite)