mirror of
https://github.com/python/cpython.git
synced 2025-08-27 20:25:18 +00:00
Get rid of last vestiges of BINARY_DIVIDE.
This commit is contained in:
parent
e4993c7ac7
commit
c6d210ca76
6 changed files with 3 additions and 29 deletions
|
@ -189,11 +189,6 @@ Implements \code{TOS = TOS1 ** TOS}.
|
||||||
Implements \code{TOS = TOS1 * TOS}.
|
Implements \code{TOS = TOS1 * TOS}.
|
||||||
\end{opcodedesc}
|
\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}{}
|
\begin{opcodedesc}{BINARY_FLOOR_DIVIDE}{}
|
||||||
Implements \code{TOS = TOS1 // TOS}.
|
Implements \code{TOS = TOS1 // TOS}.
|
||||||
\end{opcodedesc}
|
\end{opcodedesc}
|
||||||
|
|
|
@ -26,7 +26,7 @@ extern "C" {
|
||||||
#define BINARY_POWER 19
|
#define BINARY_POWER 19
|
||||||
|
|
||||||
#define BINARY_MULTIPLY 20
|
#define BINARY_MULTIPLY 20
|
||||||
#define BINARY_DIVIDE 21
|
|
||||||
#define BINARY_MODULO 22
|
#define BINARY_MODULO 22
|
||||||
#define BINARY_ADD 23
|
#define BINARY_ADD 23
|
||||||
#define BINARY_SUBTRACT 24
|
#define BINARY_SUBTRACT 24
|
||||||
|
|
|
@ -206,14 +206,12 @@ class CodeGenerator:
|
||||||
self.setups = misc.Stack()
|
self.setups = misc.Stack()
|
||||||
self.last_lineno = None
|
self.last_lineno = None
|
||||||
self._setupGraphDelegation()
|
self._setupGraphDelegation()
|
||||||
self._div_op = "BINARY_DIVIDE"
|
|
||||||
|
|
||||||
# XXX set flags based on future features
|
# XXX set flags based on future features
|
||||||
futures = self.get_module().futures
|
futures = self.get_module().futures
|
||||||
for feature in futures:
|
for feature in futures:
|
||||||
if feature == "division":
|
if feature == "division":
|
||||||
self.graph.setFlag(CO_FUTURE_DIVISION)
|
self.graph.setFlag(CO_FUTURE_DIVISION)
|
||||||
self._div_op = "BINARY_TRUE_DIVIDE"
|
|
||||||
elif feature == "absolute_import":
|
elif feature == "absolute_import":
|
||||||
self.graph.setFlag(CO_FUTURE_ABSIMPORT)
|
self.graph.setFlag(CO_FUTURE_ABSIMPORT)
|
||||||
elif feature == "with_statement":
|
elif feature == "with_statement":
|
||||||
|
@ -1177,7 +1175,7 @@ class CodeGenerator:
|
||||||
return self.binaryOp(node, 'BINARY_MULTIPLY')
|
return self.binaryOp(node, 'BINARY_MULTIPLY')
|
||||||
|
|
||||||
def visitDiv(self, node):
|
def visitDiv(self, node):
|
||||||
return self.binaryOp(node, self._div_op)
|
return self.binaryOp(node, 'BINARY_TRUE_DIVIDE')
|
||||||
|
|
||||||
def visitFloorDiv(self, node):
|
def visitFloorDiv(self, node):
|
||||||
return self.binaryOp(node, 'BINARY_FLOOR_DIVIDE')
|
return self.binaryOp(node, 'BINARY_FLOOR_DIVIDE')
|
||||||
|
|
|
@ -61,7 +61,7 @@ def_op('UNARY_INVERT', 15)
|
||||||
def_op('LIST_APPEND', 18)
|
def_op('LIST_APPEND', 18)
|
||||||
def_op('BINARY_POWER', 19)
|
def_op('BINARY_POWER', 19)
|
||||||
def_op('BINARY_MULTIPLY', 20)
|
def_op('BINARY_MULTIPLY', 20)
|
||||||
def_op('BINARY_DIVIDE', 21)
|
|
||||||
def_op('BINARY_MODULO', 22)
|
def_op('BINARY_MODULO', 22)
|
||||||
def_op('BINARY_ADD', 23)
|
def_op('BINARY_ADD', 23)
|
||||||
def_op('BINARY_SUBTRACT', 24)
|
def_op('BINARY_SUBTRACT', 24)
|
||||||
|
|
|
@ -1073,19 +1073,6 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throw)
|
||||||
if (x != NULL) continue;
|
if (x != NULL) continue;
|
||||||
break;
|
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:
|
case BINARY_TRUE_DIVIDE:
|
||||||
w = POP();
|
w = POP();
|
||||||
v = TOP();
|
v = TOP();
|
||||||
|
|
|
@ -479,11 +479,6 @@ fold_binops_on_constants(unsigned char *codestr, PyObject *consts)
|
||||||
case BINARY_MULTIPLY:
|
case BINARY_MULTIPLY:
|
||||||
newconst = PyNumber_Multiply(v, w);
|
newconst = PyNumber_Multiply(v, w);
|
||||||
break;
|
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:
|
case BINARY_TRUE_DIVIDE:
|
||||||
newconst = PyNumber_TrueDivide(v, w);
|
newconst = PyNumber_TrueDivide(v, w);
|
||||||
break;
|
break;
|
||||||
|
@ -1302,7 +1297,6 @@ opcode_stack_effect(int opcode, int oparg)
|
||||||
|
|
||||||
case BINARY_POWER:
|
case BINARY_POWER:
|
||||||
case BINARY_MULTIPLY:
|
case BINARY_MULTIPLY:
|
||||||
case BINARY_DIVIDE:
|
|
||||||
case BINARY_MODULO:
|
case BINARY_MODULO:
|
||||||
case BINARY_ADD:
|
case BINARY_ADD:
|
||||||
case BINARY_SUBTRACT:
|
case BINARY_SUBTRACT:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue