Skip to content

Commit 34d1cd2

Browse files
committed
Add Windows JNI context check exports
1 parent 96ca981 commit 34d1cd2

1 file changed

Lines changed: 72 additions & 0 deletions

File tree

src/main/java/com/sri/yices/yicesJNIforWindows.cpp

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3133,6 +3133,78 @@ JNIEXPORT jint JNICALL Java_com_sri_yices_Yices_checkContext(JNIEnv *env, jclass
31333133
return result;
31343134
}
31353135

3136+
//Since 2.?.? (new in the 2.6.4 bindings)
3137+
JNIEXPORT jint JNICALL Java_com_sri_yices_Yices_checkContextWithAssumptions(JNIEnv *env, jclass, jlong ctx, jlong params, jintArray t) {
3138+
jsize n = env->GetArrayLength(t);
3139+
term_t *a = array2terms(env, t, NULL);
3140+
jint result = -1;
3141+
if (a == NULL) {
3142+
out_of_mem_exception(env);
3143+
} else {
3144+
try {
3145+
result = yices_check_context_with_assumptions(reinterpret_cast<context_t*>(ctx), reinterpret_cast<param_t*>(params), n, a);
3146+
} catch (std::bad_alloc &ba) {
3147+
out_of_mem_exception(env);
3148+
}
3149+
}
3150+
return result;
3151+
}
3152+
3153+
// since 2.6.4
3154+
JNIEXPORT jint JNICALL Java_com_sri_yices_Yices_checkContextWithModel(JNIEnv *env, jclass, jlong ctx, jlong params, jlong model, jintArray t){
3155+
#ifdef YICES_AT_LEAST_2_6_4
3156+
jint result = -1;
3157+
jsize n = env->GetArrayLength(t);
3158+
term_t *a = array2terms(env, t, NULL);
3159+
if (a == NULL) {
3160+
out_of_mem_exception(env);
3161+
} else {
3162+
try {
3163+
result = yices_check_context_with_model(reinterpret_cast<context_t*>(ctx), reinterpret_cast<param_t*>(params), reinterpret_cast<model_t*>(model), n, a);
3164+
} catch (std::bad_alloc &ba) {
3165+
out_of_mem_exception(env);
3166+
}
3167+
}
3168+
return result;
3169+
#else
3170+
return -1;
3171+
#endif
3172+
}
3173+
3174+
// since 2.6.4
3175+
JNIEXPORT jint JNICALL Java_com_sri_yices_Yices_checkContextWithInterpolation(JNIEnv *env, jclass, jlong ctxA, jlong ctxB, jlong params, jlongArray marr, jintArray interpolant){
3176+
#ifdef YICES_AT_LEAST_2_6_4
3177+
jint result = -1;
3178+
jsize i = (interpolant == 0 ? 0 : env->GetArrayLength(interpolant));
3179+
if (i < 1) {
3180+
return result;
3181+
}
3182+
3183+
jsize n = (marr == 0 ? 0 : env->GetArrayLength(marr));
3184+
int32_t build_model = (n > 0);
3185+
interpolation_context_t ctx;
3186+
ctx.ctx_A = reinterpret_cast<context_t*>(ctxA);
3187+
ctx.ctx_B = reinterpret_cast<context_t*>(ctxB);
3188+
ctx.interpolant = 0;
3189+
ctx.model = NULL;
3190+
try {
3191+
result = yices_check_context_with_interpolation(&ctx, reinterpret_cast<param_t*>(params), build_model);
3192+
if (result == YICES_STATUS_UNSAT) {
3193+
env->SetIntArrayRegion(interpolant, 0, 1, &ctx.interpolant);
3194+
} else if(build_model && result == YICES_STATUS_SAT ) {
3195+
model_t *model = ctx.model;
3196+
jlong mdl = reinterpret_cast<jlong>(model);
3197+
env->SetLongArrayRegion(marr, 0, 1, &mdl);
3198+
}
3199+
} catch (std::bad_alloc &ba) {
3200+
out_of_mem_exception(env);
3201+
}
3202+
return result;
3203+
#else
3204+
return -1;
3205+
#endif
3206+
}
3207+
31363208
JNIEXPORT jint JNICALL Java_com_sri_yices_Yices_assertBlockingClause(JNIEnv *env, jclass, jlong ctx) {
31373209
jint result = -1;
31383210

0 commit comments

Comments
 (0)