Skip to content
Snippets Groups Projects
Commit 68f384cd authored by chrg's avatar chrg
Browse files

Enable removal of some features

parent f15e3c50
No related branches found
No related tags found
No related merge requests found
...@@ -415,8 +415,9 @@ updateCDerivedDeclarators bt ff dd = do ...@@ -415,8 +415,9 @@ updateCDerivedDeclarators bt ff dd = do
C.CPtrDeclr _ _ -> do C.CPtrDeclr _ _ -> do
pure (NonVoid . TPointer $ t, d : dd') pure (NonVoid . TPointer $ t, d : dd')
C.CArrDeclr r as ni -> do C.CArrDeclr r as ni -> do
ctx <- get
d' <- case as of d' <- case as of
C.CArrSize _ _ -> do C.CArrSize _ _ | not (DontReduceArrays `isIn` ctx) -> do
b <- check ("remove array size", C.posOf ni) b <- check ("remove array size", C.posOf ni)
pure $ if b then C.CArrDeclr r (C.CNoArrSize False) ni else d pure $ if b then C.CArrDeclr r (C.CNoArrSize False) ni else d
_ -> pure d _ -> pure d
...@@ -567,9 +568,9 @@ reduceCExternalDeclaration r = case r of ...@@ -567,9 +568,9 @@ reduceCExternalDeclaration r = case r of
isStatic <- case forceStatic of isStatic <- case forceStatic of
Just t -> pure t Just t -> pure t
Nothing -> Nothing ->
if any isStaticSpec spec if any isStaticSpec spec && not (DontRemoveStatic `isIn` ctx)
then not <$> check ("make declaration non-static", C.posOf ni) then not <$> check ("make declaration non-static", C.posOf ni)
else return False else return True
ctx' <- get ctx' <- get
(bt, spec') <- joinLiftMaybe $ updateCDeclarationSpecifiers keepAll{sfKeepStatic = isStatic} ctx' spec (bt, spec') <- joinLiftMaybe $ updateCDeclarationSpecifiers keepAll{sfKeepStatic = isStatic} ctx' spec
...@@ -792,7 +793,7 @@ reduceCInitializer t einit ctx toplevel = case einit of ...@@ -792,7 +793,7 @@ reduceCInitializer t einit ctx toplevel = case einit of
r' <- reduceCInitializer t' r ctx False r' <- reduceCInitializer t' r ctx False
pure (p, r') pure (p, r')
TPointer (NonVoid t') TPointer (NonVoid t')
| toplevel -> do | toplevel && not (DontReduceArrays `isIn` ctx) -> do
items' <- reverseRemoveList ni2 (reverse items) items' <- reverseRemoveList ni2 (reverse items)
forM (reverse items') \(p, r) -> do forM (reverse items') \(p, r) -> do
r' <- reduceCInitializer t' r ctx False r' <- reduceCInitializer t' r ctx False
...@@ -1476,8 +1477,9 @@ data Keyword ...@@ -1476,8 +1477,9 @@ data Keyword
| ComputeFunctionFixpoint | ComputeFunctionFixpoint
| InlineTypeDefs | InlineTypeDefs
| InitializeVariables | InitializeVariables
| NoSemantics
| AllowEmptyDeclarations | AllowEmptyDeclarations
| DontReduceArrays
| DontRemoveStatic
| DisallowVariableInlining | DisallowVariableInlining
| AllowInfiniteForLoops | AllowInfiniteForLoops
deriving (Show, Read, Enum, Eq, Ord) deriving (Show, Read, Enum, Eq, Ord)
......
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