summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeal Norwitz <nnorwitz@gmail.com>2006-03-16 06:02:10 (GMT)
committerNeal Norwitz <nnorwitz@gmail.com>2006-03-16 06:02:10 (GMT)
commitc6d210ca7673c6ce0cb4b77ada22087f58372efc (patch)
tree905c39266f91fbeebbeb69a5848f9eb5808bc32c
parente4993c7ac72842d18fb5689d7c77be2246b65708 (diff)
downloadcpython-c6d210ca7673c6ce0cb4b77ada22087f58372efc.zip
cpython-c6d210ca7673c6ce0cb4b77ada22087f58372efc.tar.gz
cpython-c6d210ca7673c6ce0cb4b77ada22087f58372efc.tar.bz2
Get rid of last vestiges of BINARY_DIVIDE.
-rw-r--r--Doc/lib/libdis.tex5
-rw-r--r--Include/opcode.h2
-rw-r--r--Lib/compiler/pycodegen.py4
-rw-r--r--Lib/opcode.py2
-rw-r--r--Python/ceval.c13
-rw-r--r--Python/compile.c6
6 files changed, 3 insertions, 29 deletions
diff --git a/Doc/lib/libdis.tex b/Doc/lib/libdis.tex
index 67691b7..a5b2c2c 100644
--- a/Doc/lib/libdis.tex
+++ b/Doc/lib/libdis.tex
@@ -189,11 +189,6 @@ Implements \code{TOS = TOS1 ** TOS}.
Implements \code{TOS = TOS1 * TOS}.
\end{opcodedesc}
-\begin{opcodedesc}{BINARY_DIVIDE}{}
-Implements \code{TOS = TOS1 / TOS} when
-\code{from __future__ import division} is not in effect.
-\end{opcodedesc}
-
\begin{opcodedesc}{BINARY_FLOOR_DIVIDE}{}
Implements \code{TOS = TOS1 // TOS}.
\end{opcodedesc}
diff --git a/Include/opcode.h b/Include/opcode.h
index d8cb2cd..d05588a 100644
--- a/Include/opcode.h
+++ b/Include/opcode.h
@@ -26,7 +26,7 @@ extern "C" {
#define BINARY_POWER 19
#define BINARY_MULTIPLY 20
-#define BINARY_DIVIDE 21
+
#define BINARY_MODULO 22
#define BINARY_ADD 23
#define BINARY_SUBTRACT 24
diff --git a/Lib/compiler/pycodegen.py b/Lib/compiler/pycodegen.py
index f25b3fb..e34120e 100644
--- a/Lib/compiler/pycodegen.py
+++ b/Lib/compiler/pycodegen.py
@@ -206,14 +206,12 @@ class CodeGenerator:
self.setups = misc.Stack()
self.last_lineno = None
self._setupGraphDelegation()
- self._div_op = "BINARY_DIVIDE"
# XXX set flags based on future features
futures = self.get_module().futures
for feature in futures:
if feature == "division":
self.graph.setFlag(CO_FUTURE_DIVISION)
- self._div_op = "BINARY_TRUE_DIVIDE"
elif feature == "absolute_import":
self.graph.setFlag(CO_FUTURE_ABSIMPORT)
elif feature == "with_statement":
@@ -1177,7 +1175,7 @@ class CodeGenerator:
return self.binaryOp(node, 'BINARY_MULTIPLY')
def visitDiv(self, node):
- return self.binaryOp(node, self._div_op)
+ return self.binaryOp(node, 'BINARY_TRUE_DIVIDE')
def visitFloorDiv(self, node):
return self.binaryOp(node, 'BINARY_FLOOR_DIVIDE')
diff --git a/Lib/opcode.py b/Lib/opcode.py
index 095ca42..2b9212f 100644
--- a/Lib/opcode.py
+++ b/Lib/opcode.py
@@ -61,7 +61,7 @@ def_op('UNARY_INVERT', 15)
def_op('LIST_APPEND', 18)
def_op('BINARY_POWER', 19)
def_op('BINARY_MULTIPLY', 20)
-def_op('BINARY_DIVIDE', 21)
+
def_op('BINARY_MODULO', 22)
def_op('BINARY_ADD', 23)
def_op('BINARY_SUBTRACT', 24)
diff --git a/Python/ceval.c b/Python/ceval.c
index c854fcf..1a35610 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -1073,19 +1073,6 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throw)
if (x != NULL) continue;
break;
- case BINARY_DIVIDE:
- if (!_Py_QnewFlag) {
- w = POP();
- v = TOP();
- x = PyNumber_Divide(v, w);
- Py_DECREF(v);
- Py_DECREF(w);
- SET_TOP(x);
- if (x != NULL) continue;
- break;
- }
- /* -Qnew is in effect: fall through to
- BINARY_TRUE_DIVIDE */
case BINARY_TRUE_DIVIDE:
w = POP();
v = TOP();
diff --git a/Python/compile.c b/Python/compile.c
index cfc6ef1..9ce2bf7 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -479,11 +479,6 @@ fold_binops_on_constants(unsigned char *codestr, PyObject *consts)
case BINARY_MULTIPLY:
newconst = PyNumber_Multiply(v, w);
break;
- case BINARY_DIVIDE:
- /* Cannot fold this operation statically since
- the result can depend on the run-time presence
- of the -Qnew flag */
- return 0;
case BINARY_TRUE_DIVIDE:
newconst = PyNumber_TrueDivide(v, w);
break;
@@ -1302,7 +1297,6 @@ opcode_stack_effect(int opcode, int oparg)
case BINARY_POWER:
case BINARY_MULTIPLY:
- case BINARY_DIVIDE:
case BINARY_MODULO:
case BINARY_ADD:
case BINARY_SUBTRACT: