Skip to content

Commit

Permalink
Lua backend: Eliminate table_unpackN(table_pack(...))
Browse files Browse the repository at this point in the history
  • Loading branch information
minoki committed Sep 12, 2024
1 parent 9b0b0fc commit 07a42ac
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/codegen-lua.sml
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,9 @@ struct
, L.ConstExp (L.Numeral "1")
, L.IndexExp (x, L.ConstExp (L.LiteralString "n"))
])
| TableUnpackN (x as L.CallExp (L.VarExp (L.PredefinedId "table_pack"), a)) =
if Vector.length a = 1 then Vector.sub (a, 0)
else L.CallExp (L.VarExp (L.PredefinedId "table_unpackN"), vector [x])
| TableUnpackN x =
L.CallExp (L.VarExp (L.PredefinedId "table_unpackN"), vector [x])

Expand Down

0 comments on commit 07a42ac

Please sign in to comment.