From 3bec4b221029f045a92b0ee5bf023c3a729e8ea3 Mon Sep 17 00:00:00 2001 From: ArturGogiyan Date: Sun, 27 Mar 2022 11:11:27 +0300 Subject: [PATCH] loop arg tracing test added --- src/NITTA/LuaFrontend.hs | 7 +++++-- test/NITTA/LuaFrontend/Tests.hs | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/NITTA/LuaFrontend.hs b/src/NITTA/LuaFrontend.hs index bc3bf643e..3950084d8 100644 --- a/src/NITTA/LuaFrontend.hs +++ b/src/NITTA/LuaFrontend.hs @@ -101,7 +101,7 @@ data LuaAlgBuilder x = LuaAlgBuilder algVarCounters :: HM.HashMap T.Text Int , -- | A table lists all uses of a particular LuaValueInstance. algVars :: HM.HashMap LuaValueInstance [T.Text] - , -- | A table correlating the ordinal number of an argument with a variable storing its value and startup value of this variable. + , -- | Map argument index to the variable name and initial value (in text). algStartupArgs :: HM.HashMap Int (T.Text, T.Text) , -- | A table correlating constant with LuaValueInstance which store this constant. algConstants :: HM.HashMap T.Text LuaValueInstance @@ -397,7 +397,10 @@ lua2functions src = where getAllTraceFuncs algBuilder = let traceFuncs = algTraceFuncs algBuilder - startupArgNames = map (\(_, (x, _)) -> x) $ HM.toList $ algStartupArgs algBuilder + startupArgNames = + map + (\(_idx, (varName, _initValue)) -> varName) + $ HM.toList $ algStartupArgs algBuilder in map (\name -> ([name <> "^0"], defaultFmt)) startupArgNames <> traceFuncs getFrTrace traceFuncs = [TraceVar fmt var | (vars, fmt) <- traceFuncs, var <- vars] diff --git a/test/NITTA/LuaFrontend/Tests.hs b/test/NITTA/LuaFrontend/Tests.hs index b26feaaab..4cc98a840 100644 --- a/test/NITTA/LuaFrontend/Tests.hs +++ b/test/NITTA/LuaFrontend/Tests.hs @@ -454,6 +454,24 @@ test_complex_examples = test_trace_features = [ traceLuaSimulationTestCase + pInt + "loop argument tracing" + [__i| + function counter(i) + counter(i + 1) + end + counter(0) + |] + [__i| + | Cycle | i | + |:-------|:-------| + | 1 | 0.000 | + | 2 | 1.000 | + | 3 | 2.000 | + | 4 | 3.000 | + | 5 | 4.000 |\n + |] + , traceLuaSimulationTestCase pInt "simple trace" [__i|