• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
      • Apt
      • Zfc
      • Acre
      • Milawa
      • Smtlink
      • Abnf
      • Vwsim
      • Isar
      • Wp-gen
      • Dimacs-reader
      • Pfcs
      • Legacy-defrstobj
      • Proof-checker-array
      • Soft
      • C
      • Farray
      • Rp-rewriter
      • Instant-runoff-voting
      • Imp-language
      • Sidekick
      • Leftist-trees
      • Java
      • Riscv
      • Taspi
      • Bitcoin
      • Des
      • Ethereum
      • X86isa
      • Sha-2
      • Yul
      • Zcash
      • Proof-checker-itp13
      • Regex
      • ACL2-programming-language
      • Json
      • Jfkr
      • Equational
      • Cryptography
      • Poseidon
      • Where-do-i-place-my-book
      • Axe
      • Aleo
        • Aleobft
        • Aleovm
        • Leo
          • Grammar
          • Early-version
            • Json2ast
            • Testing
            • Definition
              • Flattening
              • Abstract-syntax
              • Dynamic-semantics
                • Execution
                  • Exec-expressions/statements
                  • Init-for-loop
                  • Exec-file-main
                  • Update-variable-value-in-scope-list
                  • Step-for-loop
                  • Update-variable-value-in-scope
                  • Expr-value-to-value
                  • Exec-binary
                  • Exec-expression
                    • Init-vcscope-dinfo-call
                    • Value?+denv
                    • Exec-statement
                    • End-of-for-loop-p
                    • Expr-value
                    • Evalue+denv
                    • Write-location
                    • Read-location
                    • Exec-for-loop-iterations
                    • Update-variable-value
                    • Exec-unary
                    • Values+denv
                    • Init-vcscope-dinfo-loop
                    • Extend-denv-with-structdecl
                    • Exec-var/const
                    • Valuemap+denv
                    • Namevalue+denv
                    • Extend-denv-with-fundecl
                    • Ensure-boolean
                    • Int+denv
                    • Push-vcscope-dinfo
                    • Extend-denv-with-topdecl-list
                    • Exec-literal
                    • Build-denv-from-file
                    • Namevalue+denv-result
                    • Extend-denv-with-topdecl
                    • Evalue+denv-result
                    • Value?+denv-result
                    • Values+denv-result
                    • Valuemap+denv-result
                    • Int+denv-result
                    • Push-call-dinfo
                    • Exec-print
                    • Pop-vcscope-dinfo
                    • Exec-if
                    • Exec-function
                    • Pop-call-dinfo
                    • Exec-statement-list
                    • Exec-block
                    • Exec-struct-init-list
                    • Exec-struct-init
                    • Exec-expression-list
                  • Values
                  • Dynamic-environments
                  • Arithmetic-operations
                  • Curve-parameterization
                  • Shift-operations
                  • Errors
                  • Value-expressions
                  • Locations
                  • Input-execution
                  • Edwards-bls12-generator
                  • Equality-operations
                  • Logical-operations
                  • Program-execution
                  • Ordering-operations
                  • Bitwise-operations
                  • Literal-evaluation
                  • Type-maps-for-struct-components
                  • Output-execution
                  • Tuple-operations
                  • Struct-operations
                • Compilation
                • Static-semantics
                • Concrete-syntax
        • Bigmems
        • Builtins
        • Execloader
        • Solidity
        • Paco
        • Concurrent-programs
        • Bls12-377-curves
      • Debugging
      • Community
      • Std
      • Proof-automation
      • Macro-libraries
      • ACL2
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Math
      • Testing-utilities
    • Execution
    • Exec-expressions/statements

    Exec-expression

    Execute an expression.

    Signature
    (exec-expression expr env limit) → evalue+denv
    Arguments
    expr — Guard (expressionp expr).
    env — Guard (denvp env).
    limit — Guard (natp limit).
    Returns
    evalue+denv — Type (evalue+denv-resultp evalue+denv).

    We use separate ACL2 functions for variables and constants, and for literals.

    For unary and binary expressions, first we execute the operand(s). For binary expressions, we execute them from left to right, threading through the environment. We propagate errors from the operand(s). We use separate ACL2 functions to calculate the final result.

    For a conditional expression, we first execute the test, which must return a boolean. If the boolean is true, we execute the `then' branch; if the boolean is false, we execute the `else' branch.

    For a tuple expression, we first evaluate the sub-expressions, then put them together into a tuple value.

    For a tuple component expression, we first evaluate the sub-expression. If the result is a location, we return a location for the component. If the result is a value, we ensure that it is a tuple value, and we return the component value (if the index is in range).

    For a struct expression, we evaluate its components, and we create a struct value from them.

    For a struct component expression, we first evaluate the sub-expression. If the result is a location, we return a location for the component. If the result is a value, we ensure that it is a struct value, and we return the component value (if the component is among the declared ones for the struct type).

    For a fucntion call, we first evaluate the argument expressions. Then we call a separate ACL2 function to handle the call.