@@ -9,7 +9,8 @@ let typtbl = H.create 117
9
9
let _ =
10
10
H. add typtbl " int" " int" ;
11
11
H. add typtbl " void" " unit" ;
12
- H. add typtbl " float" " double" ;
12
+ H. add typtbl " float" " real" ;
13
+ H. add typtbl " Z3_string" " string" ;
13
14
H. add typtbl " ptr" " MLton.Pointer.t"
14
15
15
16
type varinfo = {mltyp : string ; args : string }
@@ -18,9 +19,9 @@ let vartbl = H.create 1009
18
19
19
20
let mkFunTy (argTy ,resTy ) = argTy ^ " -> " ^ resTy
20
21
21
- let mkTupleTy tys = " ( " ^ ( match tys with
22
- | [] -> " "
23
- | x ::xs -> List. fold_left (fun acc ty ->
22
+ let mkTupleTy tys = match tys with
23
+ | [] -> H. find typtbl " void "
24
+ | x ::xs -> " ( " ^ ( List. fold_left (fun acc ty ->
24
25
acc^ " * " ^ ty) x xs)^ " )"
25
26
26
27
let rec maptype typ = match typ with
@@ -43,12 +44,16 @@ let rec maptype typ = match typ with
43
44
| TComp _ | TEnum _ | TBuiltin_va_list _ ->
44
45
(E. log " Unknown type : %a\n " d_type typ; " Tunknown" )
45
46
47
+ let sanitize name = match name with
48
+ | "val" | "ref" | "let" | "in" | "end" | "fun" -> name^ " '"
49
+ | _ -> name
50
+
46
51
let mapargs typ = match typ with
47
52
| TFun (_ ,None,_ ,_ ) -> " ()"
48
53
| TFun (_ ,Some argTys ,_ ,_ ) -> " (" ^ (match argTys with
49
54
[] -> " "
50
55
| (x ,_ ,_ )::xs -> List. fold_left (fun acc (a ,b ,c ) ->
51
- acc^ " ," ^ a) x xs)^ " )"
56
+ acc^ " ," ^ (sanitize a)) (sanitize x) xs)^ " )"
52
57
53
58
let globalFolder x glob = match glob with
54
59
| GVarDecl ({vname =vname ;vtype =vtype } ,_ ) ->
@@ -94,10 +99,12 @@ let makeStructDoc () =
94
99
then myconcat [text (" type " ^ mlTy^ " = MLton.Pointer.t" );
95
100
line; doc]
96
101
else doc) typtbl nil in
102
+ let handl = text " val hndl = DynLink.dlopen
103
+ (\" libz3.dylib\" , DynLink.RTLD_LAZY);" in
97
104
let fundecs = H. fold (fun name {mltyp =typ ;args =args } doc ->
98
105
myconcat [doc;line;instantiateFunDec (name,args,typ)])
99
106
vartbl nil in
100
- let decs = myconcat [typedecs; line; fundecs] in
107
+ let decs = myconcat [typedecs; line; handl; line; fundecs] in
101
108
let footer = text " end" in
102
109
let doc = myconcat [header; indent 2 decs; footer] in
103
110
let outf = open_out " z3_ffi.sml" in
0 commit comments