deep-c-rsc/jcgo_Out/BigIntgr.c

695 lines
17 KiB
C
Raw Permalink Normal View History

2021-07-16 18:07:51 -04:00
/* DO NOT EDIT THIS FILE - it is machine generated (JCGO_116) */
#ifdef JCGO_SEPARATED
#define JCGO_116
#include "jcgortl.h"
#include "Main.h"
#endif
#ifdef JCGO_116
#ifdef CHKALL_java_math_BigInteger
#include "jcgobchk.h"
#endif
JCGO_NOSEP_INLINE void CFASTCALL
java_math_BigInteger__void( java_math_BigInteger This )
{
}
JCGO_NOSEP_STATIC java_math_BigInteger CFASTCALL
java_math_BigInteger__this__LsI( java_math_BigInteger This, java_lang_String
val, jint radix )
{
{
java_math_BigInteger result;
(java_lang_Number__this__((java_lang_Number)This));
result= (java_math_BigInteger__valueOf__LsI(
val, radix));
JCGO_FIELD_NZACCESS(This, ival)= JCGO_FIELD_ACCESS(java_math_BigInteger,
result, ival);
JCGO_FIELD_NZACCESS(This, words)= JCGO_FIELD_NZACCESS(result, words);
}
return This;
}
JCGO_NOSEP_STATIC java_math_BigInteger CFASTCALL
java_math_BigInteger__this__I( java_math_BigInteger This, jint value
)
{
{
(java_lang_Number__this__((java_lang_Number)This));
JCGO_FIELD_NZACCESS(This, ival)= value;
}
return This;
}
JCGO_NOSEP_INLINE java_math_BigInteger CFASTCALL
java_math_BigInteger__new__I( jint value )
{
return java_math_BigInteger__this__I(
(java_math_BigInteger)jcgo_newObject((jvtable)&java_math_BigInteger_methods),
value);
}
JCGO_NOSEP_STATIC java_math_BigInteger CFASTCALL
java_math_BigInteger__this__( java_math_BigInteger This )
{
{
(java_lang_Number__this__((java_lang_Number)This));
}
return This;
}
JCGO_NOSEP_INLINE java_math_BigInteger CFASTCALL
java_math_BigInteger__new__( void )
{
return java_math_BigInteger__this__(
(java_math_BigInteger)jcgo_newObject((jvtable)&java_math_BigInteger_methods));
}
JCGO_NOSEP_INLINE java_math_BigInteger CFASTCALL
java_math_BigInteger__alloc__I( jint nwords )
{
{
java_math_BigInteger result;
result= java_math_BigInteger__new__();
if (nwords > (jint)1)
{
JCGO_FIELD_NZACCESS(result, words)= (jintArr)jcgo_newArray(JCGO_CORECLASS_FOR(OBJT_jint),
0, nwords);
}
return result;
}
}
JCGO_NOSEP_INLINE jint CFASTCALL
java_math_BigInteger__wordsNeeded__IAI( jintArr words, jint len )
{
{
jint i;
i= len;
if (i > 0)
{
jint word;
word= JCGO_ARRAY_IACCESS(words, --i);
if (word == (-(jint)1))
{
while (i > 0 && (word= JCGO_ARRAY_NZIACCESS(words, i - (jint)1)) <
0)
{
i--;
if (word != (-(jint)1))
{
break;
}
}
}
else
{
while (word == 0 && i > 0 && (word= JCGO_ARRAY_NZIACCESS(words,
i - (jint)1)) >= 0)
{
i--;
}
}
}
return i + (jint)1;
}
}
JCGO_NOSEP_INLINE java_math_BigInteger CFASTCALL
java_math_BigInteger__make__IAI( jintArr words, jint len )
{
{
java_math_BigInteger num;
if (words == jnull)
{
return (java_math_BigInteger__valueOf__J(
(jlong)len));
}
len= (java_math_BigInteger__wordsNeeded__IAI(
words, len));
if (len <= (jint)1)
{
return len == 0? java_math_BigInteger__ZERO : (java_math_BigInteger__valueOf__J(
(jlong)(JCGO_ARRAY_NZIACCESS(words, 0))));
}
num= java_math_BigInteger__new__();
JCGO_FIELD_NZACCESS(num, words)= words;
JCGO_FIELD_NZACCESS(num, ival)= len;
return num;
}
}
JCGO_NOSEP_INLINE java_math_BigInteger CFASTCALL
java_math_BigInteger__valueOf__BAIZI( jbyteArr digits, jint byte_len,
jint radix, jboolean negative )
{
{
jintArr words;
jint chars_per_word;
jint size;
chars_per_word= (gnu_java_math_MPN__chars_per_word__I(
radix));
words= (jintArr)jcgo_newArray(JCGO_CORECLASS_FOR(OBJT_jint), 0, jcgo_div(byte_len,
chars_per_word) + (jint)1);
size= (gnu_java_math_MPN__set_str__IABAII(
words, digits, byte_len, radix));
if (size == 0)
{
return java_math_BigInteger__ZERO;
}
if (JCGO_ARRAY_NZIACCESS(words, size - (jint)1) < 0)
{
JCGO_ARRAY_NZIACCESS(words, size++)= 0;
}
if (negative)
{
(java_math_BigInteger__negate__IAIAI(
words, words, size));
}
return (java_math_BigInteger__make__IAI(
words, size));
}
}
JCGO_NOSEP_FRWINL java_math_BigInteger CFASTCALL
java_math_BigInteger__valueOf__LsI( java_lang_String s, jint radix
)
{
{
jbyteArr bytes;
jint len;
jint i;
jint digit;
jint byte_len;
jchar ch;
jboolean negative;
len= (JCGO_CALL_FINALF(s) java_lang_String__length__(
s));
if (len <= (jint)15 && radix <= (jint)16)
{
return (java_math_BigInteger__valueOf__J(
(java_lang_Long__parseLong__LsI(
s, radix))));
}
;
ch= (java_lang_String__charAt__I(
s, 0));
if (ch == (jchar)45/*'-'*/)
{
negative= (jboolean)jtrue;
i= (jint)1;
bytes= (jbyteArr)jcgo_newArray(JCGO_CORECLASS_FOR(OBJT_jbyte), 0,
len - (jint)1);
}
else
{
negative= (jboolean)jfalse;
i= 0;
bytes= (jbyteArr)jcgo_newArray(JCGO_CORECLASS_FOR(OBJT_jbyte), 0,
len);
}
byte_len= 0;
for (; i < len; i++)
{
ch= (java_lang_String__charAt__I(
s, i));
digit= (java_lang_Character__digit__CI(
radix, ch));
if (digit < 0)
{
JCGO_THROW_EXC(java_lang_NumberFormatException__new__());
}
JCGO_ARRAY_NZBACCESS(bytes, byte_len++)= ((jbyte)digit);
}
return (java_math_BigInteger__valueOf__BAIZI(
bytes, byte_len, radix, (jboolean)negative));
}
}
JCGO_NOSEP_INLINE jboolean CFASTCALL
java_math_BigInteger__equals__L03o76L03o76( java_math_BigInteger x,
java_math_BigInteger y )
{
{
if (JCGO_FIELD_ACCESS(java_math_BigInteger, x, words) == jnull &&
JCGO_FIELD_ACCESS(java_math_BigInteger, y, words) == jnull)
{
return (jboolean)(JCGO_FIELD_NZACCESS(x, ival) == JCGO_FIELD_ACCESS(java_math_BigInteger,
y, ival));
}
if (JCGO_FIELD_NZACCESS(x, words) == jnull || JCGO_FIELD_ACCESS(java_math_BigInteger,
y, words) == jnull || JCGO_FIELD_NZACCESS(x, ival) != JCGO_FIELD_ACCESS(java_math_BigInteger,
y, ival))
{
return (jboolean)jfalse;
}
{
jint i;
i= JCGO_FIELD_NZACCESS(x, ival);
for (; --i >= 0;)
{
jint jcgo_rcvrI1;
if ((jcgo_rcvrI1= JCGO_ARRAY_IACCESS(JCGO_FIELD_NZACCESS(x, words),
i), jcgo_rcvrI1 != JCGO_ARRAY_IACCESS(JCGO_FIELD_ACCESS(java_math_BigInteger,
y, words), i)))
{
return (jboolean)jfalse;
}
}
}
return (jboolean)jtrue;
}
}
JCGO_NOSEP_INLINE jboolean CFASTCALL
java_math_BigInteger__isNegative__( java_math_BigInteger This )
{
{
return (jboolean)((JCGO_FIELD_NZACCESS(This, words) == jnull? JCGO_FIELD_NZACCESS(This,
ival) : JCGO_ARRAY_IACCESS(JCGO_FIELD_NZACCESS(This, words), JCGO_FIELD_NZACCESS(This,
ival) - (jint)1)) < 0);
}
}
JCGO_NOSEP_INLINE void CFASTCALL
java_math_BigInteger__getAbsolute__IA( java_math_BigInteger This,
jintArr words )
{
{
jint len;
if (JCGO_FIELD_NZACCESS(This, words) == jnull)
{
len= (jint)1;
JCGO_ARRAY_IACCESS(words, 0)= (JCGO_FIELD_NZACCESS(This, ival));
}
else
{
len= JCGO_FIELD_NZACCESS(This, ival);
{
jint i;
i= len;
for (; --i >= 0;)
{
jint jcgo_rcvrI1;
(jcgo_rcvrI1= JCGO_ARRAY_IACCESS(JCGO_FIELD_NZACCESS(This, words),
i), JCGO_ARRAY_IACCESS(words, i)= jcgo_rcvrI1);
}
}
}
if (JCGO_ARRAY_IACCESS(words, len - (jint)1) < 0)
{
(java_math_BigInteger__negate__IAIAI(
words, words, len));
}
{
jint i;
i= JCGO_ARRAY_NZLENGTH(words);
for (; --i > len;)
{
JCGO_ARRAY_NZIACCESS(words, i)= 0;
}
}
}
}
JCGO_NOSEP_INLINE void CFASTCALL
java_math_BigInteger__format__IL8whtv( java_math_BigInteger This,
java_lang_StringBuffer buffer, jint radix )
{
{
if (JCGO_FIELD_NZACCESS(This, words) == jnull)
{
struct java_lang_String_s jcgo_stackobj1;
(JCGO_CALL_FINALF(buffer) java_lang_StringBuffer__append__Ls(
buffer, (java_lang_Integer__toString__IIX(
JCGO_FIELD_NZACCESS(This, ival), radix, JCGO_STACKOBJ_NEW(jcgo_stackobj1,
java_lang_String_methods)))));
}
else
{
if (JCGO_FIELD_NZACCESS(This, ival) <= (jint)2)
{
(JCGO_CALL_FINALF(buffer) java_lang_StringBuffer__append__Ls(
buffer, (java_lang_Long__toString__JI(
(java_math_BigInteger__longValue__(
This)), radix))));
}
else
{
jintArr work;
jint len;
jboolean neg;
neg= (java_math_BigInteger__isNegative__(
This));
if (neg || radix != (jint)16)
{
work= (jintArr)jcgo_newArray(JCGO_CORECLASS_FOR(OBJT_jint), 0,
JCGO_FIELD_NZACCESS(This, ival));
(java_math_BigInteger__getAbsolute__IA(
This, work));
}
else
{
work= JCGO_FIELD_NZACCESS(This, words);
}
len= JCGO_FIELD_NZACCESS(This, ival);
if (radix == (jint)16)
{
jint buf_start;
if (neg)
{
(JCGO_CALL_FINALF(buffer) java_lang_StringBuffer__append__C(
buffer, (jchar)45/*'-'*/));
}
buf_start= (JCGO_CALL_FINALF(buffer) java_lang_StringBuffer__length__(
buffer));
{
jint i;
i= len;
for (; --i >= 0;)
{
jint word;
word= JCGO_ARRAY_IACCESS(work, i);
{
jint j;
j= (jint)8;
for (; --j >= 0;)
{
jint hex_digit;
hex_digit= JCGO_SHR_F(word, (j * (jint)4)) & (jint)15;
if (hex_digit > 0 || (java_lang_StringBuffer__length__(
buffer)) > buf_start)
{
(java_lang_StringBuffer__append__C(
buffer, (java_lang_Character__forDigit__II(
hex_digit, (jint)16))));
}
}
}
}
}
}
else
{
jint i;
jint j;
i= (JCGO_CALL_FINALF(buffer) java_lang_StringBuffer__length__(
buffer));
for (;;)
{
jint digit;
digit= (gnu_java_math_MPN__divmod_1__IAIAII(
work, work, len, radix));
(java_lang_StringBuffer__append__C(
buffer, (java_lang_Character__forDigit__II(
digit, radix))));
while (len > 0 && JCGO_ARRAY_NZIACCESS(work, len - (jint)1) ==
0)
{
len--;
}
if (len == 0)
{
break;
}
}
if (neg)
{
(java_lang_StringBuffer__append__C(
buffer, (jchar)45/*'-'*/));
}
j= (java_lang_StringBuffer__length__(
buffer)) - (jint)1;
while (i < j)
{
jchar tmp;
tmp= (java_lang_StringBuffer__charAt__I(
buffer, i));
(java_lang_StringBuffer__setCharAt__IC(
buffer, i, (java_lang_StringBuffer__charAt__I(
buffer, j))));
(java_lang_StringBuffer__setCharAt__IC(
buffer, j, tmp));
i++;
j--;
}
}
}
}
}
}
JCGO_NOSEP_INLINE java_math_BigInteger CFASTCALL
java_math_BigInteger__this__Ls( java_math_BigInteger This, java_lang_String
val )
{
{
(java_math_BigInteger__this__LsI((java_math_BigInteger)This, val,
(jint)10));
}
return This;
}
JCGO_NOSEP_FRWINL java_math_BigInteger CFASTCALL
java_math_BigInteger__new__Ls( java_lang_String val )
{
JCGO_CLINIT_TRIG(java_math_BigInteger__class);
return java_math_BigInteger__this__Ls(
(java_math_BigInteger)jcgo_newObject((jvtable)&java_math_BigInteger_methods),
val);
}
JCGO_NOSEP_STATIC java_math_BigInteger CFASTCALL
java_math_BigInteger__valueOf__J( jlong val )
{
{
java_math_BigInteger result;
jint i;
if (val >= java_math_BigInteger__minFixNum && val <= java_math_BigInteger__maxFixNum)
{
return ((java_math_BigInteger)JCGO_ARRAY_NZLACCESS(java_math_BigInteger__smallFixNums,
(jint)val - java_math_BigInteger__minFixNum));
}
i= (jint)val;
if ((jlong)i == val)
{
return (java_math_BigInteger__new__I(
i));
}
result= (java_math_BigInteger__alloc__I(
(jint)2));
JCGO_FIELD_NZACCESS(result, ival)= (jint)2;
JCGO_ARRAY_IACCESS(JCGO_FIELD_NZACCESS(result, words), 0)= i;
JCGO_ARRAY_IACCESS(JCGO_FIELD_NZACCESS(result, words), (jint)1)=
((jint)JCGO_LSHR_F(val, (jint)32));
return result;
}
}
JCGO_NOSEP_INLINE java_lang_String CFASTCALL
java_math_BigInteger__toString__( java_math_BigInteger This )
{
{
return (java_math_BigInteger__toString__I(
This, (jint)10));
}
}
JCGO_NOSEP_STATIC java_lang_String CFASTCALL
java_math_BigInteger__toString__I( java_math_BigInteger This, jint
radix )
{
{
java_lang_StringBuffer buffer;
jint buf_size;
jint jcgo_rcvrI1;
struct java_lang_StringBuffer_s jcgo_stackobj1;
if (JCGO_FIELD_NZACCESS(This, words) == jnull)
{
return (java_lang_Integer__toString__II(
JCGO_FIELD_NZACCESS(This, ival), radix));
}
if (JCGO_FIELD_NZACCESS(This, ival) <= (jint)2)
{
return (java_lang_Long__toString__JI(
(java_math_BigInteger__longValue__(
This)), radix));
}
buf_size= (jcgo_rcvrI1= JCGO_FIELD_NZACCESS(This, ival), jcgo_rcvrI1 *
((gnu_java_math_MPN__chars_per_word__I(
radix)) + (jint)1));
buffer= (java_lang_StringBuffer__this__I(
JCGO_STACKOBJ_NEW(jcgo_stackobj1, java_lang_StringBuffer_methods),
buf_size));
(java_math_BigInteger__format__IL8whtv(
This, buffer, radix));
return (java_lang_StringBuffer__toString__(
buffer));
}
}
JCGO_NOSEP_STATIC jlong CFASTCALL
java_math_BigInteger__longValue__( java_math_BigInteger This )
{
{
jlong jcgo_rcvrJ1;
if (JCGO_FIELD_NZACCESS(This, words) == jnull)
{
return (jlong)JCGO_FIELD_NZACCESS(This, ival);
}
if (JCGO_FIELD_NZACCESS(This, ival) == (jint)1)
{
return (jlong)(JCGO_ARRAY_IACCESS(JCGO_FIELD_NZACCESS(This, words),
0));
}
return (jcgo_rcvrJ1= JCGO_LSHL_F((jlong)JCGO_ARRAY_IACCESS(JCGO_FIELD_NZACCESS(This,
words), (jint)1), (jint)32), jcgo_rcvrJ1 + ((jlong)JCGO_ARRAY_IACCESS(JCGO_FIELD_NZACCESS(This,
words), 0) & JLONG_C(0xffffffff)));
}
}
JCGO_NOSEP_STATIC jint CFASTCALL
java_math_BigInteger__hashCode__( java_math_BigInteger This )
{
{
jint jcgo_rcvrI1;
return JCGO_FIELD_NZACCESS(This, words) == jnull? JCGO_FIELD_NZACCESS(This,
ival) : (jcgo_rcvrI1= JCGO_ARRAY_IACCESS(JCGO_FIELD_NZACCESS(This,
words), 0), jcgo_rcvrI1 + JCGO_ARRAY_IACCESS(JCGO_FIELD_NZACCESS(This,
words), JCGO_FIELD_NZACCESS(This, ival) - (jint)1));
}
}
JCGO_NOSEP_STATIC jboolean CFASTCALL
java_math_BigInteger__equals__Lo( java_math_BigInteger This, java_lang_Object
obj )
{
{
if (!jcgo_instanceOf0(OBJT_java_math_BigInteger, MAXT_java_math_BigInteger,
(jObject)obj))
{
return (jboolean)jfalse;
}
return (jboolean)(java_math_BigInteger__equals__L03o76L03o76(
This, (java_math_BigInteger)obj));
}
}
JCGO_NOSEP_STATIC jboolean CFASTCALL
java_math_BigInteger__negate__IAIAI( jintArr dest, jintArr src, jint
len )
{
{
jlong carry;
jboolean negative;
carry= (jlong)(jint)1;
negative= JCGO_ARRAY_IACCESS(src, len - (jint)1) < 0;
{
jint i;
i= 0;
for (; i < len; i++)
{
carry+= ((jlong)(~(JCGO_ARRAY_NZIACCESS(src, i))) & JLONG_C(0xffffffff));
JCGO_ARRAY_IACCESS(dest, i)= ((jint)carry);
carry= JCGO_LSHR_F(carry, (jint)32);
}
}
return (jboolean)(negative && JCGO_ARRAY_IACCESS(dest, len - (jint)1) <
0);
}
}
JCGO_NOSEP_STATIC void CFASTCALL
java_math_BigInteger__class__0( void )
{
JCGO_CLINIT_BEGIN(java_math_BigInteger__class);
java_math_BigInteger__smallFixNums= (jObjectArr)jcgo_newArray(JCGO_CLASSREF_OF(java_math_BigInteger__class),
0, java_math_BigInteger__numFixNum);
{
{
jint i;
i= java_math_BigInteger__numFixNum;
for (; --i >= 0;)
{
jObject jcgo_rcvrL1;
jint jcgo_rcvrI1;
(jcgo_rcvrI1= i, jcgo_rcvrL1= (jObject)(java_math_BigInteger__new__I(
i + java_math_BigInteger__minFixNum)), *(java_math_BigInteger*)&JCGO_ARRAY_NZLACCESS(java_math_BigInteger__smallFixNums,
jcgo_rcvrI1)= (java_math_BigInteger)jcgo_rcvrL1);
}
}
}
java_math_BigInteger__ZERO= ((java_math_BigInteger)JCGO_ARRAY_NZLACCESS(java_math_BigInteger__smallFixNums,
(-java_math_BigInteger__minFixNum)));
JCGO_CLINIT_DONE(java_math_BigInteger__class);
}
JCGO_NOSEP_DATA CONST struct java_math_BigInteger_methods_s java_math_BigInteger_methods=
{
JCGO_CLASSREF_OF(java_math_BigInteger__class),
JCGO_GCJDESCR_INIT(java_math_BigInteger_s, words)
OBJT_java_math_BigInteger,
(JCGO_OBJSIZE_T)sizeof(struct java_math_BigInteger_s),
NULL,
JCGO_CLINIT_INIT(java_math_BigInteger__class__0)
0,
java_math_BigInteger__equals__Lo,
java_math_BigInteger__hashCode__,
java_math_BigInteger__toString__,
java_lang_Object__finalize__
};
JCGO_NOSEP_DATA struct java_math_BigInteger_class_s java_math_BigInteger__class
ATTRIBNONGC=
{
{
&java_lang_Class_methods,
JCGO_MON_INIT
JCGO_OBJREF_OF(*(java_lang_Object)&java_math_BigInteger_methods),
JCGO_STRREF_OF(jcgo_string1_BigIntgr),
JCGO_CLASSREF_OF(java_lang_Number__class),
((jObjectArr)JCGO_OBJREF_OF(jcgo_array3_Object)),
0x1c1
}
};
JCGO_NOSEP_GCDATA jObjectArr java_math_BigInteger__smallFixNums ATTRIBGCBSS=
jnull;
JCGO_NOSEP_GCDATA java_math_BigInteger java_math_BigInteger__ZERO
ATTRIBGCBSS= jnull;
JCGO_NOSEP_DATA CONST jcgo_arrtype23_Object jcgo_array2_BigIntgr=
{
(jvtable)&jbyteArr_methods,
JCGO_MON_INIT
20,
{
(jbyte)(jchar)106/*'j'*/, (jbyte)(jchar)97/*'a'*/, (jbyte)(jchar)118/*'v'*/,
(jbyte)(jchar)97/*'a'*/, (jbyte)(jchar)46/*'.'*/, (jbyte)(jchar)109/*'m'*/,
(jbyte)(jchar)97/*'a'*/, (jbyte)(jchar)116/*'t'*/, (jbyte)(jchar)104/*'h'*/,
(jbyte)(jchar)46/*'.'*/, (jbyte)(jchar)66/*'B'*/, (jbyte)(jchar)105/*'i'*/,
(jbyte)(jchar)103/*'g'*/, (jbyte)(jchar)73/*'I'*/, (jbyte)(jchar)110/*'n'*/,
(jbyte)(jchar)116/*'t'*/, (jbyte)(jchar)101/*'e'*/, (jbyte)(jchar)103/*'g'*/,
(jbyte)(jchar)101/*'e'*/, (jbyte)(jchar)114/*'r'*/
}
};
JCGO_NOSEP_DATA JCGO_NOTHR_CONST struct java_lang_String_s jcgo_string1_BigIntgr
JCGO_THRD_ATTRNONGC=
{
&java_lang_String_methods,
JCGO_MON_INIT
(java_lang_Object)JCGO_OBJREF_OF(jcgo_array2_BigIntgr),
0, 20, (jint)0xc502bf18L
};
#ifdef CHKALL_java_math_BigInteger
#include "jcgochke.h"
#endif
#endif