2 * 2005 Matthew
Fluet (mfluet@acm
.org
)
7 * spec
.sml
- A data
structure describing the export interface
of a
10 * (C
) 2001, Lucent Technologies
, Bell Labs
12 * author
: Matthias
Blume (blume@research
.bell
-labs
.com
)
14 structure Spec
= struct
16 datatype constness
= RO | RW
19 datatype basic_ctype
=
24 | SLONGLONG | ULONGLONG
35 | ARR
of { t
: ctype
, d
: int, esz
: int }
36 | UNIMPLEMENTED
of string
38 withtype cft
= { args
: ctype list
, res
: ctype option
}
40 and cobj
= constness
* ctype
43 OFIELD
of { offset
: int, spec
: cobj
, synthetic
: bool }
44 | SBF
of { offset
: int, constness
: constness
, bits
: word, shift
: word }
45 | UBF
of { offset
: int, constness
: constness
, bits
: word, shift
: word }
47 type field
= { name
: string, spec
: fieldspec
}
64 type gty
= { src
: string, name
: string, spec
: ctype
}
66 type gvar
= { src
: string, name
: string, spec
: cobj
}
68 type gfun
= { src
: string,
71 argnames
: string list option
}
73 type enumval
= { name
: string, spec
: LargeInt
.int }
75 type enum
= { src
: string,
82 type spec
= { structs
: s list
,
89 fun join (x
: spec
, y
: spec
) = let
91 fun loop ([], a
) = rev a
93 loop (t
, if List.exists
94 (fn x
=> (sel x
: string) = sel h
) a
then a
100 { structs
= uniq #
tag (#structs x
, #structs y
),
101 unions
= uniq #
tag (#unions x
, #unions y
),
102 gtys
= uniq #
name (#gtys x
, #gtys y
),
103 gvars
= uniq #
name (#gvars x
, #gvars y
),
104 gfuns
= uniq #
name (#gfuns x
, #gfuns y
),
105 enums
= uniq #
tag (#enums x
, #enums y
) } : spec
108 val empty
: spec
= { structs
= [],