Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

loop arguments added to trace #203

Merged
merged 3 commits into from
Mar 27, 2022
Merged

loop arguments added to trace #203

merged 3 commits into from
Mar 27, 2022

Conversation

ArturGogiyan
Copy link
Collaborator

@ArturGogiyan ArturGogiyan commented Mar 5, 2022

@ArturGogiyan ArturGogiyan added the bug Something isn't working label Mar 5, 2022
@ArturGogiyan ArturGogiyan self-assigned this Mar 5, 2022
@ArturGogiyan ArturGogiyan linked an issue Mar 5, 2022 that may be closed by this pull request
@@ -392,8 +392,13 @@ alg2graph LuaAlgBuilder{algGraph, algLatestLuaValueInstance, algVars} = flip exe
lua2functions src =
let syntaxTree = getLuaBlockFromSources src
luaAlgBuilder = buildAlg syntaxTree
frTrace = getFrTrace $ algTraceFuncs luaAlgBuilder
frTrace = getFrTrace $ getAllTraceFuncs luaAlgBuilder
in FrontendResult{frDataFlow = alg2graph luaAlgBuilder, frTrace = frTrace, frPrettyLog = prettyLog frTrace}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here you can use NamedFieldPuns:

     in FrontendResult{frDataFlow = alg2graph luaAlgBuilder, frTrace, frPrettyLog = prettyLog frTrace}
Write

src/NITTA/LuaFrontend.hs Outdated Show resolved Hide resolved
@ryukzak ryukzak self-requested a review March 7, 2022 17:18
Copy link
Owner

@ryukzak ryukzak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see comments

where
getAllTraceFuncs algBuilder =
let traceFuncs = algTraceFuncs algBuilder
startupArgNames = map (\(_, (x, _)) -> x) $ HM.toList $ algStartupArgs algBuilder
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean this (please, fix if I make a mistake). After change -- merge it.

diff --git a/src/NITTA/LuaFrontend.hs b/src/NITTA/LuaFrontend.hs
index bc3bf643..3950084d 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]

@ryukzak
Copy link
Owner

ryukzak commented Mar 11, 2022

And also I did forget. Can you add a test?

@ArturGogiyan ArturGogiyan merged commit 9dd317e into master Mar 27, 2022
@ryukzak ryukzak deleted the 192_console_output branch August 14, 2022 16:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Console output is broken
2 participants