@@ -2630,6 +2630,120 @@ JNIEXPORT jint JNICALL Java_com_sri_yices_Yices_termProjArg(JNIEnv *env, jclass,
26302630 return yices_proj_arg (x);
26312631}
26322632
2633+ JNIEXPORT jbyteArray JNICALL Java_com_sri_yices_Yices_sumComponentNumAsBytes (JNIEnv *env, jclass, jint x, jint idx) {
2634+ jbyteArray result = NULL ;
2635+ mpq_t q;
2636+ jint t = -1 ;
2637+
2638+ mpq_init (q);
2639+ if (yices_sum_component (x, idx, q, &t) >= 0 ) {
2640+ result = mpz_to_byte_array (env, mpq_numref (q));
2641+ }
2642+ mpq_clear (q);
2643+
2644+ return result;
2645+ }
2646+
2647+ JNIEXPORT jbyteArray JNICALL Java_com_sri_yices_Yices_sumComponentDenAsBytes (JNIEnv *env, jclass, jint x, jint idx) {
2648+ jbyteArray result = NULL ;
2649+ mpq_t q;
2650+ jint t = -1 ;
2651+
2652+ mpq_init (q);
2653+ if (yices_sum_component (x, idx, q, &t) >= 0 ) {
2654+ result = mpz_to_byte_array (env, mpq_denref (q));
2655+ }
2656+ mpq_clear (q);
2657+
2658+ return result;
2659+ }
2660+
2661+ JNIEXPORT jint JNICALL Java_com_sri_yices_Yices_sumComponentTerm (JNIEnv *env, jclass, jint x, jint idx) {
2662+ jint result = -1 ;
2663+ mpq_t q;
2664+
2665+ mpq_init (q);
2666+ yices_sum_component (x, idx, q, &result);
2667+ mpq_clear (q);
2668+
2669+ return result;
2670+ }
2671+
2672+ JNIEXPORT jbooleanArray JNICALL Java_com_sri_yices_Yices_bvSumComponentFactor (JNIEnv *env, jclass, jint x, jint idx) {
2673+ jbooleanArray result = NULL ;
2674+ jint t = -1 ;
2675+
2676+ int32_t n = yices_term_bitsize (x);
2677+ if (n < 0 ) {
2678+ return NULL ;
2679+ }
2680+
2681+ if (n <= 64 ) {
2682+ // this should be the common case
2683+ int32_t a[64 ];
2684+ int32_t code = yices_bvsum_component (x, idx, a, &t);
2685+ if (code >= 0 ) {
2686+ result = convertToBoolArray (env, n, a);
2687+ }
2688+
2689+ } else {
2690+ try {
2691+ int32_t *tmp = new int32_t [n];
2692+ int32_t code = yices_bvsum_component (x, idx, tmp, &t);
2693+ if (code >= 0 ) {
2694+ result = convertToBoolArray (env, n, tmp);
2695+ }
2696+ delete [] tmp;
2697+ } catch (std::bad_alloc&) {
2698+ out_of_mem_exception (env);
2699+ }
2700+ }
2701+
2702+ return result;
2703+ }
2704+
2705+ JNIEXPORT jint JNICALL Java_com_sri_yices_Yices_bvSumComponentTerm (JNIEnv *env, jclass, jint x, jint idx) {
2706+ jint result = -1 ;
2707+
2708+ int32_t n = yices_term_bitsize (x);
2709+ if (n < 0 ) {
2710+ return result;
2711+ }
2712+
2713+ if (n <= 64 ) {
2714+ // this should be the common case
2715+ int32_t a[64 ];
2716+ yices_bvsum_component (x, idx, a, &result);
2717+
2718+ } else {
2719+ try {
2720+ int32_t *tmp = new int32_t [n];
2721+ yices_bvsum_component (x, idx, tmp, &result);
2722+ delete [] tmp;
2723+ } catch (std::bad_alloc&) {
2724+ out_of_mem_exception (env);
2725+ }
2726+ }
2727+
2728+ return result;
2729+ }
2730+
2731+ JNIEXPORT jint JNICALL Java_com_sri_yices_Yices_productComponentTerm (JNIEnv *env, jclass, jint x, jint idx) {
2732+ uint32_t p = 0 ;
2733+ jint t = -1 ;
2734+
2735+ yices_product_component (x, idx, &t, &p);
2736+ return t;
2737+ }
2738+
2739+ JNIEXPORT jint JNICALL Java_com_sri_yices_Yices_productComponentPower (JNIEnv *env, jclass, jint x, jint idx) {
2740+ uint32_t p = 0 ;
2741+ jint t = -1 ;
2742+
2743+ yices_product_component (x, idx, &t, &p);
2744+ return p;
2745+ }
2746+
26332747JNIEXPORT jint JNICALL Java_com_sri_yices_Yices_boolConstValue (JNIEnv *env, jclass, jint x) {
26342748 int32_t val;
26352749 jint result;
0 commit comments