package wax-lib

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module Wax_lang.Typing_envSource

The naming/context layer shared by the type checker and its extracted passes (Typing_lint, Typing_suggest): the typed-tree annotation types, the resolved-reference and member-completion sinks, the name tables (Namespace / Tbl), the type and module contexts, the error-free accessor variants the lint/suggest code reads through, and the source-slice utilities the quick fixes build edits from. Its concrete types are re-exported by Typing through type equations, so external consumers keep seeing them as Wax_lang.Typing.reference etc.

Sourcetype typed_module_annotation = Ast.storagetype option array * Ast.location

The resolved per-node annotation of the typed tree: the storage types a node leaves on the stack, plus its span.

Sourcetype inferred_module_annotation = Infer.inferred_type Infer.Cell.t array * Ast.location

As typed_module_annotation, but before the inference cells are resolved to storage types — the form the editor reads.

Sourcetype hover_target =
  1. | Value_type of Infer.inferred_valtype
  2. | Type_def of Ast.subtype
    (*

    What a resolved reference summarises for a hover on a name that is not itself an expression: a variable's type, or a referenced type's definition.

    *)
Sourcetype reference = {
  1. use : Ast.location;
  2. definitions : Ast.location list;
  3. hover : hover_target option;
}

A resolved name/label reference: a use span, the definition span(s) it binds to (several only under conditional compilation), and an optional hover summary.

Sourcetype resolve_sink = reference list ref option

Where name/label references are accumulated for the editor; None disables recording (an ordinary compile).

Sourceval is_source : Ast.location -> bool

Whether a location is a genuine source span (not a synthesized node's Ast.dummy_loc).

Sourceval same_span : Ast.location -> Ast.location -> bool

Whether two locations cover the same byte range.

Sourceval expression_type_opt : ('b array * 'c) Ast.instr -> 'b option

The single inference cell an instruction leaves on the stack, or None if it is not a one-value expression. The error-free counterpart of the typer's expression_type: a lint/suggest site reads it silently and skips otherwise, never emitting the duplicate diagnostic the typer already owns.

Sourceval ref_none_valtype : nullable:bool -> Infer.inferred_valtype

The precomputed value type &?none / &none (the nullable / non-nullable bottom reference), built without a type context.

The concrete value type an inference cell stands for on its own, or None when it has none yet. Pure and context-free (its only reference result is the built-in None_ bottom); the typer's ctx-threading standalone_valtype delegates here.

Sourceval record_pun : Ast.location list ref option -> Ast.location -> unit

Record a punned struct-literal field's span, for the editor's rename.

Sourceval record_members : (Ast.location * Members.member_receiver) list ref option -> Ast.location -> Members.member_receiver -> unit

Record, at a struct field access, the field's span and the receiver it is on, for member completion.

Sourceval record_reference : ?hover:hover_target option -> resolve_sink -> Ast.location -> Ast.location list -> unit

Record a use -> definition(s) reference (dropping synthesized and self-referential definitions).

Sourcemodule StringSet : Set.S with type elt = string
Sourcemodule IntSet : Set.S with type elt = int
Sourcemodule StringMap : Map.S with type key = string
Sourceval (let*@) : 'a option -> ('a -> 'b option) -> 'b option
Sourceval (let+@) : 'a option -> ('a -> 'b) -> 'b option
Sourceval (let>@) : 'a option -> ('a -> unit) -> unit

The option let-operators: bind through Some / map the payload / run an effect only when Some.

Sourcemodule Namespace : sig ... end

A name table holding one binding per name: a run of the typer is one configuration, so a branch it does not select registers nothing. Only the type is exposed here; the operations live in Typing's Namespace (they emit diagnostics through its Error).

Sourcetype origin =
  1. | Root
    (*

    a module-level context: an initializer, a segment, an import

    *)
  2. | From_function of string
  3. | From_type of string
    (*

    a type definition's own components

    *)
  4. | Ignored
    (*

    not a source reference; do not record

    *)

A name-keyed table layered over a Namespace, tracking references (for the unused lints) and an optional hover summary. Only the type is exposed here; the operations live in Typing's Tbl.

Where a name resolution is made from, for the reachability analysis behind the unused-field warning.

Sourcemodule Tbl : sig ... end

The module's type table: each name to its interned index and subtype.

Sourcetype type_context = {
  1. internal_types : Wax_wasm.Types.t;
  2. types : (Wax_wasm.Types.ref_index * Ast.subtype) Tbl.t;
  3. features : Wax_utils.Feature.set;
  4. mutable subtyping_info_cache : Wax_wasm.Types.subtyping_info option;
}

The module-wide type space and its memoised subtyping info (see the field comments in typing_env.ml).

Sourcetype missing_batch = {
  1. mutable hole_reported : bool;
  2. hole_actual : int;
  3. hole_expected : int;
}
Sourcetype module_context = {
  1. diagnostics : Wax_utils.Diagnostic.context;
  2. warn_unused : bool;
  3. simplify : bool;
  4. suggest : bool;
  5. select : Ast.location -> bool;
  6. faithful : bool;
  7. type_context : type_context;
  8. types : (Wax_wasm.Types.ref_index * Ast.subtype) Tbl.t;
  9. functions : (Wax_wasm.Types.Id.t * string * bool) option Tbl.t;
  10. globals : (bool * Infer.inferred_valtype option) Tbl.t;
  11. import_globals : (bool * Infer.inferred_valtype option) Tbl.t;
  12. assigned_globals : (string, unit) Hashtbl.t;
  13. cast_traps_reported : (int * int, unit) Hashtbl.t;
  14. canonical_type_references : (origin * Wax_wasm.Types.Id.t) list ref;
  15. origin : origin ref;
  16. tags : Ast.functype Tbl.t;
  17. memories : (int * [ `I32 | `I64 ]) Tbl.t;
  18. datas : unit Tbl.t;
  19. tables : ([ `I32 | `I64 ] * Ast.reftype) Tbl.t;
  20. elems : Ast.reftype Tbl.t;
  21. structs_by_fields : (string, Ast.ident option) Hashtbl.t;
  22. not_expression_reported : (int * int, unit) Hashtbl.t;
  23. mutable locals : (Infer.inferred_valtype option * Ast.location) StringMap.t;
  24. mutable initialized_locals : StringSet.t;
  25. mutable deferred_uninit : Ast.ident list ref list;
  26. missing_holes : (Infer.inferred_type Infer.Cell.t * missing_batch) list ref;
  27. unresolved_label : bool ref;
  28. read_locals : IntSet.t ref;
  29. local_decls : Ast.ident list ref;
  30. used_labels : IntSet.t ref;
  31. deferred_lints : (unit -> unit) list ref;
  32. label_decls : Ast.ident list;
  33. assigned_locals : StringSet.t;
  34. control_types : (Ast.label option * Infer.inferred_type Infer.Cell.t array) list;
  35. return_types : Infer.inferred_type Infer.Cell.t array;
  36. pun_spans : Ast.location list ref option;
  37. member_completions : (Ast.location * Members.member_receiver) list ref option;
}

The per-module type-checking context: diagnostics and run configuration, the module-wide type and name tables, the per-function state (reset on entry to each function), the run's branch selection, and the editor sinks. See the field comments in typing_env.ml.

Sourceval source_slice : module_context -> Ast.location -> string option

The source text a location spans, or None when unavailable / out of range.

The location running from one position to another.

A machine-applicable edit that removes the given span.

Sourceval blank_comments : string -> string

s with every comment blanked to spaces (newlines kept), so a delimiter inside a comment is never mistaken for real syntax by the source-scanning suggestions.