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 =
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) ;
(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)
| 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