@@ -3395,6 +3395,59 @@ public static SixModelObject abs_I(SixModelObject a, SixModelObject type, Thread
3395
3395
return makeBI (tc , type , getBI (tc , a ).abs ());
3396
3396
}
3397
3397
3398
+ public static SixModelObject radix_I (long radix_l , String str , long zpos , long flags , SixModelObject type , ThreadContext tc ) {
3399
+ BigInteger zvalue = BigInteger .ZERO ;
3400
+ BigInteger zbase = BigInteger .ONE ;
3401
+ int chars = str .length ();
3402
+ BigInteger value = zvalue ;
3403
+ BigInteger base = zbase ;
3404
+ long pos = -1 ;
3405
+ char ch ;
3406
+ boolean neg = false ;
3407
+ BigInteger radix = BigInteger .valueOf (radix_l );
3408
+
3409
+ if (radix_l > 36 ) {
3410
+ throw ExceptionHandling .dieInternal (tc , "Cannot convert radix of " + radix_l + " (max 36)" );
3411
+ }
3412
+
3413
+ ch = (zpos < chars ) ? str .charAt ((int )zpos ) : 0 ;
3414
+ if ((flags & 0x02 ) != 0 && (ch == '+' || ch == '-' )) {
3415
+ neg = (ch == '-' );
3416
+ zpos ++;
3417
+ ch = (zpos < chars ) ? str .charAt ((int )zpos ) : 0 ;
3418
+ }
3419
+ while (zpos < chars ) {
3420
+ if (ch >= '0' && ch <= '9' ) ch = (char )(ch - '0' );
3421
+ else if (ch >= 'a' && ch <= 'z' ) ch = (char )(ch - 'a' + 10 );
3422
+ else if (ch >= 'A' && ch <= 'Z' ) ch = (char )(ch - 'A' + 10 );
3423
+ else break ;
3424
+ if (ch >= radix_l ) break ;
3425
+ zvalue = zvalue .multiply (radix ).add (BigInteger .valueOf (ch ));
3426
+ zbase = zbase .multiply (radix );
3427
+ zpos ++; pos = zpos ;
3428
+ if (ch != 0 || (flags & 0x04 ) == 0 ) { value =zvalue ; base =zbase ; }
3429
+ if (zpos >= chars ) break ;
3430
+ ch = str .charAt ((int )zpos );
3431
+ if (ch != '_' ) continue ;
3432
+ zpos ++;
3433
+ if (zpos >= chars ) break ;
3434
+ ch = str .charAt ((int )zpos );
3435
+ }
3436
+
3437
+ if (neg || (flags & 0x01 ) != 0 ) { value = value .negate (); }
3438
+
3439
+ HLLConfig hllConfig = tc .curFrame .codeRef .staticInfo .compUnit .hllConfig ;
3440
+ SixModelObject result = hllConfig .slurpyArrayType .st .REPR .allocate (tc ,
3441
+ hllConfig .slurpyArrayType .st );
3442
+ result .initialize (tc );
3443
+
3444
+ result .push_boxed (tc , makeBI (tc , type , value ));
3445
+ result .push_boxed (tc , makeBI (tc , type , base ));
3446
+ result .push_boxed (tc , makeBI (tc , type , BigInteger .valueOf (pos )));
3447
+
3448
+ return result ;
3449
+ }
3450
+
3398
3451
public static SixModelObject bitor_I (SixModelObject a , SixModelObject b , SixModelObject type , ThreadContext tc ) {
3399
3452
return makeBI (tc , type , getBI (tc , a ).or (getBI (tc , b )));
3400
3453
}
0 commit comments