@@ -485,61 +485,16 @@ QlBuiltins::BigInt varMaxVal(Variable v) { result = typeUpperBound(v.getUnspecif
485485QlBuiltins:: BigInt infinityAsBigInt ( ) { result = 1 .toBigInt ( ) .bitShiftLeft ( 1024 ) }
486486
487487QlBuiltins:: BigInt parseAsBigInt ( string s ) {
488- s = any ( Expr e ) .getValue ( ) and
489- (
490- result = s .toBigInt ( )
491- or
492- s .toFloat ( ) = 1.0 / 0.0 and result = infinityAsBigInt ( )
493- or
494- s .toFloat ( ) = - ( 1.0 / 0.0 ) and result = - infinityAsBigInt ( )
495- or
496- exists ( QlBuiltins:: BigInt coeff , int base10exp | parseFiniteAsBigInt ( s , coeff , base10exp ) |
497- if base10exp < 0
498- then result = coeff / 10 .toBigInt ( ) .pow ( - base10exp )
499- else result = coeff * 10 .toBigInt ( ) .pow ( base10exp )
500- )
501- )
502- }
503-
504- bindingset [ s]
505- private predicate parseFiniteAsBigInt ( string s , QlBuiltins:: BigInt coeff , int base10exp ) {
506- exists ( string t | s = "+" + t | parseUnsignedAsBigInt ( t , coeff , base10exp ) )
507- or
508- exists ( string t | s = "-" + t | parseUnsignedAsBigInt ( t , - coeff , base10exp ) )
509- or
510- parseUnsignedAsBigInt ( s , coeff , base10exp )
511- }
512-
513- bindingset [ s]
514- private predicate parseUnsignedAsBigInt ( string s , QlBuiltins:: BigInt coeff , int base10exp ) {
515- exists ( string beforeE , int base10expAfterE , int base10expBeforeE |
516- beforeE = s .toUpperCase ( ) .splitAt ( "E" , 0 ) and
517- base10expAfterE = parseSignedInt ( s .toUpperCase ( ) .splitAt ( "E" , 1 ) ) and
518- parseUnsignedDecimalAsBigInt ( beforeE , coeff , base10expBeforeE ) and
519- base10exp = base10expBeforeE + base10expAfterE
520- )
521- or
522- exists ( string beforeDot , string afterDot |
523- beforeDot = s .splitAt ( "." , 0 ) and
524- afterDot = s .splitAt ( "." , 1 ) and
525- coeff = ( beforeDot + afterDot ) .toBigInt ( ) and
526- base10exp = - afterDot .length ( )
527- )
528- }
529-
530- bindingset [ s]
531- private predicate parseUnsignedDecimalAsBigInt ( string s , QlBuiltins:: BigInt coeff , int base10exp ) {
532- exists ( string beforeDot , string afterDot |
533- beforeDot = s .splitAt ( "." , 0 ) and
534- afterDot = s .splitAt ( "." , 1 ) and
535- coeff = ( beforeDot + afterDot ) .toBigInt ( ) and
536- base10exp = - afterDot .length ( )
488+ exists ( Expr e | s = e .getValue ( ) |
489+ if exists ( s .toBigInt ( ) ) then
490+ result = s .toBigInt ( )
491+ else
492+ exists ( float f | f = s .toFloat ( ) |
493+ f = 1.0 / 0.0 and result = infinityAsBigInt ( )
494+ or
495+ f = - ( 1.0 / 0.0 ) and result = - infinityAsBigInt ( )
496+ or
497+ result = f .toString ( ) .toBigInt ( )
498+ )
537499 )
538500}
539-
540- bindingset [ s]
541- private int parseSignedInt ( string s ) {
542- exists ( string t | s = "+" + t | result = t .toInt ( ) )
543- or
544- result = s .toInt ( )
545- }
0 commit comments