(ExecutionContext context, String hint)
| 275 | } |
| 276 | |
| 277 | @Override |
| 278 | public Object defaultValue(ExecutionContext context, String hint) { |
| 279 | // 8.12.8 |
| 280 | |
| 281 | if (hint == null) { |
| 282 | hint = "Number"; |
| 283 | } |
| 284 | |
| 285 | if (hint.equals("String")) { |
| 286 | Object toString = get(context, "toString"); |
| 287 | if (toString instanceof JSFunction) { |
| 288 | Object result = context.call((JSFunction) toString, this); |
| 289 | if (result instanceof String || result instanceof Number || result instanceof Boolean || result == Types.UNDEFINED || result == Types.NULL) { |
| 290 | return result; |
| 291 | } |
| 292 | } |
| 293 | |
| 294 | Object valueOf = get(context, "valueOf"); |
| 295 | if (valueOf instanceof JSFunction) { |
| 296 | Object result = context.call((JSFunction) valueOf, this); |
| 297 | if (result instanceof String || result instanceof Number || result instanceof Boolean || result == Types.UNDEFINED || result == Types.NULL) { |
| 298 | return result; |
| 299 | } |
| 300 | } |
| 301 | throw new ThrowException(context, context.createTypeError("String coercion must return a primitive value")); |
| 302 | } else if (hint.equals("Number")) { |
| 303 | Object valueOf = get(context, "valueOf"); |
| 304 | if (valueOf instanceof JSFunction) { |
| 305 | Object result = context.call((JSFunction) valueOf, this); |
| 306 | if (result instanceof String || result instanceof Number || result instanceof Boolean || result == Types.UNDEFINED || result == Types.NULL) { |
| 307 | return result; |
| 308 | } |
| 309 | } |
| 310 | |
| 311 | Object toString = get(context, "toString"); |
| 312 | if (toString instanceof JSFunction) { |
| 313 | Object result = context.call((JSFunction) toString, this); |
| 314 | if (result instanceof String || result instanceof Number || result instanceof Boolean || result == Types.UNDEFINED || result == Types.NULL) { |
| 315 | return result; |
| 316 | } |
| 317 | } |
| 318 | throw new ThrowException(context, context.createTypeError("String coercion must return a primitive value")); |
| 319 | } |
| 320 | |
| 321 | return null; |
| 322 | } |
| 323 | |
| 324 | @Override |
| 325 | public boolean defineOwnProperty(ExecutionContext context, String name, PropertyDescriptor desc, boolean shouldThrow) { |
nothing calls this directly
no test coverage detected