diff options
author | Joe Crayne <joe@jerkface.net> | 2019-03-19 05:01:37 -0400 |
---|---|---|
committer | Joe Crayne <joe@jerkface.net> | 2019-03-19 05:01:37 -0400 |
commit | 272514b914d3cb715d09f1476e41bae731c98881 (patch) | |
tree | e0b96bdf3d9d4344b591af655071c22992e0c4d2 /monkeypatch.hs | |
parent | a5bcd90145cf81f675acd5a1ba7df37326a817a9 (diff) |
Grok ternary operator.
Diffstat (limited to 'monkeypatch.hs')
-rw-r--r-- | monkeypatch.hs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/monkeypatch.hs b/monkeypatch.hs index d9fb192..a835e86 100644 --- a/monkeypatch.hs +++ b/monkeypatch.hs | |||
@@ -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 (CCond cond (Just thn) els _) = do | ||
236 | (cs,c) <- grokExpression cond | ||
237 | (ts,t) <- grokExpression thn | ||
238 | (es,e) <- grokExpression els | ||
239 | let tt = foldr applyComputation t ts | ||
240 | ee = foldr applyComputation e es | ||
241 | return $ (,) cs $ fmap (\cnd -> If () cnd (comp tt) (comp ee)) c | ||
242 | { compFree = compFree ee `Map.union` compFree tt `Map.union` compFree c | ||
243 | } | ||
235 | grokExpression (CCast (CDecl [ CTypeSpec (CVoidType _) ] | 244 | grokExpression (CCast (CDecl [ CTypeSpec (CVoidType _) ] |
236 | [ ( Just (CDeclr Nothing [ CPtrDeclr [] _ ] Nothing [] _) , Nothing , Nothing) ] | 245 | [ ( Just (CDeclr Nothing [ CPtrDeclr [] _ ] Nothing [] _) , Nothing , Nothing) ] |
237 | _) | 246 | _) |