Ejemplo n.º 1
0
        public override object NotEqual(object self, object other)
        {
            object func;

            if (PythonType.TryLookupSpecialMethod(self, SymbolTable.OpNotEqual, out func))
            {
                object ret;
                if (Ops.TryCall(func, other, out ret) && ret != Ops.NotImplemented)
                {
                    return(ret);
                }
            }

            if (PythonType.TryLookupSpecialMethod(self, SymbolTable.Cmp, out func) && func != __cmp__F)
            {
                object ret = Ops.Call(func, other);
                if (ret != Ops.NotImplemented)
                {
                    return(Ops.CompareToZero(ret) != 0);
                }

                //if (ret is int) {
                //    return ((int)ret) != 0;
                //} else if (ret is ExtensibleInt) {
                //    return ((ExtensibleInt)ret)._value != 0;
                //}
                //throw Ops.TypeError("comparison did not return an int");
            }

            return(Ops.NotImplemented);
        }