Skip to content

Commit

Permalink
Add support of implicit second return value for div. Close #212
Browse files Browse the repository at this point in the history
  • Loading branch information
ryukzak committed Jan 21, 2024
1 parent 0603636 commit 5e5d467
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/NITTA/Frontends/Lua.hs
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,7 @@ alg2graph LuaAlgBuilder{algGraph, algLatestLuaValueInstance, algVars} = flip exe
function2nitta LuaStatement{fName = "add", fIn = [a, b], fOut = [c], fValues = [], fInt = []} = F.add (fromText a) (fromText b) $ output c
function2nitta LuaStatement{fName = "sub", fIn = [a, b], fOut = [c], fValues = [], fInt = []} = F.sub (fromText a) (fromText b) $ output c
function2nitta LuaStatement{fName = "multiply", fIn = [a, b], fOut = [c], fValues = [], fInt = []} = F.multiply (fromText a) (fromText b) $ output c
function2nitta LuaStatement{fName = "divide", fIn = [d, n], fOut = [q], fValues = [], fInt = []} = F.division (fromText d) (fromText n) (output q) []
function2nitta LuaStatement{fName = "divide", fIn = [d, n], fOut = [q, r], fValues = [], fInt = []} = F.division (fromText d) (fromText n) (output q) (output r)
function2nitta LuaStatement{fName = "neg", fIn = [i], fOut = [o], fValues = [], fInt = []} = F.neg (fromText i) $ output o
function2nitta LuaStatement{fName = "receive", fIn = [], fOut = [o], fValues = [], fInt = []} = F.receive $ output o
Expand Down
11 changes: 10 additions & 1 deletion test/NITTA/Model/ProcessorUnits/Divider/Tests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,23 @@ tests =
[ division "a" "b" ["c"] ["d"]
]
, luaTestCase
"one division"
"one division explicit"
[__i|
function f(a)
a, _b = a / 2
f(a)
end
f(1024)
|]
, luaTestCase
"one division implicit"
[__i|
function f(a)
a = a / 2
f(a)
end
f(1024)
|]
, luaTestCase
"two division"
[__i|
Expand Down

0 comments on commit 5e5d467

Please sign in to comment.