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 1742 - (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 : mblume 1742 | SLONGLONG | ULONGLONG
17 : blume 828 | FLOAT | DOUBLE | VOIDPTR
18 :     | STRUCT of tag
19 :     | UNION of tag
20 : blume 1096 | ENUM of tag * bool
21 : blume 828 | FPTR of cft
22 :     | PTR of cobj
23 :     | ARR of { t: ctype, d: int, esz: int }
24 : blume 1096 | UNIMPLEMENTED of string
25 : blume 828
26 :     withtype cft = { args: ctype list, res: ctype option }
27 :    
28 :     and cobj = constness * ctype
29 :    
30 :     datatype fieldspec =
31 :     OFIELD of { offset: int, spec: cobj, synthetic: bool }
32 :     | SBF of { offset: int, constness: constness, bits: word, shift: word }
33 :     | UBF of { offset: int, constness: constness, bits: word, shift: word }
34 :    
35 :     type field = { name: string, spec: fieldspec }
36 :    
37 :     type s =
38 : blume 1011 { src: string,
39 : blume 1036 tag: tag, anon: bool, size: word, fields: field list,
40 :     exclude: bool }
41 : blume 828 type u =
42 : blume 1011 { src: string,
43 : mblume 1548 tag: tag, anon: bool, size: word, all: field list,
44 : blume 1036 exclude: bool }
45 : blume 828
46 : blume 1011 type gvar = { src: string, name: string, spec: cobj }
47 : blume 828
48 : blume 1011 type gfun = { src: string,
49 :     name: string, spec: cft, argnames: string list option }
50 : blume 828
51 : blume 1011 type gty = { src: string, name: string, spec: ctype }
52 : blume 828
53 : blume 1011 type enumval = { name: string, spec: LargeInt.int }
54 : blume 975
55 : blume 1096 type enum = { src: string,
56 :     tag: tag, anon: bool, descr: string, spec: enumval list,
57 :     exclude: bool }
58 : blume 1011
59 : blume 828 type spec = { structs: s list,
60 :     unions: u list,
61 :     gtys: gty list,
62 :     gvars: gvar list,
63 : blume 975 gfuns: gfun list,
64 :     enums: enum list }
65 : blume 1011
66 :     fun join (x: spec, y: spec) = let
67 :     fun uniq sel = let
68 :     fun loop ([], a) = rev a
69 :     | loop (h :: t, a) =
70 : blume 1062 loop (t, if List.exists
71 :     (fn x => (sel x : string) = sel h) a then a
72 : blume 1011 else h :: a)
73 :     in
74 :     loop
75 :     end
76 :     in
77 :     { structs = uniq #tag (#structs x, #structs y),
78 :     unions = uniq #tag (#unions x, #unions y),
79 :     gtys = uniq #name (#gtys x, #gtys y),
80 :     gvars = uniq #name (#gvars x, #gvars y),
81 :     gfuns = uniq #name (#gfuns x, #gfuns y),
82 :     enums = uniq #tag (#enums x, #enums y) } : spec
83 :     end
84 :    
85 :     val empty : spec = { structs = [], unions = [], gtys = [], gvars = [],
86 :     gfuns = [], enums = [] }
87 : blume 828 end

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