3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-23 00:55:31 +00:00

ML API bugfixes

Signed-off-by: Christoph M. Wintersteiger <cwinter@microsoft.com>
This commit is contained in:
Christoph M. Wintersteiger 2012-12-20 04:10:38 +00:00
parent 50560ba791
commit 1685e3dd6f
3 changed files with 99 additions and 64 deletions

View file

@ -1,4 +1,3 @@
############################################
# Copyright (c) 2012 Microsoft Corporation
#
@ -328,16 +327,12 @@ def param2ml(p):
if k == OUT:
if param_type(p) == INT or param_type(p) == UINT or param_type(p) == INT64 or param_type(p) == UINT64:
return "int"
elif param_type(p) == INT64 or param_type(p) == UINT64 or param_type(p) >= FIRST_OBJ_ID:
return "int"
elif param_type(p) == STRING:
return "string"
else:
return "ptr"
elif k == IN_ARRAY or k == INOUT_ARRAY or k == OUT_ARRAY:
return "%s array" % type2ml(param_type(p))
elif k == OUT_MANAGED_ARRAY:
return "%s array" % type2ml(param_type(p));
else:
return type2ml(param_type(p))
@ -1131,9 +1126,16 @@ def mk_ml():
ml_native.write('%s -> ' % param2ml(p))
if len(op) > 0:
ml_native.write('(')
ml_native.write('%s' % type2ml(result))
first = True
if result != VOID or len(op) == 0:
ml_native.write('%s' % type2ml(result))
first = False
for p in op:
ml_native.write(' * %s' % param2ml(p))
if first:
first = False
else:
ml_native.write(' * ')
ml_native.write('%s' % param2ml(p))
if len(op) > 0:
ml_native.write(')')
ml_native.write('\n')
@ -1160,11 +1162,13 @@ def mk_ml():
i = i + 1
ml_native.write(' = \n')
ml_native.write(' ')
if result == VOID:
if result == VOID and len(op) == 0:
ml_native.write('let _ = ')
else:
ml_native.write('let res = ')
ml_native.write('(ML2C.n_%s' % (ml_method_name(name)))
if len(ip) == 0:
ml_native.write(' ()')
first = True
i = 0;
for p in params:
@ -1177,7 +1181,7 @@ def mk_ml():
ml_native.write(' if err <> OK then\n')
ml_native.write(' raise (Exception (ML2C.n_get_error_msg_ex a0 (error_code2int err)))\n')
ml_native.write(' else\n')
if result == VOID:
if result == VOID and len(op) == 0:
ml_native.write(' ()\n')
else:
ml_native.write(' res\n')