summaryrefslogtreecommitdiff
path: root/check.hs
diff options
context:
space:
mode:
authortomsmeding <tom.smeding@gmail.com>2017-02-01 23:12:40 +0100
committertomsmeding <tom.smeding@gmail.com>2017-02-01 23:12:40 +0100
commitb9b2ccd5155f8ce14cc9b4b04fffe56b988a3bdd (patch)
treee319d2162552222a0aebcd1f10007670b33e40cb /check.hs
parent44ccdb3c72fad6daf995c0354e3ab75a3260ca9c (diff)
Pointer arithmetic!
Diffstat (limited to 'check.hs')
-rw-r--r--check.hs4
1 files changed, 3 insertions, 1 deletions
diff --git a/check.hs b/check.hs
index 22d8196..65c1470 100644
--- a/check.hs
+++ b/check.hs
@@ -214,6 +214,8 @@ complogBO = compareBO ++ logicBO
resultTypeBO :: BinaryOperator -> Type -> Type -> Maybe Type
resultTypeBO Minus (TypePtr t1) (TypePtr t2) | t1 == t2 = Just $ TypeUInt 1
resultTypeBO bo (TypePtr t1) (TypePtr t2) | t1 == t2 && bo `elem` complogBO = Just $ TypeUInt 1
+resultTypeBO bo t@(TypePtr _) (TypeInt _) | bo `elem` [Plus, Minus] = Just t
+resultTypeBO bo (TypeInt _) t@(TypePtr _) | bo `elem` [Plus, Minus] = Just t
resultTypeBO _ (TypePtr _) _ = Nothing
resultTypeBO _ _ (TypePtr _) = Nothing
@@ -243,7 +245,7 @@ resultTypeUO uo t@(TypeInt _) | uo `elem` [Negate, Invert] = Just t
resultTypeUO uo t@(TypeUInt _) | uo `elem` [Negate, Invert] = Just t
resultTypeUO Negate TypeFloat = Just TypeFloat
resultTypeUO Negate TypeDouble = Just TypeDouble
-resultTypeUO Dereference t@(TypePtr _) = Just t
+resultTypeUO Dereference (TypePtr t) = Just t
resultTypeUO _ _ = Nothing
smallestFloatType :: Double -> Type