nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeString.java
equal
deleted
inserted
replaced
88 this(value, global.getStringPrototype(), $nasgenmap$); |
88 this(value, global.getStringPrototype(), $nasgenmap$); |
89 } |
89 } |
90 |
90 |
91 private NativeString(final CharSequence value, final ScriptObject proto, final PropertyMap map) { |
91 private NativeString(final CharSequence value, final ScriptObject proto, final PropertyMap map) { |
92 super(proto, map); |
92 super(proto, map); |
93 assert value instanceof String || value instanceof ConsString; |
93 assert JSType.isString(value); |
94 this.value = value; |
94 this.value = value; |
95 } |
95 } |
96 |
96 |
97 @Override |
97 @Override |
98 public String safeToString() { |
98 public String safeToString() { |
153 @Override |
153 @Override |
154 protected GuardedInvocation findGetIndexMethod(final CallSiteDescriptor desc, final LinkRequest request) { |
154 protected GuardedInvocation findGetIndexMethod(final CallSiteDescriptor desc, final LinkRequest request) { |
155 final Object self = request.getReceiver(); |
155 final Object self = request.getReceiver(); |
156 final Class<?> returnType = desc.getMethodType().returnType(); |
156 final Class<?> returnType = desc.getMethodType().returnType(); |
157 |
157 |
158 if (returnType == Object.class && (self instanceof String || self instanceof ConsString)) { |
158 if (returnType == Object.class && JSType.isString(self)) { |
159 try { |
159 try { |
160 return new GuardedInvocation(MH.findStatic(MethodHandles.lookup(), NativeString.class, "get", desc.getMethodType()), NashornGuards.getInstanceOf2Guard(String.class, ConsString.class)); |
160 return new GuardedInvocation(MH.findStatic(MethodHandles.lookup(), NativeString.class, "get", desc.getMethodType()), NashornGuards.getInstanceOf2Guard(String.class, ConsString.class)); |
161 } catch (final LookupException e) { |
161 } catch (final LookupException e) { |
162 //empty. Shouldn't happen. Fall back to super |
162 //empty. Shouldn't happen. Fall back to super |
163 } |
163 } |
1310 private static Object protoFilter(final Object object) { |
1310 private static Object protoFilter(final Object object) { |
1311 return Global.instance().getStringPrototype(); |
1311 return Global.instance().getStringPrototype(); |
1312 } |
1312 } |
1313 |
1313 |
1314 private static CharSequence getCharSequence(final Object self) { |
1314 private static CharSequence getCharSequence(final Object self) { |
1315 if (self instanceof String || self instanceof ConsString) { |
1315 if (JSType.isString(self)) { |
1316 return (CharSequence)self; |
1316 return (CharSequence)self; |
1317 } else if (self instanceof NativeString) { |
1317 } else if (self instanceof NativeString) { |
1318 return ((NativeString)self).getValue(); |
1318 return ((NativeString)self).getValue(); |
1319 } else if (self != null && self == Global.instance().getStringPrototype()) { |
1319 } else if (self != null && self == Global.instance().getStringPrototype()) { |
1320 return ""; |
1320 return ""; |