public static IScriptable ToObjectOrNull (Context cx, object obj) { if (obj is IScriptable) { return (IScriptable)obj; } else if (obj != null && obj != Undefined.Value) { return ToObject (cx, ScriptRuntime.getTopCallScope (cx), obj); } return null; }