support true division
This commit is contained in:
parent
fda3c3ddae
commit
aee0bfedcc
@ -161,12 +161,14 @@ class CodeGenerator:
|
|||||||
self.maxStack = 0
|
self.maxStack = 0
|
||||||
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 == "generators":
|
elif feature == "generators":
|
||||||
self.graph.setFlag(CO_GENERATOR_ALLOWED)
|
self.graph.setFlag(CO_GENERATOR_ALLOWED)
|
||||||
|
|
||||||
@ -975,7 +977,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, 'BINARY_DIVIDE')
|
return self.binaryOp(node, self._div_op)
|
||||||
|
|
||||||
def visitFloorDiv(self, node):
|
def visitFloorDiv(self, node):
|
||||||
return self.binaryOp(node, 'BINARY_FLOOR_DIVIDE')
|
return self.binaryOp(node, 'BINARY_FLOOR_DIVIDE')
|
||||||
|
@ -161,12 +161,14 @@ class CodeGenerator:
|
|||||||
self.maxStack = 0
|
self.maxStack = 0
|
||||||
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 == "generators":
|
elif feature == "generators":
|
||||||
self.graph.setFlag(CO_GENERATOR_ALLOWED)
|
self.graph.setFlag(CO_GENERATOR_ALLOWED)
|
||||||
|
|
||||||
@ -975,7 +977,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, 'BINARY_DIVIDE')
|
return self.binaryOp(node, self._div_op)
|
||||||
|
|
||||||
def visitFloorDiv(self, node):
|
def visitFloorDiv(self, node):
|
||||||
return self.binaryOp(node, 'BINARY_FLOOR_DIVIDE')
|
return self.binaryOp(node, 'BINARY_FLOOR_DIVIDE')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user