From fe76e2ad510ec9e4df965a9620f8d36778222c08 Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Fri, 28 Jul 2017 23:46:38 +0200 Subject: Add globals on A-stack --- Sil/Check.icl | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'Sil/Check.icl') diff --git a/Sil/Check.icl b/Sil/Check.icl index c51d73c..f9147bf 100644 --- a/Sil/Check.icl +++ b/Sil/Check.icl @@ -34,6 +34,8 @@ where = "Type error: no return from non-void function '" <+ f <+ "'." toString (LocalVoid f l) = "Type error: local variable '" <+ l <+ "' in '" <+ f <+ "' cannot have type Void." + toString (BasicGlobal g) + = "Error: global variable '" <+ g <+ "' cannot have a basic type." instance <<< CheckError where <<< f e = f <<< toString e <<< "\r\n" @@ -42,6 +44,7 @@ checkProgram err prog = checkErrors [ checkFunctionNames , checkMainFunction + , checkGlobals ] prog $ appFst flatten $ mapSt (flip checkFunction) prog.p_funs err where @@ -56,6 +59,12 @@ where \\ fs <- tails [f.f_name \\ f <- p.p_funs] | not (isEmpty fs) && isMember (hd fs) (tl fs)] + checkGlobals :: Program -> [CheckError] + checkGlobals p = + [ BasicGlobal g.init_name + \\ g <- p.p_globals + | (typeSize g.init_type).bsize <> 0] + checkFunction :: *(Maybe *File) Function -> *([CheckError], *Maybe *File) checkFunction err f = checkErrors [ checkLocals -- cgit v1.2.3