41 assert tree.data ==
'portdecltype',
"Expecting portdecltype"
42 new_tree = Tree(
'sigdecltype', tree.children, meta=tree.meta)
43 new_tree.children[0] = Tree(
'sigdecl', [tree.children[0].children[0]])
44 new_tree.meta.direction = tree.direction
48 with self.
ctx.add_values(port_decl_to_remove=[]):
50 if self.
ctx.port_decl_to_remove:
51 tree.children = list(filter(
lambda x: x
not in self.
ctx.port_decl_to_remove, tree.children))
55 for i
in range(len(tree.children) - 1, -1, -1):
56 if tree.children[i].data ==
'sigdecltype':
59 elif tree.children[i].data ==
'portdecltype':
63 tree.children = tree.children[:insertion_pos + 1] + new_sig_decls + tree.children[insertion_pos + 1:]
79 if self.
ctx.current_port_decl_node
and tree.children[0] ==
'array':
80 if self.
ctx.current_port_decl_node.children[0].data ==
'inportdecl':
81 with self.
ctx.add_values(port_erasure=
True):
83 self.
ctx.current_port_decl_node.direction =
'input'
84 self.
ctx.port_decl_to_remove.append(self.
ctx.current_port_decl_node)
85 elif self.
ctx.current_port_decl_node.children[0].data ==
'outportdecl':
86 self.
ctx.current_port_decl_node.direction =
'output'
88 raise ValueError(
"Unknown port type")
89 elif self.
ctx.port_erasure:
90 if tree.children[0]
in [
'sc_in',
'sc_out']:
91 return tree.children[1]