5 val append_typedef : Ast.program -> (Ast.ident * Ast.typedef) -> Ast.program
6 val append_function : Ast.program -> (Ast.ident * Ast.function) -> Ast.program
11 val data : Ast.typedef -> Ast.typedef
12 val mark : Ast.typedef -> Mark.ext option
17 val data : Ast.function -> Ast.function
18 val mark : Ast.function -> Mark.ext option
19 val returntype : Ast.function -> Ast.vtype
20 val params : Ast.function -> Ast.variable list
25 val size : Ast.vtype -> int
26 val issmall : Ast.vtype -> bool
30 structure AstUtils :> ASTUTILS =
36 fun append_typedef (tds, fns) (i, td) =
39 of A.MarkedTypedef m => Mark.ext m
41 val _ = case (Symbol.look tds i)
42 of SOME (A.MarkedTypedef m) => (ErrorMsg.error mark ("Redefining typedef " ^ Symbol.name i) ;
43 ErrorMsg.error (Mark.ext m) "(was originally defined here)" ;
45 | SOME _ => (ErrorMsg.error mark ("Redefining typedef " ^ Symbol.name i) ;
49 (Symbol.bind tds (i, td), fns)
51 fun append_function (tds, fns) (i, func) =
54 of A.MarkedFunction m => Mark.ext m
56 val _ = case (Symbol.look fns i)
57 of SOME (A.MarkedFunction m) => (ErrorMsg.error mark ("Redefining function " ^ Symbol.name i) ;
58 ErrorMsg.error (Mark.ext m) "(was originally defined here)" ;
60 | SOME _ => (ErrorMsg.error mark ("Redefining function " ^ Symbol.name i) ;
64 (tds, Symbol.bind fns (i, func))
70 fun data (A.MarkedTypedef m) = data (Mark.data m)
73 fun mark (A.MarkedTypedef m) = Mark.ext m
79 fun data (A.MarkedFunction m) = data (Mark.data m)
82 fun mark (A.MarkedFunction m) = Mark.ext m
85 fun returntype (A.MarkedFunction m) = returntype (Mark.data m)
86 | returntype (A.Function (r, _, _, _)) = r
87 | returntype (A.Extern (r, _)) = r
89 fun params (A.MarkedFunction m) = params (Mark.data m)
90 | params (A.Function (_, pl, _, _)) = pl
91 | params (A.Extern (_, pl)) = pl
97 | size (A.Typedef _) = raise ErrorMsg.InternalError "AU.Type.size on non-small type?"
98 | size (A.Pointer _) = 8
99 | size (A.Array _) = 8
102 fun issmall A.Int = true
103 | issmall (A.Pointer _) = true
104 | issmall (A.Array _) = true