(ExecutionContext context, Object o)
| 56 | } |
| 57 | |
| 58 | public static JSObject toObject(ExecutionContext context, Object o) { |
| 59 | if (o == Types.UNDEFINED) { |
| 60 | throw new ThrowException(context, context.createTypeError("undefined cannot be converted to an object")); |
| 61 | } |
| 62 | if (o == Types.NULL) { |
| 63 | throw new ThrowException(context, context.createTypeError("null cannot be converted to an object")); |
| 64 | } |
| 65 | if (o instanceof JSObject) { |
| 66 | return (JSObject) o; |
| 67 | } |
| 68 | if (o instanceof String) { |
| 69 | return new DynString(context.getGlobalContext(), (String) o); |
| 70 | } |
| 71 | if (o instanceof Number) { |
| 72 | return new DynNumber(context.getGlobalContext(), (Number) o); |
| 73 | } |
| 74 | if (o instanceof Boolean) { |
| 75 | return new DynBoolean(context.getGlobalContext(), (Boolean) o); |
| 76 | } |
| 77 | return new PrimitiveDynObject(context.getGlobalContext(), o); |
| 78 | } |
| 79 | |
| 80 | public static Object toThisObject(ExecutionContext context, Object o) { |
| 81 | if (o == Types.UNDEFINED) { |
no test coverage detected