package wax-lib
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=4361e1324b7754a4c08ab5b505df32061f3ce0cea60443fd0d3699e0fa796b32
sha512=fcc756d2f160ba90a9aa1131f2ab22ed7f45466ccd658c21cf9df6868a6aab0cee7f404719d698a379958802f9820398f2fe0685ecc4dda018ca4f653294e39b
doc/wax-lib.wax/Wax_lang/Typing_lint/index.html
Module Wax_lang.Typing_lintSource
Pure AST analysis helpers and the source-walking lint checks. The analysis primitives (value-effect classification, hole counting, the per-function collection passes) are shared with the type checker; the lint checks (constant conditions, shift/division/conversion traps, tautologies, redundant arithmetic, eager ?:, operator precedence) run once over the source AST and emit warnings. The warning-emitting Error submodule is internal.
Whether a no-/one-argument numeric instruction method (x.abs(), x.min(y)) is pure and total.
Whether a cast never traps, so discarding its result is pointless.
Whether evaluating an expression has no side effect and cannot trap.
val collect_assigned_locals :
Typing_env.StringSet.t ->
'a Ast.instr ->
Typing_env.StringSet.tAccumulate the local names assigned (Set/Tee targets) anywhere in an instruction.
Accumulate the block labels declared anywhere in an instruction.
The location of a trapping/effectful operation on the eagerly-evaluated spine of a ?: branch, or None if the branch is pure.
Constant-integer-operand parsing/matching for the lints. The operand forms look through a leading sign, matching how Wax_conversion.To_wasm folds it into the emitted iNN.const.
val lint_shift :
Typing_env.module_context ->
(Ast.binop, Ast.location) Ast.annotated ->
Infer.inferred_type Infer.Cell.t ->
'a Ast.instr ->
unitFlag a shift whose constant count is at least the operand's bit width. Deferred until the result cell's width is pinned.
Run and clear the lints deferred until their result cells were pinned.
val lint_division :
Typing_env.module_context ->
(Ast.binop, Ast.location) Ast.annotated ->
'a Ast.instr ->
unitFlag an integer / or % by a constant zero (always traps).
Constant-float-operand parsing and the trapping-conversion predicate for lint_conversion.
val lint_conversion :
Typing_env.module_context ->
location:Ast.location ->
Ast.casttype ->
'a Ast.instr ->
unitFlag a strict float-to-integer conversion of a constant out of range.
Whether two operands are the same pure read (a local/global get).
val lint_comparison :
Typing_env.module_context ->
(Ast.binop, Ast.location) Ast.annotated ->
(Infer.inferred_type Infer.Cell.t array * 'a) Ast.instr ->
'b Ast.instr ->
unitFlag a comparison whose result is constant regardless of its operand.
val lint_redundant :
Typing_env.module_context ->
(Ast.binop, Ast.location) Ast.annotated ->
(Infer.inferred_type Infer.Cell.t array * 'a) Ast.instr ->
(Infer.inferred_type Infer.Cell.t array * 'a) Ast.instr ->
unitFlag an arithmetic operation with no effect or a constant result (off by default).
val lint_redundant_unop :
Typing_env.module_context ->
(Ast.unop, Ast.location) Ast.annotated ->
(Infer.inferred_type Infer.Cell.t array * 'a) Ast.instr ->
unitAs lint_redundant for a unary operation: -e lowers to 0 - e, so a zero operand is the x - 0 identity the Wasm validator reports on the lowered form.
val lint_condition :
Typing_env.module_context ->
?is_while:bool ->
Ast.location Ast.instr ->
unitFlag a branch/loop/select condition that is a constant literal.
val lint_eager_select :
Typing_env.module_context ->
select:Ast.location ->
Ast.location Ast.instr ->
unitReport an eager-evaluation hazard in a ?: branch.
Human-readable name of a binary operator's precedence class.
val operand_parenthesized :
Typing_env.module_context ->
op:(Ast.binop, Ast.location) Ast.annotated ->
side:[< `Left | `Right ] ->
Ast.location Ast.instr ->
boolWhether a binary operator's operand was written parenthesized (from the source text).
val lint_precedence :
Typing_env.module_context ->
(Ast.binop, Ast.location) Ast.annotated ->
Ast.location Ast.instr ->
Ast.location Ast.instr ->
unitFlag a confusing precedence mix written without disambiguating parentheses.
Walk the source AST and report the purely-syntactic lints (constant conditions, eager ?:, precedence, redundant self-assignment, a pointless drop). The orchestrator that dispatches to the checks above.