5 val append_typedef : Ast.program -> (Ast.ident * Type.typedef) -> Ast.program
6 val append_function : Ast.program -> (Ast.ident * Ast.function) -> Ast.program
11 val data : Ast.function -> Ast.function
12 val mark : Ast.function -> Mark.ext option
13 val returntype : Ast.function -> Type.vtype
14 val params : Ast.function -> Type.variable list
18 structure AstUtils :> ASTUTILS =
25 fun append_typedef (tds, fns) (i, td) =
28 of T.MarkedTypedef m => Mark.ext m
30 val _ = case (Symbol.look tds i)
31 of SOME (T.MarkedTypedef m) => (ErrorMsg.error mark ("Redefining typedef " ^ Symbol.name i) ;
32 ErrorMsg.error (Mark.ext m) "(was originally defined here)" ;
34 | SOME _ => (ErrorMsg.error mark ("Redefining typedef " ^ Symbol.name i) ;
38 (Symbol.bind tds (i, td), fns)
40 fun append_function (tds, fns) (i, func) =
43 of A.MarkedFunction m => Mark.ext m
45 val _ = case (Symbol.look fns i)
46 of SOME (A.MarkedFunction m) => (ErrorMsg.error mark ("Redefining function " ^ Symbol.name i) ;
47 ErrorMsg.error (Mark.ext m) "(was originally defined here)" ;
49 | SOME _ => (ErrorMsg.error mark ("Redefining function " ^ Symbol.name i) ;
53 (tds, Symbol.bind fns (i, func))
59 fun data (A.MarkedFunction m) = data (Mark.data m)
62 fun mark (A.MarkedFunction m) = Mark.ext m
65 fun returntype (A.MarkedFunction m) = returntype (Mark.data m)
66 | returntype (A.Function (r, _, _, _)) = r
67 | returntype (A.Extern (r, _)) = r
69 fun params (A.MarkedFunction m) = params (Mark.data m)
70 | params (A.Function (_, pl, _, _)) = pl
71 | params (A.Extern (_, pl)) = pl