package wax-lib

  1. Overview
  2. Docs
Libraries for Wax, a Rust-like syntax for WebAssembly

Install

dune-project
 Dependency

Authors

Maintainers

Sources

wax-v0.2.0.tbz
sha256=4361e1324b7754a4c08ab5b505df32061f3ce0cea60443fd0d3699e0fa796b32
sha512=fcc756d2f160ba90a9aa1131f2ab22ed7f45466ccd658c21cf9df6868a6aab0cee7f404719d698a379958802f9820398f2fe0685ecc4dda018ca4f653294e39b

doc/wax-lib.wasm/Wax_wasm/Types/index.html

Module Wax_wasm.TypesSource

Type handling for Wasm.

Sourcemodule Id : sig ... end
Sourcemodule Internal : sig ... end

The internal (resolved) type representation: type references carry the abstract Id.t rather than the wire format's int. This is what the type store and validation reason about; the codec stays on Ast.Binary.

Sourcetype ref_index =
  1. | Def of Id.t
  2. | Rec of int
    (*

    A reference inside a rec group being registered (Normalized): Def id denotes an already-defined type by its canonical index, while Rec pos denotes the group's own pos-th member. Making the intra-group back-reference a constructor — rather than a canonical index and a negative sign bit sharing one integer space — means the two cannot be confused, and an Id.t is only ever a genuine store index.

    *)
Sourcemodule Normalized : sig ... end

The normalized form fed to add_rectype: like Internal, but references are ref_index so a rec group's own members are named relatively (by position) and the group dedups regardless of where it lands. A caller resolving a source rec group builds this directly.

Sourcetype t

A type context holding recursive type definitions.

Sourceval create : unit -> t

create () creates a new empty type context.

Sourceval add_rectype : t -> Normalized.rectype -> Id.t

Add a recursive type definition to the context. Returns the canonical index of the first type defined. Raises Invalid_argument if the group is not well-formed (a Rec back-reference out of range, or a Def referring to a type not yet defined).

Sourceval last_index : t -> int

last_index context returns the index that the next freshly-added type would receive (i.e. the number of types currently defined).

Sourcetype subtyping_info

Information needed for subtyping checks.

Sourceval subtyping_info : t -> subtyping_info

subtyping_info context extracts subtyping information from the context.

get_subtype info index returns the subtype at the given canonical index.

Sourceval get_all_rectypes : t -> Internal.rectype list

Returns all recursive type definitions from the context.

heap_subtype info ht1 ht2 checks if ht1 is a subtype of ht2.

ref_subtype info rt1 rt2 checks if rt1 is a subtype of rt2.

val_subtype info vt1 vt2 checks if vt1 is a subtype of vt2.