package wax-lib
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=41b580846af8d41bdf6c3f005f62e38feda3e60fe2e9e4aa440db34ce515a153
sha512=4b3a181fcc7d743194a8647260870fb5190770066a197bcc48104c2b77fd40c643228b795c2bcd6b29a120820e969eb42a37a9bcec98b3f608d13f152d9f6579
doc/wax-lib.wasm/Wax_wasm/Cond_specialize/index.html
Module Wax_wasm.Cond_specializeSource
Specialization of conditional annotations against user-supplied variable bindings (the -D/--define CLI option).
Conditional annotations (@if <cond> ...) are normally preserved verbatim (see Cond_solver for their path-sensitive validation). Given values for some condition variables, this module partially evaluates the conditions:
- a conditional whose condition becomes fully determined is removed, splicing the surviving branch into the enclosing position;
- a conditional that still mentions unset variables is kept, with its condition simplified (the known variables substituted and the result constant-folded).
A mapping from condition-variable names to values.
parse_define s parses one -D/--define argument, either "name" or "name=value". A bare name binds a boolean true. Otherwise the value kind is inferred: "true"/"false" is a boolean, N.N.N (three non-negative integers) a version, and anything else a string. Returns Error msg on a malformed argument (an empty variable name).
Build bindings from name/value pairs. On a duplicate name, the last entry wins.
eval ctx env c partially evaluates c under env. Unbound variables are left in the residual; bound ones are substituted and the condition is constant-folded. Reports an error diagnostic (and leaves the offending sub-condition residual) when a variable is set to a value of a kind incompatible with how the condition uses it.
val module_ :
Wax_utils.Diagnostic.context ->
bindings ->
Ast.location Ast.Text.module_ ->
Ast.location Ast.Text.module_ * (int * int) listSplice out and simplify every conditional annotation in a WAT module according to eval. Returns the specialized module and the half-open byte ranges of the branches that were removed, for dropping their comments (see Wax_utils.Trivia.drop_in_ranges). With empty bindings this is the identity (no conditional is determined, so all are kept unchanged) and no range is produced.