Skip to content

Commit

Permalink
pyGHDL/dom: add some guards to avoid crash for optional fields
Browse files Browse the repository at this point in the history
  • Loading branch information
tgingold committed Jun 18, 2021
1 parent 823ee7d commit 2d84548
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion pyGHDL/dom/InterfaceItem.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ def parse(cls, generic):
name = NodeToName(generic)
mode = GetModeOfNode(generic)
subTypeIndication = GetSubtypeIndicationFromNode(generic, "generic", name)
value = GetExpressionFromNode(nodes.Get_Default_Value(generic))
default = nodes.Get_Default_Value(generic);
value = GetExpressionFromNode(default) if default else None

generic = cls(name, mode, subTypeIndication, value)

Expand Down
3 changes: 2 additions & 1 deletion pyGHDL/dom/Object.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ def __init__(
def parse(cls, node):
name = NodeToName(node)
subTypeIndication = GetSubtypeIndicationFromNode(node, "signal", name)
defaultExpression = GetExpressionFromNode(nodes.Get_Default_Value(node))
default = nodes.Get_Default_Value(node);
defaultExpression = GetExpressionFromNode(default) if default else None

signal = cls(name, subTypeIndication, defaultExpression)

Expand Down
2 changes: 2 additions & 0 deletions pyGHDL/dom/_Translate.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@
@export
def GetSubtypeIndicationFromNode(node, entity: str, name: str) -> SubTypeOrSymbol:
subTypeIndication = nodes.Get_Subtype_Indication(node)
if subTypeIndication is nodes.Null_Iir:
return None
subTypeKind = GetIirKindOfNode(subTypeIndication)

if subTypeKind == nodes.Iir_Kind.Simple_Name:
Expand Down

0 comments on commit 2d84548

Please sign in to comment.