private IMember CallOperator(PythonOperator op, IMember left, IPythonType leftType, IMember right, IPythonType rightType, Expression expr, bool tryLeft = true, bool tryRight = true)
        {
            var(funcName, swappedFuncName) = OpMethodName(op);

            if (tryLeft && funcName != null && left is IPythonInstance lpi)
            {
                var ret = leftType.Call(lpi, funcName, new ArgumentSet(new[] { right }, expr, this));
                if (!ret.IsUnknown())
                {
                    return(ret);
                }
            }

            if (tryRight && swappedFuncName != null && right is IPythonInstance rpi)
            {
                var ret = rightType.Call(rpi, swappedFuncName, new ArgumentSet(new[] { left }, expr, this));
                if (!ret.IsUnknown())
                {
                    return(ret);
                }
            }

            return(null);
        }
Beispiel #2
0
 public IMember Call(IPythonInstance instance, string memberName, IArgumentSet args) => _type.Call(instance, memberName, args);