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.3.0.tbz
sha256=cc19989d0db930d9300d7356c8f127309424a82767dd3c91ffd19a0bfd20e3a6
sha512=14ff9219dc6c4e8855c3cb895bd1af6fd81d1c521afefe1e7f69208a2e37abc7ec0946f188198a26780aa405fd43a526b938158334a019f7a5d991d8efc437c3

doc/src/wax-lib.conversion/naming.ml.html

Source file naming.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
open Wax_wasm.Ast

(* [Func] carries an inline record, so each field is rebound and the record
   reconstructed explicitly (an inline record cannot be captured with [as]). *)
let rec map_fields fields =
  List.map
    (fun field ->
      match field.desc with
      | Text.Func { id = None; typ; locals; instrs; exports; priority }
        when match exports with
             | export :: _ -> Wax_wasm.Lexer.is_valid_identifier export.desc
             | [] -> false ->
          let export = List.hd exports in
          {
            field with
            desc =
              Text.Func
                { id = Some export; typ; locals; instrs; exports; priority };
          }
      | Text.Module_if_annotation { cond; then_fields; else_fields } ->
          {
            field with
            desc =
              Text.Module_if_annotation
                {
                  cond;
                  then_fields =
                    { then_fields with desc = map_fields then_fields.desc };
                  else_fields =
                    Option.map
                      (fun e -> { e with desc = map_fields e.desc })
                      else_fields;
                };
          }
      | _ -> field)
    fields

let name_functions_from_exports (name, fields) = (name, map_fields fields)