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

SCM Repository

[smlnj] Annotation of /sml/trunk/src/ml-nlffigen/spec.sml
ViewVC logotype

Annotation of /sml/trunk/src/ml-nlffigen/spec.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1011 - (view) (download)

1 : blume 828 (*
2 :     * spec.sml - A data structure describing the export interface of a
3 :     * C program.
4 :     *
5 :     * (C) 2001, Lucent Technologies, Bell Labs
6 :     *
7 :     * author: Matthias Blume (blume@research.bell-labs.com)
8 :     *)
9 :     structure Spec = struct
10 :    
11 :     datatype constness = RO | RW
12 :     type tag = string
13 :    
14 :     datatype ctype =
15 :     SCHAR | UCHAR | SINT | UINT | SSHORT | USHORT | SLONG | ULONG
16 :     | FLOAT | DOUBLE | VOIDPTR
17 :     | STRUCT of tag
18 :     | UNION of tag
19 :     | FPTR of cft
20 :     | PTR of cobj
21 :     | ARR of { t: ctype, d: int, esz: int }
22 :    
23 :     withtype cft = { args: ctype list, res: ctype option }
24 :    
25 :     and cobj = constness * ctype
26 :    
27 :     datatype fieldspec =
28 :     OFIELD of { offset: int, spec: cobj, synthetic: bool }
29 :     | SBF of { offset: int, constness: constness, bits: word, shift: word }
30 :     | UBF of { offset: int, constness: constness, bits: word, shift: word }
31 :    
32 :     type field = { name: string, spec: fieldspec }
33 :    
34 :     type s =
35 : blume 1011 { src: string,
36 :     tag: tag, anon: bool, size: word, fields: field list }
37 : blume 828 type u =
38 : blume 1011 { src: string,
39 :     tag: tag, anon: bool, size: word, largest: field, all: field list }
40 : blume 828
41 : blume 1011 type gvar = { src: string, name: string, spec: cobj }
42 : blume 828
43 : blume 1011 type gfun = { src: string,
44 :     name: string, spec: cft, argnames: string list option }
45 : blume 828
46 : blume 1011 type gty = { src: string, name: string, spec: ctype }
47 : blume 828
48 : blume 1011 type enumval = { name: string, spec: LargeInt.int }
49 : blume 975
50 : blume 1011 type enum = { src: string, tag: tag, spec: enumval list }
51 :    
52 : blume 828 type spec = { structs: s list,
53 :     unions: u list,
54 :     gtys: gty list,
55 :     gvars: gvar list,
56 : blume 975 gfuns: gfun list,
57 :     enums: enum list }
58 : blume 1011
59 :     fun join (x: spec, y: spec) = let
60 :     fun uniq sel = let
61 :     fun loop ([], a) = rev a
62 :     | loop (h :: t, a) =
63 :     loop (t, if List.exists (fn x => sel x = sel h) a then a
64 :     else h :: a)
65 :     in
66 :     loop
67 :     end
68 :     in
69 :     { structs = uniq #tag (#structs x, #structs y),
70 :     unions = uniq #tag (#unions x, #unions y),
71 :     gtys = uniq #name (#gtys x, #gtys y),
72 :     gvars = uniq #name (#gvars x, #gvars y),
73 :     gfuns = uniq #name (#gfuns x, #gfuns y),
74 :     enums = uniq #tag (#enums x, #enums y) } : spec
75 :     end
76 :    
77 :     val empty : spec = { structs = [], unions = [], gtys = [], gvars = [],
78 :     gfuns = [], enums = [] }
79 : blume 828 end

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