37 ''' This module contains the ScopingNode implementation.'''
45 ''' Abstract node that has an associated Symbol Table to keep track of
46 symbols declared in its scope (symbols that can be accessed by this node
47 and any of its descendants). If a pre-existing symbol table is provided,
48 it will be attached to the node (raising an error if the symbol table
49 is already attached to another scope), otherwise a new empty Symbol Table
52 :param children: the PSyIR nodes that are children of this node.
53 :type children: List[:py:class:`psyclone.psyir.nodes.Node`]
54 :param parent: the parent node of this node in the PSyIR.
55 :type parent: Optional[:py:class:`psyclone.psyir.nodes.Node`]
56 :param symbol_table: attach the given symbol table to the new node.
58 Optional[:py:class:`psyclone.psyir.symbols.SymbolTable`]
62 _symbol_table_class = SymbolTable
64 def __init__(self, children=None, parent=None, symbol_table=None):
65 super().__init__(children=children, parent=parent)
68 if symbol_table
is not None:
70 symbol_table.attach(self)
77 Checks whether two nodes are equal. Scoping nodes are equal if their
78 symbol tables are equal.
80 :param object other: the object to check equality to.
82 :returns: whether other is equal to self.
85 is_eq = super().
__eq__(other)
89 def _refine_copy(self, other):
90 ''' Refine the object attributes when a shallow copy is not the most
91 appropriate operation during a call to the copy() method.
93 :param other: object we are copying from.
94 :type other: :py:class:`psyclone.psyir.node.Node`
97 super(ScopingNode, self)._refine_copy(other)
98 self.
_symbol_table_symbol_table = other.symbol_table.deep_copy()
114 for node
in self.
walkwalk((Reference, Loop)):
115 if isinstance(node, Reference):
116 if node.symbol
in other.symbol_table.symbols:
118 if isinstance(node, Loop)
and node._variable:
119 if node.variable
in other.symbol_table.symbols:
124 def symbol_table(self):
126 :returns: table containing symbol information for this scope.
127 :rtype: :py:class:`psyclone.psyGen.SymbolTable`
133 __all__ = [
'ScopingNode']
def walk(self, my_type, stop_type=None, depth=None)