X-Git-Url: http://git.joshuawise.com/snipe.git/blobdiff_plain/1144856ba9d6018d9922c6ede7e97779a0fe6373..HEAD:/parse/astutils.sml diff --git a/parse/astutils.sml b/parse/astutils.sml index 72bdaeb..7031e67 100644 --- a/parse/astutils.sml +++ b/parse/astutils.sml @@ -2,33 +2,22 @@ signature ASTUTILS = sig structure Program : sig - val append_typedef : Ast.program -> (Ast.ident * Ast.typedef) -> Ast.program + val append_typedef : Ast.program -> (Ast.ident * Type.typedef) -> Ast.program val append_function : Ast.program -> (Ast.ident * Ast.function) -> Ast.program end - - structure Typedef : - sig - val data : Ast.typedef -> Ast.typedef - val mark : Ast.typedef -> Mark.ext option - end - + structure Function : sig val data : Ast.function -> Ast.function val mark : Ast.function -> Mark.ext option - val returntype : Ast.function -> Ast.vtype - val params : Ast.function -> Ast.variable list - end - - structure Type : - sig - val size : Ast.vtype -> int - val issmall : Ast.vtype -> bool + val returntype : Ast.function -> Type.vtype + val params : Ast.function -> Type.variable list end end structure AstUtils :> ASTUTILS = struct + structure T = Type structure A = Ast structure Program = @@ -36,10 +25,10 @@ struct fun append_typedef (tds, fns) (i, td) = let val mark = case td - of A.MarkedTypedef m => Mark.ext m + of T.MarkedTypedef m => Mark.ext m | _ => NONE val _ = case (Symbol.look tds i) - of SOME (A.MarkedTypedef m) => (ErrorMsg.error mark ("Redefining typedef " ^ Symbol.name i) ; + of SOME (T.MarkedTypedef m) => (ErrorMsg.error mark ("Redefining typedef " ^ Symbol.name i) ; ErrorMsg.error (Mark.ext m) "(was originally defined here)" ; raise ErrorMsg.Error) | SOME _ => (ErrorMsg.error mark ("Redefining typedef " ^ Symbol.name i) ; @@ -64,16 +53,7 @@ struct (tds, Symbol.bind fns (i, func)) end end - - structure Typedef = - struct - fun data (A.MarkedTypedef m) = data (Mark.data m) - | data m = m - - fun mark (A.MarkedTypedef m) = Mark.ext m - | mark _ = NONE - end - + structure Function = struct fun data (A.MarkedFunction m) = data (Mark.data m) @@ -90,18 +70,5 @@ struct | params (A.Function (_, pl, _, _)) = pl | params (A.Extern (_, pl)) = pl end - - structure Type = - struct - fun size A.Int = 4 - | size (A.Typedef _) = raise ErrorMsg.InternalError "AU.Type.size on non-small type?" - | size (A.Pointer _) = 8 - | size (A.Array _) = 8 - | size A.TNull = 8 - - fun issmall A.Int = true - | issmall (A.Pointer _) = true - | issmall (A.Array _) = true - | issmall _ = false - end + end