aboutsummaryrefslogtreecommitdiff
path: root/Sil/Syntax.icl
diff options
context:
space:
mode:
Diffstat (limited to 'Sil/Syntax.icl')
-rw-r--r--Sil/Syntax.icl45
1 files changed, 27 insertions, 18 deletions
diff --git a/Sil/Syntax.icl b/Sil/Syntax.icl
index 0749dde..e28d616 100644
--- a/Sil/Syntax.icl
+++ b/Sil/Syntax.icl
@@ -15,13 +15,13 @@ import Sil.Util.Printer
instance toString Statement
where
- toString (Declaration n a) = n <+ " := " <+ a <+ ";"
- toString (Application e) = toString e <+ ";"
- toString (Return Nothing) = "return;"
- toString (Return (Just a)) = "return " <+ a <+ ";"
- toString (If bs e) = "if ..."
- toString (MachineStm s) = "|~" <+ s
- toString _ = "<<unimplemented Statement>>"
+ toString (Declaration _ n a) = n <+ " := " <+ a <+ ";"
+ toString (Application _ e) = toString e <+ ";"
+ toString (Return _ Nothing) = "return;"
+ toString (Return _ (Just a)) = "return " <+ a <+ ";"
+ toString (If _ bs e) = "if ..."
+ toString (MachineStm _ s) = "|~" <+ s
+ toString _ = "<<unimplemented Statement>>"
instance toString Arg where toString arg = arg.arg_type <+ " " <+ arg.arg_name
@@ -68,6 +68,15 @@ where
instance getPos Function where getPos f = f.f_pos
instance getPos Initialisation where getPos i = i.init_pos
+instance getPos Statement
+where
+ getPos (Declaration p _ _) = p
+ getPos (Application p _) = p
+ getPos (Return p _) = p
+ getPos (If p _ _) = p
+ getPos (While p _ _) = p
+ getPos (MachineStm p _) = p
+
instance allStatements Program
where allStatements p = concatMap allStatements p.p_funs
@@ -79,13 +88,13 @@ where allStatements cb = concatMap allStatements cb.cb_content
instance allStatements Statement
where
- allStatements st=:(Declaration _ _) = [st]
- allStatements st=:(Application _) = [st]
- allStatements st=:(Return _) = [st]
- allStatements st=:(If bs Nothing) = [st:concatMap (allStatements o snd) bs]
- allStatements st=:(If bs (Just e)) = [st:allStatements e ++ concatMap (allStatements o snd) bs]
- allStatements st=:(While _ cb) = [st:allStatements cb]
- allStatements st=:(MachineStm _) = [st]
+ allStatements st=:(Declaration _ _ _) = [st]
+ allStatements st=:(Application _ _) = [st]
+ allStatements st=:(Return _ _) = [st]
+ allStatements st=:(If _ bs Nothing) = [st:concatMap (allStatements o snd) bs]
+ allStatements st=:(If _ bs (Just e)) = [st:allStatements e ++ concatMap (allStatements o snd) bs]
+ allStatements st=:(While _ _ cb) = [st:allStatements cb]
+ allStatements st=:(MachineStm _ _) = [st]
instance allCodeBlocks Function where allCodeBlocks f = allCodeBlocks f.f_code
@@ -94,10 +103,10 @@ 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 _ = []
+ 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