예제 #1
0
void
verify_bottom_code (gcc_jit_context *ctxt, gcc_jit_result *result)
{
  typedef int (*fn_type) (double a, double b, double c,
			  double *r1, double *r2);

  CHECK_NON_NULL (result);

  fn_type test_quadratic =
    (fn_type)gcc_jit_result_get_code (result, "test_quadratic");
  CHECK_NON_NULL (test_quadratic);

  /* Verify that the code correctly solves quadratic equations.  */
  double r1, r2;

  /* This one has two solutions: */
  CHECK_VALUE (test_quadratic (1, 3, -4, &r1, &r2), 2);
  CHECK_VALUE (r1, 1);
  CHECK_VALUE (r2, -4);

  /* This one has one solution: */
  CHECK_VALUE (test_quadratic (4, 4, 1, &r1, &r2), 1);
  CHECK_VALUE (r1, -0.5);

  /* This one has no real solutions: */
  CHECK_VALUE (test_quadratic (4, 1, 1, &r1, &r2), 0);
}
예제 #2
0
static void
verify_test_of_builtin_trig (gcc_jit_context *ctxt, gcc_jit_result *result)
{
  typedef double (*fn_type) (double);
  CHECK_NON_NULL (result);

  fn_type test_of_builtin_trig =
    (fn_type)gcc_jit_result_get_code (result, "test_of_builtin_trig");
  CHECK_NON_NULL (test_of_builtin_trig);

  /* Verify that it correctly computes
        sin (2 * theta)
     (perhaps calling sin and cos). */
  CHECK_DOUBLE_VALUE (test_of_builtin_trig (0.0         ),  0.0);
  CHECK_DOUBLE_VALUE (test_of_builtin_trig (M_PI_4      ),  1.0);
  CHECK_DOUBLE_VALUE (test_of_builtin_trig (M_PI_2      ),  0.0);
  CHECK_DOUBLE_VALUE (test_of_builtin_trig (M_PI_4 * 3.0), -1.0);
  CHECK_DOUBLE_VALUE (test_of_builtin_trig (M_PI        ),  0.0);

  /* PR jit/64020:
     The "sincos" pass merges sin/cos calls into the cexpi builtin.
     Verify that a dump of the "sincos" pass was provided, and that it
     shows a call to the cexpi builtin on a SSA name of "theta".  */
  CHECK_NON_NULL (trig_sincos_dump);
  CHECK_STRING_CONTAINS (trig_sincos_dump, " = __builtin_cexpi (theta_");
  free (trig_sincos_dump);

  /* Similarly, verify that the statistics dump was provided, and that
     it shows the sincos optimization.  */
  CHECK_NON_NULL (trig_statistics_dump);
  CHECK_STRING_CONTAINS (
    trig_statistics_dump,
    "sincos \"sincos statements inserted\" \"test_of_builtin_trig\" 1");
  free (trig_statistics_dump);
}
예제 #3
0
extern void
verify_code (gcc_jit_context *ctxt, gcc_jit_result *result)
{
  typedef void (*fn_type) (const char *);
  CHECK_NON_NULL (result);
  fn_type hello_world =
    (fn_type)gcc_jit_result_get_code (result, "hello_world");
  CHECK_NON_NULL (hello_world);
  hello_world ("world");
  fflush (stdout);
}
예제 #4
0
void
verify_code (gcc_jit_context *ctxt, gcc_jit_result *result)
{
  CHECK_NON_NULL (result);

  typedef int (*my_fn_type) (void);
  CHECK_NON_NULL (result);
  my_fn_type my_fn =
    (my_fn_type)gcc_jit_result_get_code (result, long_names.fn_name);
  CHECK_NON_NULL (my_fn);
  int val = my_fn ();
  CHECK_VALUE (val, 42);
}
예제 #5
0
static void
verify_void_return (gcc_jit_context *ctxt, gcc_jit_result *result)
{
  typedef void (*fn_type) (int *);
  CHECK_NON_NULL (result);

  fn_type test_of_void_return =
    (fn_type)gcc_jit_result_get_code (result, "test_of_void_return");
  CHECK_NON_NULL (test_of_void_return);

  int i;
  test_of_void_return (&i);
  CHECK_VALUE (i, 1); /* ensure correct value was written back */
}
예제 #6
0
static void
verify_test_of_builtin_strcmp (gcc_jit_context *ctxt, gcc_jit_result *result)
{
  typedef int (*fn_type) (const char *, const char *);
  CHECK_NON_NULL (result);

  fn_type test_of_builtin_strcmp =
    (fn_type)gcc_jit_result_get_code (result, "test_of_builtin_strcmp");
  CHECK_NON_NULL (test_of_builtin_strcmp);

  /* Verify that it correctly called strcmp.  */
  CHECK_VALUE (test_of_builtin_strcmp ("foo", "foo"), 0);
  CHECK (test_of_builtin_strcmp ("foo", "bar") > 0);
  CHECK (test_of_builtin_strcmp ("bar", "foo") < 0);
}
예제 #7
0
 Z3_bool Z3_API Z3_fpa_get_numeral_sign(Z3_context c, Z3_ast t, int * sgn) {
     Z3_TRY;
     LOG_Z3_fpa_get_numeral_sign(c, t, sgn);
     RESET_ERROR_CODE();
     CHECK_NON_NULL(t, 0);
     CHECK_VALID_AST(t, 0);
     if (sgn == nullptr) {
         SET_ERROR_CODE(Z3_INVALID_ARG);
         return 0;
     }
     ast_manager & m = mk_c(c)->m();
     mpf_manager & mpfm = mk_c(c)->fpautil().fm();
     family_id fid = mk_c(c)->get_fpa_fid();
     fpa_decl_plugin * plugin = (fpa_decl_plugin*)m.get_plugin(fid);
     expr * e = to_expr(t);
     if (!is_app(e) || is_app_of(e, fid, OP_FPA_NAN) || !is_fp(c, t)) {
         SET_ERROR_CODE(Z3_INVALID_ARG);
         return 0;
     }
     scoped_mpf val(mpfm);
     bool r = plugin->is_numeral(to_expr(t), val);
     if (!r || mpfm.is_nan(val)) {
         SET_ERROR_CODE(Z3_INVALID_ARG);
         return 0;
     }
     *sgn = mpfm.sgn(val);
     return r;
     Z3_CATCH_RETURN(0);
 }
예제 #8
0
파일: api_model.cpp 프로젝트: kayceesrk/Z3
 Z3_ast Z3_API Z3_get_model_func_entry_value(Z3_context c,
         Z3_model m,
         unsigned i,
         unsigned j) {
     Z3_TRY;
     LOG_Z3_get_model_func_entry_value(c, m, i, j);
     RESET_ERROR_CODE();
     CHECK_NON_NULL(m, 0);
     if (j >= get_model_func_num_entries_core(c, m, i)) {
         SET_ERROR_CODE(Z3_IOB);
         RETURN_Z3(0);
     }
     Z3_func_decl d = get_model_func_decl_core(c, m, i);
     if (d) {
         model * _m = to_model_ref(m);
         func_interp * g = _m->get_func_interp(to_func_decl(d));
         if (g && j < g->num_entries()) {
             func_entry const* e = g->get_entry(j);
             expr* a = e->get_result();
             mk_c(c)->save_ast_trail(a);
             RETURN_Z3(of_ast(a));
         }
         SET_ERROR_CODE(Z3_IOB);
         RETURN_Z3(0);
     }
     RETURN_Z3(0);
     Z3_CATCH_RETURN(0);
 }
예제 #9
0
 Z3_ast Z3_API Z3_fpa_get_numeral_sign_bv(Z3_context c, Z3_ast t) {
     Z3_TRY;
     LOG_Z3_fpa_get_numeral_sign_bv(c, t);
     RESET_ERROR_CODE();
     CHECK_NON_NULL(t, nullptr);
     CHECK_VALID_AST(t, nullptr);
     ast_manager & m = mk_c(c)->m();
     mpf_manager & mpfm = mk_c(c)->fpautil().fm();
     family_id fid = mk_c(c)->get_fpa_fid();
     fpa_decl_plugin * plugin = (fpa_decl_plugin*)m.get_plugin(fid);
     api::context * ctx = mk_c(c);
     expr * e = to_expr(t);
     if (!is_app(e) || is_app_of(e, fid, OP_FPA_NAN) || !is_fp(c, t)) {
         SET_ERROR_CODE(Z3_INVALID_ARG);
         RETURN_Z3(nullptr);
     }
     scoped_mpf val(mpfm);
     bool r = plugin->is_numeral(to_expr(t), val);
     if (!r || mpfm.is_nan(val)) {
         SET_ERROR_CODE(Z3_INVALID_ARG);
         return nullptr;
     }
     app * a;
     if (mpfm.is_pos(val))
         a = ctx->bvutil().mk_numeral(0, 1);
     else
         a = ctx->bvutil().mk_numeral(1, 1);
     mk_c(c)->save_ast_trail(a);
     RETURN_Z3(of_expr(a));
     Z3_CATCH_RETURN(nullptr);
 }
예제 #10
0
 Z3_ast Z3_API Z3_fpa_get_numeral_significand_bv(Z3_context c, Z3_ast t) {
     Z3_TRY;
     LOG_Z3_fpa_get_numeral_significand_bv(c, t);
     RESET_ERROR_CODE();
     CHECK_NON_NULL(t, nullptr);
     CHECK_VALID_AST(t, nullptr);
     ast_manager & m = mk_c(c)->m();
     mpf_manager & mpfm = mk_c(c)->fpautil().fm();
     unsynch_mpq_manager & mpqm = mpfm.mpq_manager();
     family_id fid = mk_c(c)->get_fpa_fid();
     fpa_decl_plugin * plugin = (fpa_decl_plugin*)m.get_plugin(fid);
     SASSERT(plugin != 0);
     expr * e = to_expr(t);
     if (!is_app(e) || is_app_of(e, fid, OP_FPA_NAN) || !is_fp(c, t)) {
         SET_ERROR_CODE(Z3_INVALID_ARG);
         RETURN_Z3(nullptr);
     }
     scoped_mpf val(mpfm);
     bool r = plugin->is_numeral(e, val);
     if (!r || !(mpfm.is_normal(val) || mpfm.is_denormal(val) || mpfm.is_zero(val) || mpfm.is_inf(val))) {
         SET_ERROR_CODE(Z3_INVALID_ARG);
         RETURN_Z3(nullptr);
     }
     unsigned sbits = val.get().get_sbits();
     scoped_mpq q(mpqm);
     mpqm.set(q, mpfm.sig(val));
     if (mpfm.is_inf(val)) mpqm.set(q, 0);
     app * a = mk_c(c)->bvutil().mk_numeral(q.get(), sbits-1);
     mk_c(c)->save_ast_trail(a);
     RETURN_Z3(of_expr(a));
     Z3_CATCH_RETURN(nullptr);
 }
예제 #11
0
 bool Z3_API Z3_model_has_interp(Z3_context c, Z3_model m, Z3_func_decl a) {
     Z3_TRY;
     LOG_Z3_model_has_interp(c, m, a);
     CHECK_NON_NULL(m, 0);
     return to_model_ref(m)->has_interpretation(to_func_decl(a));
     Z3_CATCH_RETURN(false);
 }
예제 #12
0
 Z3_string Z3_API Z3_fpa_get_numeral_significand_string(Z3_context c, Z3_ast t) {
     Z3_TRY;
     LOG_Z3_fpa_get_numeral_significand_string(c, t);
     RESET_ERROR_CODE();
     CHECK_NON_NULL(t, nullptr);
     CHECK_VALID_AST(t, nullptr);
     ast_manager & m = mk_c(c)->m();
     mpf_manager & mpfm = mk_c(c)->fpautil().fm();
     unsynch_mpq_manager & mpqm = mpfm.mpq_manager();
     family_id fid = mk_c(c)->get_fpa_fid();
     fpa_decl_plugin * plugin = (fpa_decl_plugin*)m.get_plugin(fid);
     SASSERT(plugin != 0);
     expr * e = to_expr(t);
     if (!is_app(e) || is_app_of(e, fid, OP_FPA_NAN) || !is_fp(c, t)) {
         SET_ERROR_CODE(Z3_INVALID_ARG);
         return "";
     }
     scoped_mpf val(mpfm);
     bool r = plugin->is_numeral(e, val);
     if (!r || !(mpfm.is_normal(val) || mpfm.is_denormal(val) || mpfm.is_zero(val) || mpfm.is_inf(val))) {
         SET_ERROR_CODE(Z3_INVALID_ARG);
         return "";
     }
     unsigned sbits = val.get().get_sbits();
     scoped_mpq q(mpqm);
     mpqm.set(q, mpfm.sig(val));
     if (!mpfm.is_denormal(val)) mpqm.add(q, mpfm.m_powers2(sbits - 1), q);
     mpqm.div(q, mpfm.m_powers2(sbits - 1), q);
     if (mpfm.is_inf(val)) mpqm.set(q, 0);
     std::stringstream ss;
     mpqm.display_decimal(ss, q, sbits);
     return mk_c(c)->mk_external_string(ss.str());
     Z3_CATCH_RETURN("");
 }
예제 #13
0
void
verify_code (gcc_jit_context *ctxt, gcc_jit_result *result)
{
  typedef double (*test_nested_loops_fn_type) (int n, double *a, double *b);
  CHECK_NON_NULL (result);

  test_nested_loops_fn_type test_nested_loops =
    (test_nested_loops_fn_type)gcc_jit_result_get_code (result,
						     "test_nested_loops");
  CHECK_NON_NULL (test_nested_loops);
  double test_a[] = {1., 2., 3., 4., 5., 6., 7., 8., 9., 10.};
  double test_b[] = {5., 6., 7., 8., 9., 10., 1., 2., 3., 4.};
  double val = test_nested_loops (10, test_a, test_b);
  note ("test_nested_loops returned: %f", val);
  CHECK_VALUE (val, 3025.0);
}
예제 #14
0
void
verify_code (gcc_jit_context *ctxt, gcc_jit_result *result)
{
  CHECK_NON_NULL (result);
  /* We don't actually build any functions above;
     nothing more to verify.  */
}
예제 #15
0
 unsigned Z3_API Z3_model_get_num_funcs(Z3_context c, Z3_model m) {
     Z3_TRY;
     LOG_Z3_model_get_num_funcs(c, m);
     RESET_ERROR_CODE();
     CHECK_NON_NULL(m, 0);
     return to_model_ref(m)->get_num_functions();
     Z3_CATCH_RETURN(0);
 }
예제 #16
0
 unsigned Z3_API Z3_func_interp_get_arity(Z3_context c, Z3_func_interp f) {
     Z3_TRY;
     LOG_Z3_func_interp_get_arity(c, f);
     RESET_ERROR_CODE();
     CHECK_NON_NULL(f, 0);
     return to_func_interp_ref(f)->get_arity();
     Z3_CATCH_RETURN(0);
 }
예제 #17
0
파일: api_model.cpp 프로젝트: kayceesrk/Z3
 Z3_ast Z3_API Z3_func_interp_get_else(Z3_context c, Z3_func_interp f) {
     Z3_TRY;
     LOG_Z3_func_interp_get_else(c, f);
     RESET_ERROR_CODE();
     CHECK_NON_NULL(f, 0);
     expr * e = to_func_interp_ref(f)->get_else();
     RETURN_Z3(of_expr(e));
     Z3_CATCH_RETURN(0);
 }
예제 #18
0
void
verify_code (gcc_jit_context *ctxt, gcc_jit_result *result)
{
  typedef float (*fn_type) (int i);
  CHECK_NON_NULL (result);

  fn_type test_union =
    (fn_type)gcc_jit_result_get_code (result, "test_union");
  CHECK_NON_NULL (test_union);

  /* Call the JIT-generated function.  */
  float f_result = test_union (42);

  union int_or_float u;
  u.as_float = f_result;

  CHECK_VALUE (u.as_int, 42);
}
예제 #19
0
 Z3_func_decl get_model_func_decl_core(Z3_context c, Z3_model m, unsigned i) {
     CHECK_NON_NULL(m, nullptr);
     model * _m = to_model_ref(m);
     if (i >= _m->get_num_functions()) {
         SET_ERROR_CODE(Z3_IOB, nullptr);
         return nullptr;
     }
     return of_func_decl(_m->get_function(i));
 }
예제 #20
0
 Z3_bool Z3_API Z3_model_has_interp(Z3_context c, Z3_model m, Z3_func_decl a) {
     Z3_TRY;
     LOG_Z3_model_has_interp(c, m, a);
     CHECK_NON_NULL(m, 0);
     if (to_model_ref(m)->has_interpretation(to_func_decl(a))) {
         return Z3_TRUE;
     } else {
         return Z3_FALSE;
     }
     Z3_CATCH_RETURN(Z3_FALSE);
 }
예제 #21
0
void
verify_uint_overflow_fn (gcc_jit_result *jit_result,
			 const char *funcname,
			 unsigned int x, unsigned int y,
			 unsigned int expected_result,
			 int expected_ovf)
{
  CHECK_NON_NULL (jit_result);
  typedef unsigned int (*overflow_fn_type) (unsigned int, unsigned int, int *);
  overflow_fn_type fn =
    (overflow_fn_type)gcc_jit_result_get_code (jit_result, funcname);
  CHECK_NON_NULL (fn);

  /* Call the function:  */
  int actual_ovf = 0;
  unsigned int actual_result = fn (x, y, &actual_ovf);
  note ("%s (%d, %d) returned: %d with ovf: %d",
	funcname, x, y, actual_result, actual_ovf);
  CHECK_VALUE (actual_result, expected_result);
  CHECK_VALUE (actual_ovf, expected_ovf);
}
예제 #22
0
static void
verify_hidden_functions (gcc_jit_context *ctxt, gcc_jit_result *result)
{
  CHECK_NON_NULL (result);

  /* GCC_JIT_FUNCTION_INTERNAL and GCC_JIT_FUNCTION_ALWAYS_INLINE
     functions should not be accessible in the result.  */
  CHECK_VALUE (NULL, gcc_jit_result_get_code (result, "my_internal_mult"));
  CHECK_VALUE (NULL, gcc_jit_result_get_code (result, "my_always_inline_mult"));

  typedef double (*fn_type) (double);
  fn_type my_square_with_internal =
    (fn_type)gcc_jit_result_get_code (result, "my_square_with_internal");
  CHECK_NON_NULL (my_square_with_internal);
  CHECK_VALUE (my_square_with_internal (5.0), 25.0);

  fn_type my_square_with_always_inline =
    (fn_type)gcc_jit_result_get_code (result, "my_square_with_always_inline");
  CHECK_NON_NULL (my_square_with_always_inline);
  CHECK_VALUE (my_square_with_always_inline (5.0), 25.0);
}
예제 #23
0
 Z3_ast Z3_API Z3_func_interp_get_else(Z3_context c, Z3_func_interp f) {
     Z3_TRY;
     LOG_Z3_func_interp_get_else(c, f);
     RESET_ERROR_CODE();
     CHECK_NON_NULL(f, nullptr);
     expr * e = to_func_interp_ref(f)->get_else();
     if (e) {
         mk_c(c)->save_ast_trail(e);
     }
     RETURN_Z3(of_expr(e));
     Z3_CATCH_RETURN(nullptr);
 }
예제 #24
0
void
verify_code (gcc_jit_context *ctxt, gcc_jit_result *result)
{
  typedef void (*fn_type) (int);
  CHECK_NON_NULL (result);

  fn_type test_caller =
    (fn_type)gcc_jit_result_get_code (result, "test_caller");
  CHECK_NON_NULL (test_caller);

  called_with[0] = 0;
  called_with[1] = 0;
  called_with[2] = 0;

  /* Call the JIT-generated function.  */
  test_caller (5);

  /* Verify that it correctly called "called_function".  */
  CHECK_VALUE (called_with[0], 15);
  CHECK_VALUE (called_with[1], 20);
  CHECK_VALUE (called_with[2], 25);
}
예제 #25
0
 unsigned Z3_API Z3_fpa_get_sbits(Z3_context c, Z3_sort s) {
     Z3_TRY;
     LOG_Z3_fpa_get_sbits(c, s);
     RESET_ERROR_CODE();
     CHECK_NON_NULL(s, 0);
     CHECK_VALID_AST(s, 0);
     if (!is_fp_sort(c, s)) {
         SET_ERROR_CODE(Z3_INVALID_ARG);
         RETURN_Z3(0);
     }
     return mk_c(c)->fpautil().get_sbits(to_sort(s));
     Z3_CATCH_RETURN(0);
 }
예제 #26
0
파일: api_model.cpp 프로젝트: kayceesrk/Z3
 Z3_ast Z3_API Z3_model_get_const_interp(Z3_context c, Z3_model m, Z3_func_decl a) {
     Z3_TRY;
     LOG_Z3_model_get_const_interp(c, m, a);
     RESET_ERROR_CODE();
     CHECK_NON_NULL(m, 0);
     expr * r = to_model_ref(m)->get_const_interp(to_func_decl(a));
     if (!r) {
         SET_ERROR_CODE(Z3_INVALID_ARG);
         RETURN_Z3(0);
     }
     RETURN_Z3(of_expr(r));
     Z3_CATCH_RETURN(0);
 }
예제 #27
0
 Z3_ast_opt Z3_API Z3_model_get_const_interp(Z3_context c, Z3_model m, Z3_func_decl a) {
     Z3_TRY;
     LOG_Z3_model_get_const_interp(c, m, a);
     RESET_ERROR_CODE();
     CHECK_NON_NULL(m, nullptr);
     expr * r = to_model_ref(m)->get_const_interp(to_func_decl(a));
     if (!r) {
         RETURN_Z3(nullptr);
     }
     mk_c(c)->save_ast_trail(r);
     RETURN_Z3(of_expr(r));
     Z3_CATCH_RETURN(nullptr);
 }
예제 #28
0
파일: toyvm.c 프로젝트: KangDroid/gcc
static void
test_script (const char *scripts_dir, const char *script_name, int input,
	     int expected_result)
{
  char *script_path;
  toyvm_function *fn;
  int interpreted_result;
  toyvm_compiled_function *compiled_fn;
  toyvm_compiled_code code;
  int compiled_result;

  snprintf (test, sizeof (test), "toyvm.c: %s", script_name);

  script_path = (char *)malloc (strlen (scripts_dir)
				+ strlen (script_name) + 1);
  CHECK_NON_NULL (script_path);
  sprintf (script_path, "%s%s", scripts_dir, script_name);

  fn = toyvm_function_parse (script_path, script_name);
  CHECK_NON_NULL (fn);

  interpreted_result = toyvm_function_interpret (fn, input, NULL);
  CHECK_VALUE (interpreted_result, expected_result);

  compiled_fn = toyvm_function_compile (fn);
  CHECK_NON_NULL (compiled_fn);

  code = (toyvm_compiled_code)compiled_fn->cf_code;
  CHECK_NON_NULL (code);

  compiled_result = code (input);
  CHECK_VALUE (compiled_result, expected_result);

  gcc_jit_result_release (compiled_fn->cf_jit_result);
  free (compiled_fn);
  free (fn);
  free (script_path);
}
예제 #29
0
파일: api_model.cpp 프로젝트: kayceesrk/Z3
 Z3_bool Z3_API Z3_is_array_value(Z3_context c, Z3_model _m, Z3_ast _v, unsigned* size) {
     Z3_TRY;
     LOG_Z3_is_array_value(c, _m, _v, size);
     RESET_ERROR_CODE();
     CHECK_NON_NULL(_v, Z3_FALSE);
     CHECK_NON_NULL(_m, Z3_FALSE);
     model * m = to_model_ref(_m);
     expr * v = to_expr(_v);
     ast_manager& mgr = mk_c(c)->m();
     family_id afid = mk_c(c)->get_array_fid();
     unsigned sz = 0;
     array_util pl(mgr);
     if (pl.is_as_array(v)) {
         func_decl* f = pl.get_as_array_func_decl(to_app(v));
         func_interp* g = m->get_func_interp(f);
         sz = g->num_entries();
         if (sz > 0 && g->get_arity() != 1) {
             return Z3_FALSE;
         }
     }
     else {
         while (pl.is_store(v)) {
             if (to_app(v)->get_num_args() != 3) {
                 return Z3_FALSE;
             }
             v = to_app(v)->get_arg(0);
             ++sz;
         }
         if (!is_app_of(v, afid, OP_CONST_ARRAY)) {
             return Z3_FALSE;
         }
     }
     if (size) {
         *size = sz;
     }
     return Z3_TRUE;
     Z3_CATCH_RETURN(Z3_FALSE);
 }
예제 #30
0
파일: api_model.cpp 프로젝트: kayceesrk/Z3
 Z3_bool Z3_API Z3_model_eval(Z3_context c, Z3_model m, Z3_ast t, Z3_bool model_completion, Z3_ast * v) {
     Z3_TRY;
     LOG_Z3_model_eval(c, m, t, model_completion, v);
     if (v) *v = 0;
     RESET_ERROR_CODE();
     CHECK_NON_NULL(m, Z3_FALSE);
     model * _m = to_model_ref(m);
     expr_ref result(mk_c(c)->m());
     _m->eval(to_expr(t), result, model_completion == Z3_TRUE);
     mk_c(c)->save_ast_trail(result.get());
     *v = of_ast(result.get());
     RETURN_Z3_model_eval Z3_TRUE;
     Z3_CATCH_RETURN(0);
 }