package wax-lib

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

Install

dune-project
 Dependency

Authors

Maintainers

Sources

wax-0.1.0.tbz
sha256=41b580846af8d41bdf6c3f005f62e38feda3e60fe2e9e4aa440db34ce515a153
sha512=4b3a181fcc7d743194a8647260870fb5190770066a197bcc48104c2b77fd40c643228b795c2bcd6b29a120820e969eb42a37a9bcec98b3f608d13f152d9f6579

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.