MCPcopy Create free account
hub / github.com/dynjs/dynjs / toObject

Method toObject

src/main/java/org/dynjs/runtime/Types.java:58–78  ·  view source on GitHub ↗
(ExecutionContext context, Object o)

Source from the content-addressed store, hash-verified

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) {

Callers 15

interpretMethod · 0.95
interpretMethod · 0.95
interpretMethod · 0.95
interpretMethod · 0.95
interpretMethod · 0.95
interpretMethod · 0.95
getValueMethod · 0.95
callMethod · 0.95
callMethod · 0.95
callMethod · 0.95

Calls 2

createTypeErrorMethod · 0.80
getGlobalContextMethod · 0.65

Tested by

no test coverage detected