mirror of
https://github.com/myhdl/myhdl.git
synced 2024-12-14 07:44:38 +08:00
Fix #114
This commit is contained in:
parent
97f9b3479b
commit
68ac94cc54
@ -777,6 +777,14 @@ class _ConvertVisitor(ast.NodeVisitor, _ConversionMixin):
|
||||
self.write(")")
|
||||
|
||||
def visit_UnaryOp(self, node):
|
||||
# in python3 a negative Num is represented as an USub of a positive Num
|
||||
# Fix: restore python2 behavior by a shortcut: invert value of Num, inherit
|
||||
# vhdl type from UnaryOp node, and visit the modified operand
|
||||
if isinstance(node.op, ast.USub) and isinstance(node.operand, ast.Num):
|
||||
node.operand.n = -node.operand.n
|
||||
node.operand.vhd = node.vhd
|
||||
self.visit(node.operand)
|
||||
return
|
||||
pre, suf = self.inferCast(node.vhd, node.vhdOri)
|
||||
self.write(pre)
|
||||
self.write("(")
|
||||
|
Loading…
x
Reference in New Issue
Block a user