public static Callable GetElemFunctionAndThis(object obj, object elem, Context cx)
{
string str = ToStringIdOrIndex(cx, elem);
if (str != null)
{
return GetPropFunctionAndThis(obj, str, cx);
}
int index = LastIndexResult(cx);
Scriptable thisObj = ToObjectOrNull(cx, obj);
if (thisObj == null)
{
throw UndefCallError(obj, index.ToString());
}
object value = ScriptableObject.GetProperty(thisObj, index);
if (!(value is Callable))
{
throw NotFunctionError(value, elem);
}
StoreScriptable(cx, thisObj);
return (Callable)value;
}