Skip to content

Commit bdb2428

Browse files
committed
better tuple.make
1 parent 96985b5 commit bdb2428

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

wasm/wat.ml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,9 @@ module C = struct
254254
| Rvar v -> reft v
255255
| Tuple l -> node "" (List.map type_atom l)
256256

257+
258+
let tuple_make fields = node "tuple.make" (Atom (List.length fields |> string_of_int) :: fields )
259+
257260
let local l t = node "local" [ !$(Expr.Local.var_name l); type_atom t ]
258261

259262
let param p t = node "param" [ !$(Param.name p); type_atom t ]
@@ -311,12 +314,12 @@ module C = struct
311314
nodehv "loop" [ !$(Block_id.name id); results result ] body
312315

313316
let br id args =
314-
node "br" [ !$(Block_id.name id); node (Format.sprintf "tuple.make %d" (List.length args)) args ]
317+
node "br" [ !$(Block_id.name id); tuple_make args ]
315318

316319
let br' id = node "br" [ !$(Block_id.name id) ]
317320

318321
let return args =
319-
node "return" [ node (Format.sprintf "tuple.make %d" (List.length args)) args ]
322+
node "return" [ tuple_make args ]
320323

321324
let br_on_cast id typ arg =
322325
node "br_on_cast" [ !$(Block_id.name id); type_name typ; arg ]
@@ -347,9 +350,7 @@ module C = struct
347350
node "sub" [ type_name name; descr ]
348351

349352
let opt_tuple fields =
350-
[ node (Format.sprintf "tuple.make %d" (List.length fields)) fields ]
351-
352-
let tuple_make fields = node (Format.sprintf "tuple.make %d" (List.length fields)) fields
353+
[ tuple_make fields ]
353354

354355
let tuple_extract field tuple = node "tuple.extract" [ int field; tuple ]
355356

0 commit comments

Comments
 (0)