foldVarDecl :: Int VarDecl -> Gen Int
foldVarDecl x (VarDecl _ _ k e) = g e
+ >>| annote x k
>>| updateAdressbook (extend k (ADDR x)) >>| pure (x + 1)
addVars :: [String] -> (Addressbook -> Addressbook)
updateAdressbook (addVars args) >>|
tell [Lab k] >>|
tell [Instr "link" [Lit 0] ""] >>|
- //then generate functions for the VarDecls
+ //add the vars
foldM foldVarDecl 1 vds >>|
- //then the main function
+ //and the statements
mapM_ g stms >>|
updateAdressbook (const oldMap) >>| pure ()
+annote :: Int -> String -> Gen ()
+annote pos key =
+ tell [Instr "annote" [Raw "MP", Lit pos, Lit pos, Raw "orange", Raw key] ""]
+
class print a :: a -> [String]
instance print Instr where