From b56b655f0bea1922999305d8e88bf16e874098a3 Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Thu, 20 Jul 2017 08:24:33 +0000 Subject: Add checks for locals with type Void --- Sil/Syntax.icl | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'Sil/Syntax.icl') diff --git a/Sil/Syntax.icl b/Sil/Syntax.icl index f78ba83..8083eba 100644 --- a/Sil/Syntax.icl +++ b/Sil/Syntax.icl @@ -77,6 +77,26 @@ where allStatements st=:(While _ cb) = [st:allStatements cb] allStatements st=:(MachineStm _) = [st] +instance allCodeBlocks Function where allCodeBlocks f = allCodeBlocks f.f_code + +instance allCodeBlocks CodeBlock +where allCodeBlocks cb = [cb:concatMap allCodeBlocks cb.cb_content] + +instance allCodeBlocks Statement +where + allCodeBlocks (If bs Nothing) = concatMap (allCodeBlocks o snd) bs + allCodeBlocks (If bs (Just e)) = [e:concatMap (allCodeBlocks o snd) bs] + allCodeBlocks (While _ cb) = [cb] + allCodeBlocks _ = [] + +instance allLocals Function +where + allLocals f = [(a.arg_type, a.arg_name) \\ a <- f.f_args] ++ + allLocals f.f_code + +instance allLocals CodeBlock +where allLocals cb = [(i.init_type, i.init_name) \\ i <- cb.cb_init] + typeSize :: Type -> Int typeSize TVoid = 0 typeSize TBool = 1 -- cgit v1.2.3