nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptRuntime.java
equal
deleted
inserted
replaced
30 import static jdk.nashorn.internal.runtime.ECMAErrors.rangeError; |
30 import static jdk.nashorn.internal.runtime.ECMAErrors.rangeError; |
31 import static jdk.nashorn.internal.runtime.ECMAErrors.referenceError; |
31 import static jdk.nashorn.internal.runtime.ECMAErrors.referenceError; |
32 import static jdk.nashorn.internal.runtime.ECMAErrors.syntaxError; |
32 import static jdk.nashorn.internal.runtime.ECMAErrors.syntaxError; |
33 import static jdk.nashorn.internal.runtime.ECMAErrors.typeError; |
33 import static jdk.nashorn.internal.runtime.ECMAErrors.typeError; |
34 import static jdk.nashorn.internal.runtime.JSType.isRepresentableAsInt; |
34 import static jdk.nashorn.internal.runtime.JSType.isRepresentableAsInt; |
|
35 import static jdk.nashorn.internal.runtime.JSType.isString; |
35 |
36 |
36 import java.lang.invoke.MethodHandle; |
37 import java.lang.invoke.MethodHandle; |
37 import java.lang.invoke.MethodHandles; |
38 import java.lang.invoke.MethodHandles; |
38 import java.lang.invoke.SwitchPoint; |
39 import java.lang.invoke.SwitchPoint; |
39 import java.lang.reflect.Array; |
40 import java.lang.reflect.Array; |
53 import jdk.nashorn.internal.ir.debug.JSONWriter; |
54 import jdk.nashorn.internal.ir.debug.JSONWriter; |
54 import jdk.nashorn.internal.objects.Global; |
55 import jdk.nashorn.internal.objects.Global; |
55 import jdk.nashorn.internal.objects.NativeObject; |
56 import jdk.nashorn.internal.objects.NativeObject; |
56 import jdk.nashorn.internal.parser.Lexer; |
57 import jdk.nashorn.internal.parser.Lexer; |
57 import jdk.nashorn.internal.runtime.linker.Bootstrap; |
58 import jdk.nashorn.internal.runtime.linker.Bootstrap; |
58 |
|
59 |
59 |
60 /** |
60 /** |
61 * Utilities to be called by JavaScript runtime API and generated classes. |
61 * Utilities to be called by JavaScript runtime API and generated classes. |
62 */ |
62 */ |
63 |
63 |
562 |
562 |
563 // code below is as per the spec. |
563 // code below is as per the spec. |
564 final Object xPrim = JSType.toPrimitive(x); |
564 final Object xPrim = JSType.toPrimitive(x); |
565 final Object yPrim = JSType.toPrimitive(y); |
565 final Object yPrim = JSType.toPrimitive(y); |
566 |
566 |
567 if (xPrim instanceof String || yPrim instanceof String |
567 if (isString(xPrim) || isString(yPrim)) { |
568 || xPrim instanceof ConsString || yPrim instanceof ConsString) { |
|
569 try { |
568 try { |
570 return new ConsString(JSType.toCharSequence(xPrim), JSType.toCharSequence(yPrim)); |
569 return new ConsString(JSType.toCharSequence(xPrim), JSType.toCharSequence(yPrim)); |
571 } catch (final IllegalArgumentException iae) { |
570 } catch (final IllegalArgumentException iae) { |
572 throw rangeError(iae, "concat.string.too.big"); |
571 throw rangeError(iae, "concat.string.too.big"); |
573 } |
572 } |
1008 } else { |
1007 } else { |
1009 py = JSType.toPrimitive(y, Number.class); |
1008 py = JSType.toPrimitive(y, Number.class); |
1010 px = JSType.toPrimitive(x, Number.class); |
1009 px = JSType.toPrimitive(x, Number.class); |
1011 } |
1010 } |
1012 |
1011 |
1013 if (JSType.ofNoFunction(px) == JSType.STRING && JSType.ofNoFunction(py) == JSType.STRING) { |
1012 if (isString(px) && isString(py)) { |
1014 // May be String or ConsString |
1013 // May be String or ConsString |
1015 return px.toString().compareTo(py.toString()) < 0; |
1014 return px.toString().compareTo(py.toString()) < 0; |
1016 } |
1015 } |
1017 |
1016 |
1018 final double nx = JSType.toNumber(px); |
1017 final double nx = JSType.toNumber(px); |