aboutsummaryrefslogtreecommitdiff
path: root/Sil/Check.icl
diff options
context:
space:
mode:
authorCamil Staps2017-07-30 09:53:24 +0200
committerCamil Staps2017-07-30 09:53:24 +0200
commitad519a42876796f969900e687cea80c799dd40ec (patch)
tree608f3250dc4924be286d3c296f74db9bfed5dabd /Sil/Check.icl
parentReorganise: make Position a field in Syntax types (diff)
Add positions to Statements
Diffstat (limited to 'Sil/Check.icl')
-rw-r--r--Sil/Check.icl30
1 files changed, 14 insertions, 16 deletions
diff --git a/Sil/Check.icl b/Sil/Check.icl
index 6179a66..b06824b 100644
--- a/Sil/Check.icl
+++ b/Sil/Check.icl
@@ -57,21 +57,19 @@ checkFunction err f = checkErrors
where
checkReturnAndVoid :: Function -> [Error]
checkReturnAndVoid f = case f.f_type of
- TVoid -> case [st \\ st=:(Return (Just _)) <- allStatements f] of
- [] -> []
- _ -> [Ck_ReturnExpressionFromVoid (errpos f) f.f_name]
+ TVoid -> [Ck_ReturnExpressionFromVoid (errpos st) f.f_name \\ st=:(Return _ (Just _)) <- allStatements f]
_ -> if (sureToReturn f.f_code) [] [Ck_NoReturnFromNonVoid (errpos f) f.f_name]
where
sureToReturn :: CodeBlock -> Bool
sureToReturn cb = case cb.cb_content of
[] -> False
sts -> case last sts of
- Return _ -> True
- While _ cb` -> sureToReturn cb`
- If bs (Just e) -> all sureToReturn [e:map snd bs]
- If bs Nothing -> all (sureToReturn o snd) bs
- MachineStm _ -> True // Let's assume the user is not stupid
- _ -> False
+ Return _ _ -> True
+ While _ _ cb` -> sureToReturn cb`
+ If _ bs (Just e) -> all sureToReturn [e:map snd bs]
+ If _ bs Nothing -> all (sureToReturn o snd) bs
+ MachineStm _ _ -> True // Let's assume the user is not stupid
+ _ -> False
checkMainFunctionType :: Function -> [Error]
checkMainFunctionType {f_name="main",f_args=[]}
@@ -95,13 +93,13 @@ where
underlyingCBs :: CodeBlock -> [CodeBlock]
underlyingCBs cb = concatMap findCBs cb.cb_content
where
- findCBs (Declaration _ _) = []
- findCBs (Application _) = []
- findCBs (Return _) = []
- findCBs (If bs (Just e)) = [e:map snd bs]
- findCBs (If bs Nothing) = map snd bs
- findCBs (While _ cb) = [cb]
- findCBs (MachineStm _) = []
+ findCBs (Declaration _ _ _) = []
+ findCBs (Application _ _) = []
+ findCBs (Return _ _) = []
+ findCBs (If _ bs (Just e)) = [e:map snd bs]
+ findCBs (If _ bs Nothing) = map snd bs
+ findCBs (While _ _ cb) = [cb]
+ findCBs (MachineStm _ _) = []
checkVoid :: (Type, Name) -> [Error]
checkVoid (TVoid, n) = [Ck_LocalVoid f.f_name n]