diff options
author | Guido van Rossum <guido@python.org> | 1995-01-07 12:40:10 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1995-01-07 12:40:10 (GMT) |
commit | 06186519e56094f54a39e3c2a9c7be30d8c9a9fc (patch) | |
tree | 90044ddbb5f95742501e9956ea35c8310d2be687 /Python | |
parent | 6a00cd8b89e23c4e577eabc9956debc725afde21 (diff) | |
download | cpython-06186519e56094f54a39e3c2a9c7be30d8c9a9fc.zip cpython-06186519e56094f54a39e3c2a9c7be30d8c9a9fc.tar.gz cpython-06186519e56094f54a39e3c2a9c7be30d8c9a9fc.tar.bz2 |
Use new instancebinop interface
Diffstat (limited to 'Python')
-rw-r--r-- | Python/ceval.c | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/Python/ceval.c b/Python/ceval.c index 5fa5dbb..410384e 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -68,7 +68,7 @@ static object *add PROTO((object *, object *)); static object *sub PROTO((object *, object *)); static object *mul PROTO((object *, object *)); static object *divide PROTO((object *, object *)); -static object *rem PROTO((object *, object *)); +static object *mod PROTO((object *, object *)); static object *neg PROTO((object *)); static object *pos PROTO((object *)); static object *not PROTO((object *)); @@ -571,7 +571,7 @@ eval_code(co, globals, locals, owner, arg) case BINARY_MODULO: w = POP(); v = POP(); - x = rem(v, w); + x = mod(v, w); DECREF(v); DECREF(w); PUSH(x); @@ -1742,18 +1742,18 @@ flushline() } -#define BINOP(opname, ropname) \ - do { \ - if (is_instanceobject(v) || is_instanceobject(w)) \ - return instancebinop(v, w, opname, ropname); \ - } while (0) +#define BINOP(opname, ropname, thisfunc) \ + if (!is_instanceobject(v) && !is_instanceobject(w)) \ + ; \ + else \ + return instancebinop(v, w, opname, ropname, thisfunc) static object * or(v, w) object *v, *w; { - BINOP("__or__", "__ror__"); + BINOP("__or__", "__ror__", or); if (v->ob_type->tp_as_number != NULL) { object *x; object * (*f) FPROTO((object *, object *)); @@ -1774,7 +1774,7 @@ static object * xor(v, w) object *v, *w; { - BINOP("__xor__", "__rxor__"); + BINOP("__xor__", "__rxor__", xor); if (v->ob_type->tp_as_number != NULL) { object *x; object * (*f) FPROTO((object *, object *)); @@ -1795,7 +1795,7 @@ static object * and(v, w) object *v, *w; { - BINOP("__and__", "__rand__"); + BINOP("__and__", "__rand__", and); if (v->ob_type->tp_as_number != NULL) { object *x; object * (*f) FPROTO((object *, object *)); @@ -1816,7 +1816,7 @@ static object * lshift(v, w) object *v, *w; { - BINOP("__lshift__", "__rlshift__"); + BINOP("__lshift__", "__rlshift__", lshift); if (v->ob_type->tp_as_number != NULL) { object *x; object * (*f) FPROTO((object *, object *)); @@ -1837,7 +1837,7 @@ static object * rshift(v, w) object *v, *w; { - BINOP("__rshift__", "__rrshift__"); + BINOP("__rshift__", "__rrshift__", rshift); if (v->ob_type->tp_as_number != NULL) { object *x; object * (*f) FPROTO((object *, object *)); @@ -1858,7 +1858,7 @@ static object * add(v, w) object *v, *w; { - BINOP("__add__", "__radd__"); + BINOP("__add__", "__radd__", add); if (v->ob_type->tp_as_sequence != NULL) return (*v->ob_type->tp_as_sequence->sq_concat)(v, w); else if (v->ob_type->tp_as_number != NULL) { @@ -1878,7 +1878,7 @@ static object * sub(v, w) object *v, *w; { - BINOP("__sub__", "__rsub__"); + BINOP("__sub__", "__rsub__", sub); if (v->ob_type->tp_as_number != NULL) { object *x; if (coerce(&v, &w) != 0) @@ -1898,7 +1898,7 @@ mul(v, w) { typeobject *tp; tp = v->ob_type; - BINOP("__mul__", "__rmul__"); + BINOP("__mul__", "__rmul__", mul); if (tp->tp_as_number != NULL && w->ob_type->tp_as_sequence != NULL && !is_instanceobject(v)) { @@ -1942,7 +1942,7 @@ static object * divide(v, w) object *v, *w; { - BINOP("__div__", "__rdiv__"); + BINOP("__div__", "__rdiv__", divide); if (v->ob_type->tp_as_number != NULL) { object *x; if (coerce(&v, &w) != 0) @@ -1957,13 +1957,13 @@ divide(v, w) } static object * -rem(v, w) +mod(v, w) object *v, *w; { if (is_stringobject(v)) { return formatstring(v, w); } - BINOP("__mod__", "__rmod__"); + BINOP("__mod__", "__rmod__", mod); if (v->ob_type->tp_as_number != NULL) { object *x; if (coerce(&v, &w) != 0) |