]> Joshua Wise's Git repositories - snipe.git/blobdiff - parse/astutils.sml
Initial import of l5c
[snipe.git] / parse / astutils.sml
index 72bdaeb71b2d68e0875477a4b0c3894e7241feae..7031e67593face5fe3cb5d9a8571b38eed25defd 100644 (file)
@@ -2,33 +2,22 @@ signature ASTUTILS =
 sig    
   structure Program :
   sig
 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
     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
   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
   end
 end
 
 structure AstUtils :> ASTUTILS =
 struct
+  structure T = Type
   structure A = Ast
 
   structure Program =
   structure A = Ast
 
   structure Program =
@@ -36,10 +25,10 @@ struct
     fun append_typedef (tds, fns) (i, td) =
       let
         val mark = case td
     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)
                     | _ => 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) ;
                                                 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
        (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)
   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
       | 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
 end
This page took 0.025329 seconds and 4 git commands to generate.