From: Jeremy Hylton Date: Mon, 17 Sep 2001 16:41:02 +0000 (+0000) Subject: support true division X-Git-Tag: v2.2.1c1~1778 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=aee0bfedcc56edffd995c5cd5c3a4c5ca0d960b7;p=thirdparty%2FPython%2Fcpython.git support true division --- diff --git a/Lib/compiler/pycodegen.py b/Lib/compiler/pycodegen.py index 0097482447c3..a019828e9ebb 100644 --- a/Lib/compiler/pycodegen.py +++ b/Lib/compiler/pycodegen.py @@ -161,12 +161,14 @@ class CodeGenerator: self.maxStack = 0 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 == "generators": self.graph.setFlag(CO_GENERATOR_ALLOWED) @@ -975,7 +977,7 @@ class CodeGenerator: return self.binaryOp(node, 'BINARY_MULTIPLY') def visitDiv(self, node): - return self.binaryOp(node, 'BINARY_DIVIDE') + return self.binaryOp(node, self._div_op) def visitFloorDiv(self, node): return self.binaryOp(node, 'BINARY_FLOOR_DIVIDE') diff --git a/Tools/compiler/compiler/pycodegen.py b/Tools/compiler/compiler/pycodegen.py index 0097482447c3..a019828e9ebb 100644 --- a/Tools/compiler/compiler/pycodegen.py +++ b/Tools/compiler/compiler/pycodegen.py @@ -161,12 +161,14 @@ class CodeGenerator: self.maxStack = 0 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 == "generators": self.graph.setFlag(CO_GENERATOR_ALLOWED) @@ -975,7 +977,7 @@ class CodeGenerator: return self.binaryOp(node, 'BINARY_MULTIPLY') def visitDiv(self, node): - return self.binaryOp(node, 'BINARY_DIVIDE') + return self.binaryOp(node, self._div_op) def visitFloorDiv(self, node): return self.binaryOp(node, 'BINARY_FLOOR_DIVIDE')