Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] View of /MLRISC/trunk/c-calls/c-types.sml
ViewVC logotype

View of /MLRISC/trunk/c-calls/c-types.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2995 - (download) (annotate)
Fri Apr 18 06:59:04 2008 UTC (11 years, 2 months ago) by mrainey
File size: 986 byte(s)
  Still working out struct passing.
(* c-types.sml
 *
 * COPYRIGHT (c) 1999 Bell Labs, Lucent Technologies
 *
 * A representation of C Types for specifying the arguments and results
 * of C function calls.
 *)


structure CTypes =
  struct

    datatype c_type
      = C_void
      | C_float
      | C_double
      | C_long_double
      | C_unsigned of c_int
      | C_signed of c_int
      | C_PTR
      | C_ARRAY of (c_type * int)
      | C_STRUCT of c_type list
      | C_UNION of c_type list

    and c_int
      = I_char
      | I_short
      | I_int
      | I_long
      | I_long_long


  (* multiple calling conventions on a single architecture *)
    type calling_convention = string

  (* prototype describing C function *)
    type c_proto = {
	conv : calling_convention,
	retTy : c_type,
	paramTys : c_type list
      }

    (* eliminate unions and structs *)
    fun flattenCTy cTy = (case cTy
        of (C_STRUCT cTys |
	    C_UNION cTys ) => List.concat (List.map flattenCTy cTys)
	 | cTy => [cTy])


  end

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0