File tree Expand file tree Collapse file tree 2 files changed +14
-26
lines changed
graal-js/src/com.oracle.truffle.js/src/com/oracle/truffle/js/runtime Expand file tree Collapse file tree 2 files changed +14
-26
lines changed Original file line number Diff line number Diff line change @@ -1566,9 +1566,20 @@ public static boolean isHex(char c) {
15661566
15671567 @ TruffleBoundary
15681568 public static long parseArrayIndexIsIndexRaw (Object o ) {
1569- assert isArrayIndex (o );
1570- assert Strings .isTString (o ) || o instanceof Number ;
1571- return parseArrayIndexRaw (o instanceof TruffleString str ? str : Strings .fromNumber ((Number ) o ), TruffleString .ReadCharUTF16Node .getUncached ());
1569+ assert (Strings .isTString (o ) || o instanceof Number ) && isArrayIndex (o ) : o ;
1570+ TruffleString asStr ;
1571+ if (o instanceof TruffleString str ) {
1572+ asStr = str ;
1573+ } else if (o instanceof Integer i ) {
1574+ return i ;
1575+ } else if (o instanceof Long l ) {
1576+ return l ;
1577+ } else if (o instanceof Double d ) {
1578+ asStr = doubleToString (d );
1579+ } else {
1580+ throw CompilerDirectives .shouldNotReachHere ();
1581+ }
1582+ return parseArrayIndexRaw (asStr , TruffleString .ReadCharUTF16Node .getUncached ());
15721583 }
15731584
15741585 /**
Original file line number Diff line number Diff line change 4444import java .util .ArrayList ;
4545import java .util .Locale ;
4646
47- import com .oracle .truffle .api .CompilerDirectives ;
4847import com .oracle .truffle .api .CompilerDirectives .TruffleBoundary ;
4948import com .oracle .truffle .api .interop .InteropLibrary ;
5049import com .oracle .truffle .api .interop .UnsupportedMessageException ;
@@ -848,28 +847,6 @@ public static TruffleString fromInt(int intValue) {
848847 return fromLong (intValue );
849848 }
850849
851- public static TruffleString fromDouble (double d ) {
852- return TruffleString .FromJavaStringNode .getUncached ().execute (doubleToJavaString (d ), TruffleString .Encoding .UTF_16 );
853- }
854-
855- @ TruffleBoundary
856- private static String doubleToJavaString (double d ) {
857- return String .valueOf (d );
858- }
859-
860- public static TruffleString fromNumber (Number number ) {
861- if (number instanceof Integer ) {
862- return fromInt (number .intValue ());
863- }
864- if (number instanceof Long ) {
865- return fromLong (number .longValue ());
866- }
867- if (number instanceof Double ) {
868- return fromDouble (number .doubleValue ());
869- }
870- throw CompilerDirectives .shouldNotReachHere ();
871- }
872-
873850 @ TruffleBoundary
874851 public static TruffleString fromBigInt (BigInt bi ) {
875852 return fromBigInt (TruffleString .FromJavaStringNode .getUncached (), bi );
You can’t perform that action at this time.
0 commit comments