package wax-lib

All checked builds pass
  1. Overview
  2. Docs
Libraries for Wax, a Rust-like syntax for WebAssembly

Install

dune-project
 Dependency

Authors

Maintainers

Sources

wax-v0.3.0.tbz
sha256=cc19989d0db930d9300d7356c8f127309424a82767dd3c91ffd19a0bfd20e3a6
sha512=14ff9219dc6c4e8855c3cb895bd1af6fd81d1c521afefe1e7f69208a2e37abc7ec0946f188198a26780aa405fd43a526b938158334a019f7a5d991d8efc437c3

doc/wax-lib.utils/Wax_utils/Source_map/index.html

Module Wax_utils.Source_mapSource

Sourcetype t
Sourcetype mapping = {
  1. generated_offset : int;
  2. original_file_idx : int;
  3. original_line : int;
  4. original_column : int;
}
Sourceval create : enabled:bool -> t

create ~enabled:false returns a sink whose recording functions are no-ops, so a module writer that never serializes a map does not pay for accumulating one entry per instruction.

Sourceval register_file : t -> string -> int
Sourceval add_mapping : t -> generated_offset:int -> original_location:Ast.location -> unit

Map generated_offset to the start of original_location.

Sourceval add_mapping_at : t -> generated_offset:int -> position:Lexing.position -> unit

Map generated_offset to a specific source position — used to attach the closing end opcode of a block or expression to its end position.

Sourceval add_absent_mapping : t -> generated_offset:int -> unit

add_absent_mapping t ~generated_offset records that the code at generated_offset has no original location, emitting a segment that resets the mapping so the previous location does not bleed into it.

Sourcetype checkpoint
Sourceval checkpoint : t -> checkpoint

checkpoint t captures the set of mappings recorded so far, for a later shift_since. Mappings are recorded with generated offsets relative to whichever buffer is being encoded; a checkpoint plus shift_since rebases the ones added afterwards once their absolute file offset is known.

Sourceval shift_since : t -> checkpoint -> delta:int -> unit

shift_since t cp ~delta adds delta to the generated offset of every mapping recorded since the checkpoint cp.

Sourceval to_json : t -> file_name:string -> string