@@ -653,6 +653,24 @@ JNIEXPORT void JNICALL Java_com_sri_yices_Yices_resetError(JNIEnv *, jclass) {
653653 yices_clear_error ();
654654}
655655
656+ JNIEXPORT jobject JNICALL Java_com_sri_yices_Yices_errorReport (JNIEnv *env, jclass) {
657+ try {
658+ error_report_t * report = yices_error_report ();
659+ // now construct new ErrorReport(report->code, report->line, report->column, report->term1, report->type1, report->term2, report->type2, report->badval);
660+ jclass cls = env->FindClass (" com/sri/yices/ErrorReport" );
661+ if (cls != NULL ) {
662+ jmethodID constructor = env->GetMethodID (cls, " <init>" , " (IIIIIIIJ)V" );
663+ if (constructor != NULL ) {
664+ jobject object = env->NewObject (cls, constructor, report->code , report->line , report->column , report->term1 , report->type1 , report->term2 , report->type2 , report->badval );
665+ return object;
666+ }
667+ }
668+ } catch (std::bad_alloc &ba) {
669+ out_of_mem_exception (env);
670+ }
671+ return 0 ;
672+ }
673+
656674
657675// to test the throw exception code
658676JNIEXPORT void JNICALL Java_com_sri_yices_Yices_testException (JNIEnv *env, jclass) {
@@ -3255,6 +3273,39 @@ JNIEXPORT void JNICALL Java_com_sri_yices_Yices_freeParamRecord(JNIEnv *env, jcl
32553273 yices_free_param_record (reinterpret_cast <param_t *>(param));
32563274}
32573275
3276+ // since 2.?.? (new in the 2.6.4 bindings)
3277+ JNIEXPORT jintArray JNICALL Java_com_sri_yices_Yices_getUnsatCore (JNIEnv *env, jclass, jlong ctx) {
3278+ jintArray retval = NULL ;
3279+ int32_t code;
3280+ term_vector_t aux;
3281+ try {
3282+ yices_init_term_vector (&aux);
3283+ code = yices_get_unsat_core (reinterpret_cast <context_t *>(ctx), &aux);
3284+ if (code >= 0 ) {
3285+ retval = convertToIntArray (env, aux.size , aux.data );
3286+ }
3287+ yices_delete_term_vector (&aux);
3288+ } catch (std::bad_alloc &ba) {
3289+ out_of_mem_exception (env);
3290+ }
3291+ return retval;
3292+ }
3293+
3294+ // since 2.6.4
3295+ JNIEXPORT jint JNICALL Java_com_sri_yices_Yices_getModelInterpolant (JNIEnv *env, jclass, jlong ctx) {
3296+ #ifdef YICES_AT_LEAST_2_6_4
3297+ jint result = -1 ;
3298+ try {
3299+ result = yices_get_model_interpolant (reinterpret_cast <context_t *>(ctx));
3300+ } catch (std::bad_alloc &ba) {
3301+ out_of_mem_exception (env);
3302+ }
3303+ return result;
3304+ #else
3305+ return -1 ;
3306+ #endif
3307+ }
3308+
32583309
32593310/*
32603311 * MODELS
@@ -3270,6 +3321,21 @@ JNIEXPORT jlong JNICALL Java_com_sri_yices_Yices_getModel(JNIEnv *env, jclass, j
32703321 return result;
32713322}
32723323
3324+ // since 2.6.4
3325+ JNIEXPORT jlong JNICALL Java_com_sri_yices_Yices_newModel (JNIEnv *env, jclass){
3326+ #ifdef YICES_AT_LEAST_2_6_4
3327+ jlong result = 0 ; // NULL pointer
3328+ try {
3329+ result = reinterpret_cast <jlong>(yices_new_model ());
3330+ } catch (std::bad_alloc &ba) {
3331+ out_of_mem_exception (env);
3332+ }
3333+ return result;
3334+ #else
3335+ return NULL ;
3336+ #endif
3337+ }
3338+
32733339JNIEXPORT void JNICALL Java_com_sri_yices_Yices_freeModel (JNIEnv *env, jclass, jlong model) {
32743340 yices_free_model (reinterpret_cast <model_t *>(model));
32753341}
@@ -3299,6 +3365,103 @@ JNIEXPORT jlong JNICALL Java_com_sri_yices_Yices_modelFromMap(JNIEnv *env, jclas
32993365 return result;
33003366}
33013367
3368+ // Since 2.6.4
3369+ JNIEXPORT jint JNICALL Java_com_sri_yices_Yices_modelSetBool (JNIEnv *env, jclass, jlong model, jint var, jint val) {
3370+ #ifdef YICES_AT_LEAST_2_6_4
3371+ jint result = -1 ;
3372+ try {
3373+ result = yices_model_set_bool (reinterpret_cast <model_t *>(model), reinterpret_cast <term_t >(var), reinterpret_cast <int32_t >(val));
3374+ } catch (std::bad_alloc &ba) {
3375+ out_of_mem_exception (env);
3376+ }
3377+ return result;
3378+ #else
3379+ return -1 ;
3380+ #endif
3381+ }
3382+
3383+ // Since 2.6.4
3384+ JNIEXPORT jint JNICALL Java_com_sri_yices_Yices_modelSetInteger (JNIEnv *env, jclass, jlong model, jint var, jlong val){
3385+ #ifdef YICES_AT_LEAST_2_6_4
3386+ jint result = -1 ;
3387+ try {
3388+ result = yices_model_set_int64 (reinterpret_cast <model_t *>(model), reinterpret_cast <term_t >(var), val);
3389+ } catch (std::bad_alloc &ba) {
3390+ out_of_mem_exception (env);
3391+ }
3392+ return result;
3393+ #else
3394+ return -1 ;
3395+ #endif
3396+ }
3397+
3398+ // Since 2.6.4
3399+ JNIEXPORT jint JNICALL Java_com_sri_yices_Yices_modelSetRational (JNIEnv *env, jclass, jlong model, jint var, jlong num, jlong den) {
3400+ #ifdef YICES_AT_LEAST_2_6_4
3401+ jint result = -1 ;
3402+ try {
3403+ result = yices_model_set_rational64 (reinterpret_cast <model_t *>(model), reinterpret_cast <term_t >(var), num, den);
3404+ } catch (std::bad_alloc &ba) {
3405+ out_of_mem_exception (env);
3406+ }
3407+ return result;
3408+ #else
3409+ return -1 ;
3410+ #endif
3411+ }
3412+
3413+ // Since 2.6.4
3414+ JNIEXPORT jint JNICALL Java_com_sri_yices_Yices_modelSetBVInteger (JNIEnv *env, jclass, jlong model, jint var, jlong val) {
3415+ #ifdef YICES_AT_LEAST_2_6_4
3416+ jint result = -1 ;
3417+ try {
3418+ result = yices_model_set_bv_uint64 (reinterpret_cast <model_t *>(model), reinterpret_cast <term_t >(var), val);
3419+ } catch (std::bad_alloc &ba) {
3420+ out_of_mem_exception (env);
3421+ }
3422+ return result;
3423+ #else
3424+ return -1 ;
3425+ #endif
3426+ }
3427+
3428+ // Since 2.6.4
3429+ JNIEXPORT jint JNICALL Java_com_sri_yices_Yices_modelSetBVFromArray (JNIEnv *env, jclass, jlong model, jint var, jintArray arr) {
3430+ #ifdef YICES_AT_LEAST_2_6_4
3431+ jint result = -1 ;
3432+ jsize n = env->GetArrayLength (arr);
3433+ if (n == 0 ) {
3434+ return result;
3435+ }
3436+ assert (n > 0 );
3437+ int32_t *vals = array2int32 (env, arr, NULL );
3438+ try {
3439+ result = yices_model_set_bv_from_array (reinterpret_cast <model_t *>(model), reinterpret_cast <term_t >(var), n, vals);
3440+ } catch (std::bad_alloc &ba) {
3441+ out_of_mem_exception (env);
3442+ }
3443+ release_int32_elems (env, arr, vals);
3444+ return result;
3445+ #else
3446+ return -1 ;
3447+ #endif
3448+ }
3449+
3450+ // since 2.?.? (new in 2.6.4 bindings)
3451+ JNIEXPORT jintArray JNICALL Java_com_sri_yices_Yices_modelCollectDefinedTerms (JNIEnv *env, jclass, jlong model) {
3452+ term_vector_t aux;
3453+ jintArray result = NULL ;
3454+ try {
3455+ yices_init_term_vector (&aux);
3456+ yices_model_collect_defined_terms (reinterpret_cast <model_t *>(model), &aux);
3457+ result = convertToIntArray (env, aux.size , aux.data );
3458+ yices_delete_term_vector (&aux);
3459+ } catch (std::bad_alloc &ba) {
3460+ out_of_mem_exception (env);
3461+ }
3462+ return result;
3463+ }
3464+
33023465// returns -1 for error, 0 for false, +1 for true
33033466JNIEXPORT jint JNICALL Java_com_sri_yices_Yices_getBoolValue (JNIEnv *env, jclass, jlong model, jint t) {
33043467 int32_t val = -1 ;
0 commit comments