From 5e5d467e0467d01e6bd340b0871895c771811280 Mon Sep 17 00:00:00 2001 From: Aleksandr Penskoi Date: Sun, 21 Jan 2024 15:07:27 +0100 Subject: [PATCH] Add support of implicit second return value for div. Close #212 --- src/NITTA/Frontends/Lua.hs | 1 + test/NITTA/Model/ProcessorUnits/Divider/Tests.hs | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/NITTA/Frontends/Lua.hs b/src/NITTA/Frontends/Lua.hs index a6c6245a0..d416fb03a 100644 --- a/src/NITTA/Frontends/Lua.hs +++ b/src/NITTA/Frontends/Lua.hs @@ -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 diff --git a/test/NITTA/Model/ProcessorUnits/Divider/Tests.hs b/test/NITTA/Model/ProcessorUnits/Divider/Tests.hs index 7d09ae603..3828a317b 100644 --- a/test/NITTA/Model/ProcessorUnits/Divider/Tests.hs +++ b/test/NITTA/Model/ProcessorUnits/Divider/Tests.hs @@ -137,7 +137,7 @@ tests = [ division "a" "b" ["c"] ["d"] ] , luaTestCase - "one division" + "one division explicit" [__i| function f(a) a, _b = a / 2 @@ -145,6 +145,15 @@ tests = end f(1024) |] + , luaTestCase + "one division implicit" + [__i| + function f(a) + a = a / 2 + f(a) + end + f(1024) + |] , luaTestCase "two division" [__i|