summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Crayne <joe@jerkface.net>2019-03-20 14:41:29 -0400
committerJoe Crayne <joe@jerkface.net>2019-03-20 14:41:29 -0400
commit9f4cfc458fbe6140ac2793a29068794bcd23883e (patch)
treefb02f91b74f687c286e7357358d94aa06c4ce312
parent6efda02e8d3eb4c67d033fc2506fb5c76ab8ddfe (diff)
Grok assignment to field.
-rw-r--r--monkeypatch.hs16
1 files changed, 16 insertions, 0 deletions
diff --git a/monkeypatch.hs b/monkeypatch.hs
index e4ccbc1..461d3c1 100644
--- a/monkeypatch.hs
+++ b/monkeypatch.hs
@@ -383,6 +383,22 @@ grokStatement (CBlockStmt (CExpr (Just (C.CCall (CVar (C.Ident "__assert_fail" _
383 x' = fmap (\y -> App () (hsvar "error") y) x 383 x' = fmap (\y -> App () (hsvar "error") y) x
384 return $ fmap (\y -> Lambda () [hspvar k] y) x' 384 return $ fmap (\y -> Lambda () [hspvar k] y) x'
385grokStatement (CBlockStmt (CExpr (Just 385grokStatement (CBlockStmt (CExpr (Just
386 (CAssign CAssignOp
387 (CMember cvar fld isptr _) expr _)) _)) = do
388 (xs,x) <- grokExpression expr
389 v <- cvarName cvar
390 let fieldlbl = identToString fld
391 k1 = uniqIdentifier "go" (compFree x)
392 fieldinit = comp x
393 x' = x
394 { comp = infixOp
395 (App () (App () (App () (hsvar "set")
396 (TypeApp () (TyPromoted () (PromotedString () fieldlbl fieldlbl))))
397 (hsvar v))
398 fieldinit) ">>" (hsvar k1)
399 }
400 return $ fmap (\y -> Lambda () [hspvar k1] y) $ foldr applyComputation x' xs
401grokStatement (CBlockStmt (CExpr (Just
386 (CAssign CAssignOp cvarnew 402 (CAssign CAssignOp cvarnew
387 (C.CCall cvarfun [] _) _)) _)) = do 403 (C.CCall cvarfun [] _) _)) _)) = do
388 v <- cvarName cvarnew 404 v <- cvarName cvarnew