@@ -47,9 +47,6 @@ compile codegen f tm
4747 let tmnames = namesUsed (STerm tm)
4848 usedIn <- mapM (allNames []) tmnames
4949 let used = sUN "prim__subBigInt" : sUN "prim__addBigInt" : concat usedIn
50− defsIn <- mkDecls tm used
51−
52− -- TODO: traverse all names correctly
5350
5451 -- TODO: DEBUG-ONLY, remove
5552 ctx <- tt_ctxt <$> getIState
@@ -65,11 +62,14 @@ compile codegen f tm
6562 -- END TODO
6663
6764 maindef <- irMain tm
65+ iLOG $ "MAIN: " ++ show maindef
66+ iLOG $ "USED: " ++ show used
6867 objs <- getObjectFiles codegen
6968 libs <- getLibs codegen
7069 flags <- getFlags codegen
7170 hdrs <- getHdrs codegen
7271 impdirs <- allImportDirs
72+ defsIn <- mkDecls tm used
7373 let defs = defsIn ++ [(sMN 0 "runMain", maindef)]
7474 -- iputStrLn $ showSep "\n" (map show defs)
7575 let (nexttag, tagged) = addTags 65536 (liftAll defs)
@@ -278,8 +278,8 @@ instance ToIR (TT Name) where
278278 args' <- mapM (ir' env) args
279279 return (LApp False f' args')
280280 where mkUsed u i [] = []
281− mkUsed u i (x : xs) | i `notElem` u = LNothing : mkUsed u (i + 1) xs
282− | otherwise = x : mkUsed u (i + 1) xs
281+ mkUsed u i (x : xs) | i `elem` u = x : mkUsed u (i + 1) xs
282+ | otherwise = LNothing : mkUsed u (i + 1) xs
283283-- ir' env (P _ (NS (UN "Z") ["Nat", "Prelude"]) _)
284284-- = return $ LConst (BI 0)
285285 ir' env (P _ n _) = return $ LV (Glob n)