Skip to content
Snippets Groups Projects
Commit 9ec0f353 authored by chrg's avatar chrg
Browse files

Better Unstatic

parent c5b2a24a
No related branches found
No related tags found
No related merge requests found
......@@ -91,13 +91,24 @@ reduceCTranslUnit ::
reduceCTranslUnit (C.CTranslUnit es ni) ctx = do
let _functions = foldMap (findFunctions (: [])) es
unstatic <-
if ComputeFunctionFixpoint `isIn` ctx
then forM _functions \fun ->
if funIsStatic fun
then do
let fstr = C.identToString (funName fun)
isStatic <- check ("remove static from " <> fstr, funPosition fun)
pure fun{funIsStatic = isStatic}
else pure fun
else pure _functions
let funmap :: [(C.Ident, Maybe Function)] =
List.sortOn (maybe 0 (negate . funSize) . snd)
. Map.toList
. Map.fromListWith const
. map (\f -> (funName f, Just f))
. List.sortOn funSize
$ _functions
$ unstatic
let reduce funcs = forM funcs \(k, mf) ->
(k,) <$> runMaybeT do
......@@ -116,11 +127,7 @@ reduceCTranslUnit (C.CTranslUnit es ni) ctx = do
pure f{funIsStatic = isStatic}
-- try remove static
functions2 <- do
funmap' <- reduce funmap
if ComputeFunctionFixpoint `isIn` ctx
then reduce funmap'
else pure funmap'
functions2 <- reduce funmap
functions3 <- forM functions2 \(k, mf) ->
(k,) <$> runMaybeT do
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment