diff options
author | Joe Crayne <joe@jerkface.net> | 2019-03-18 22:52:28 -0400 |
---|---|---|
committer | Joe Crayne <joe@jerkface.net> | 2019-03-18 22:52:28 -0400 |
commit | a5bcd90145cf81f675acd5a1ba7df37326a817a9 (patch) | |
tree | 2eb0d35a6d31ebfae8b8906f801c6b1402572c74 /monkeypatch.hs | |
parent | a6299c4d8b4dedb5c8f3b83d2caaa69ed025b202 (diff) |
recognize nullPtr, fix withPointer output.
Diffstat (limited to 'monkeypatch.hs')
-rw-r--r-- | monkeypatch.hs | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/monkeypatch.hs b/monkeypatch.hs index 90299ed..d9fb192 100644 --- a/monkeypatch.hs +++ b/monkeypatch.hs | |||
@@ -223,8 +223,8 @@ grokExpression (CUnary CAdrOp (CVar cv0 _) _) = do | |||
223 | , compIntro = Map.singleton hv () | 223 | , compIntro = Map.singleton hv () |
224 | , comp = Lambda () [hspvar k] | 224 | , comp = Lambda () [hspvar k] |
225 | $ InfixApp () | 225 | $ InfixApp () |
226 | (App () (hsvar "withPointer") (hsvar cv)) | 226 | (hsvar cv) |
227 | hsopBind | 227 | (QVarOp () (UnQual () (HS.Ident () "withPointer"))) |
228 | (Lambda () [hspvar hv] (hsvar k)) | 228 | (Lambda () [hspvar hv] (hsvar k)) |
229 | } | 229 | } |
230 | return $ (,) ss Computation | 230 | return $ (,) ss Computation |
@@ -232,6 +232,15 @@ grokExpression (CUnary CAdrOp (CVar cv0 _) _) = do | |||
232 | , compIntro = Map.empty | 232 | , compIntro = Map.empty |
233 | , comp = hsvar hv | 233 | , comp = hsvar hv |
234 | } | 234 | } |
235 | grokExpression (CCast (CDecl [ CTypeSpec (CVoidType _) ] | ||
236 | [ ( Just (CDeclr Nothing [ CPtrDeclr [] _ ] Nothing [] _) , Nothing , Nothing) ] | ||
237 | _) | ||
238 | (CConst (CIntConst zero _)) _) | 0 <- getCInteger zero = do | ||
239 | return $ (,) [] Computation | ||
240 | { compFree = Map.singleton "nullPtr" () | ||
241 | , compIntro = Map.empty | ||
242 | , comp = hsvar "nullPtr" | ||
243 | } | ||
235 | grokExpression (C.CCall (CVar fn _) exps _) = do | 244 | grokExpression (C.CCall (CVar fn _) exps _) = do |
236 | gs <- mapM grokExpression exps | 245 | gs <- mapM grokExpression exps |
237 | let ss = concatMap fst gs -- TODO: resolve variable name conflicts | 246 | let ss = concatMap fst gs -- TODO: resolve variable name conflicts |