+programContext :: [FunDecl] -> SSMProgram
+programContext x = [Lab "1func"
+ ,Instr "link" [Lit 0] ""
+ :fS ["1printint" ,"1printchar"
+ ,"read" ,"1readint"
+ ,"isEmpty":map (\(FunDecl _ k _ _ _ _)->k) x] 0] ++
+ [Instr "unlink" [] ""
+ ,Instr "ret" [] "":context]
+ where
+
+ fS :: [String] Int -> SSMProgram
+ fS [] _ = []
+ fS [k:xs] n = [
+ Instr "ldl" [Lit -2] ""
+ ,Instr "ldc" [Lit n] $ "branch to: " +++ k
+ ,Instr "eq" [] ""
+ ,Instr "brt" [L k] ""
+ :fS xs $ n+1]
+ context :: SSMProgram
+ context = [Lab "1printint"