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/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)