mirror of
https://github.com/myhdl/myhdl.git
synced 2024-12-14 07:44:38 +08:00
addded code to handle deprecated NameConstant values
This commit is contained in:
parent
3340aab567
commit
5d63ac4a52
@ -1195,7 +1195,8 @@ class _ConvertVisitor(ast.NodeVisitor, _ConversionMixin):
|
|||||||
if sys.version_info >= (3, 8, 0):
|
if sys.version_info >= (3, 8, 0):
|
||||||
|
|
||||||
def visit_Constant(self, node):
|
def visit_Constant(self, node):
|
||||||
if isinstance(node.value, bool):
|
if node.value in (True, False, None):
|
||||||
|
# NameConstant
|
||||||
node.id = str(node.value)
|
node.id = str(node.value)
|
||||||
self.getName(node)
|
self.getName(node)
|
||||||
elif isinstance(node.value, int):
|
elif isinstance(node.value, int):
|
||||||
@ -1227,9 +1228,6 @@ class _ConvertVisitor(ast.NodeVisitor, _ConversionMixin):
|
|||||||
if isinstance(node.vhd, vhd_unsigned):
|
if isinstance(node.vhd, vhd_unsigned):
|
||||||
typemark = 'unsigned'
|
typemark = 'unsigned'
|
||||||
self.write("%s'(\"%s\")" % (typemark, node.value))
|
self.write("%s'(\"%s\")" % (typemark, node.value))
|
||||||
else:
|
|
||||||
node.id = str(node.value)
|
|
||||||
self.getName(node)
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
||||||
@ -2294,10 +2292,11 @@ class _AnnotateTypesVisitor(ast.NodeVisitor, _ConversionMixin):
|
|||||||
if sys.version_info >= (3, 8, 0):
|
if sys.version_info >= (3, 8, 0):
|
||||||
|
|
||||||
def visit_Constant(self, node):
|
def visit_Constant(self, node):
|
||||||
if isinstance(node.value, str):
|
if node.value is None:
|
||||||
|
# NameConstant
|
||||||
node.vhd = vhd_string()
|
node.vhd = vhd_string()
|
||||||
node.vhdOri = copy(node.vhd)
|
node.vhdOri = copy(node.vhd)
|
||||||
elif isinstance(node.value, bool):
|
elif node.value in (True, False):
|
||||||
node.vhd = inferVhdlObj(node.value)
|
node.vhd = inferVhdlObj(node.value)
|
||||||
node.vhdOri = copy(node.vhd)
|
node.vhdOri = copy(node.vhd)
|
||||||
elif isinstance(node.value, int):
|
elif isinstance(node.value, int):
|
||||||
@ -2306,10 +2305,6 @@ class _AnnotateTypesVisitor(ast.NodeVisitor, _ConversionMixin):
|
|||||||
else:
|
else:
|
||||||
node.vhd = vhd_nat()
|
node.vhd = vhd_nat()
|
||||||
node.vhdOri = copy(node.vhd)
|
node.vhdOri = copy(node.vhd)
|
||||||
else:
|
|
||||||
# NameConstant None
|
|
||||||
node.vhd = inferVhdlObj(node.value)
|
|
||||||
node.vhdOri = copy(node.vhd)
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
||||||
|
@ -894,14 +894,17 @@ class _ConvertVisitor(ast.NodeVisitor, _ConversionMixin):
|
|||||||
if sys.version_info >= (3, 8, 0):
|
if sys.version_info >= (3, 8, 0):
|
||||||
|
|
||||||
def visit_Constant(self, node):
|
def visit_Constant(self, node):
|
||||||
if isinstance(node.value, bool):
|
if node.value in (True, False, None):
|
||||||
|
# NameConstant
|
||||||
self.write(nameconstant_map[node.obj])
|
self.write(nameconstant_map[node.obj])
|
||||||
elif isinstance(node.value, int):
|
elif isinstance(node.value, int):
|
||||||
|
# Num
|
||||||
if self.context == _context.PRINT:
|
if self.context == _context.PRINT:
|
||||||
self.write('"%s"' % node.value)
|
self.write('"%s"' % node.value)
|
||||||
else:
|
else:
|
||||||
self.write(self.IntRepr(node.value))
|
self.write(self.IntRepr(node.value))
|
||||||
elif isinstance(node.value, str):
|
elif isinstance(node.value, str):
|
||||||
|
# Str
|
||||||
s = node.value
|
s = node.value
|
||||||
if self.context == _context.PRINT:
|
if self.context == _context.PRINT:
|
||||||
self.write('"%s"' % s)
|
self.write('"%s"' % s)
|
||||||
@ -909,8 +912,6 @@ class _ConvertVisitor(ast.NodeVisitor, _ConversionMixin):
|
|||||||
self.write("%s'b%s" % (len(s), s))
|
self.write("%s'b%s" % (len(s), s))
|
||||||
else:
|
else:
|
||||||
self.write(s)
|
self.write(s)
|
||||||
else:
|
|
||||||
self.write(nameconstant_map[node.obj])
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user