Reference Guide  2.5.0
psyclone.psyir.nodes.node.ChildrenList Class Reference
Inheritance diagram for psyclone.psyir.nodes.node.ChildrenList:
Collaboration diagram for psyclone.psyir.nodes.node.ChildrenList:

Public Member Functions

def __init__ (self, node, validation_function, validation_text)
 
def append (self, item)
 
def __setitem__ (self, index, item)
 
def insert (self, index, item)
 
def extend (self, items)
 
def __delitem__ (self, index)
 
def remove (self, item)
 
def pop (self, index=-1)
 
def reverse (self)
 
def clear (self)
 
def sort (self, reverse=False, key=None)
 

Detailed Description

Customized list to keep track of the children nodes. It is initialised with
a callback function that allows the validation of the inserted children.
Since this is a subclass of the standard list, all operations (e.g. append,
insert, extend, comparisons, list arithmetic operations) are conserved and
make use of the validation. They also trigger an update of all ancestor
nodes so that action can be taken in order to keep the tree consistent when
necessary (e.g. to update the data-movement clauses on an OpenACC data
region).

:param node: reference to the node where the list belongs.
:type node: :py:class:`psyclone.psyir.nodes.Node`
:param validation_function: callback function to the validation method.
:type validation_function: \
        function(int, :py:class:`psyclone.psyir.nodes.Node`)
:param str validation_text: textual representation of the valid children.

Definition at line 94 of file node.py.

Member Function Documentation

◆ __delitem__()

def psyclone.psyir.nodes.node.ChildrenList.__delitem__ (   self,
  index 
)
 Extends list __delitem__ method with children node validation.

:param int index: position where to insert the item.

Definition at line 266 of file node.py.

266  def __delitem__(self, index):
267  ''' Extends list __delitem__ method with children node validation.
268 
269  :param int index: position where to insert the item.
270 
271  '''
272  positiveindex = index if index >= 0 else len(self) - index
273  for position in range(positiveindex + 1, len(self)):
274  self._validate_item(position - 1, self[position])
275  self._del_parent_link(self[index])
276  super().__delitem__(index)
277  self._node_reference.update_signal()
278 

References psyclone.psyir.nodes.node.ChildrenList._del_parent_link(), psyclone.psyir.nodes.node.ChildrenList._node_reference, and psyclone.psyir.nodes.node.ChildrenList._validate_item().

Here is the call graph for this function:

◆ __setitem__()

def psyclone.psyir.nodes.node.ChildrenList.__setitem__ (   self,
  index,
  item 
)
 Extends list __setitem__ method with children node validation.

:param int index: position where to insert the item.
:param item: item to be inserted to the list.
:type item: :py:class:`psyclone.psyir.nodes.Node`

Definition at line 216 of file node.py.

216  def __setitem__(self, index, item):
217  ''' Extends list __setitem__ method with children node validation.
218 
219  :param int index: position where to insert the item.
220  :param item: item to be inserted to the list.
221  :type item: :py:class:`psyclone.psyir.nodes.Node`
222 
223  '''
224  self._validate_item(index, item)
225  self._check_is_orphan(item)
226  self._del_parent_link(self[index])
227  super().__setitem__(index, item)
228  self._set_parent_link(item)
229  self._node_reference.update_signal()
230 

References psyclone.psyir.nodes.node.ChildrenList._check_is_orphan(), psyclone.psyir.nodes.node.ChildrenList._del_parent_link(), psyclone.psyir.nodes.node.ChildrenList._node_reference, psyclone.psyir.nodes.node.ChildrenList._set_parent_link(), and psyclone.psyir.nodes.node.ChildrenList._validate_item().

Here is the call graph for this function:

◆ append()

def psyclone.psyir.nodes.node.ChildrenList.append (   self,
  item 
)
 Extends list append method with children node validation.

:param item: item to be appened to the list.
:type item: :py:class:`psyclone.psyir.nodes.Node`

Definition at line 203 of file node.py.

203  def append(self, item):
204  ''' Extends list append method with children node validation.
205 
206  :param item: item to be appened to the list.
207  :type item: :py:class:`psyclone.psyir.nodes.Node`
208 
209  '''
210  self._validate_item(len(self), item)
211  self._check_is_orphan(item)
212  super().append(item)
213  self._set_parent_link(item)
214  self._node_reference.update_signal()
215 

References psyclone.psyir.nodes.node.ChildrenList._check_is_orphan(), psyclone.psyir.nodes.node.ChildrenList._node_reference, psyclone.psyir.nodes.node.ChildrenList._set_parent_link(), and psyclone.psyir.nodes.node.ChildrenList._validate_item().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ clear()

def psyclone.psyir.nodes.node.ChildrenList.clear (   self)
 Wipes the list. 

Definition at line 320 of file node.py.

320  def clear(self):
321  ''' Wipes the list. '''
322  for item in self:
323  self._del_parent_link(item)
324  super().clear()
325  # Signal that the tree has changed.
326  self._node_reference.update_signal()
327 

References psyclone.psyir.nodes.node.ChildrenList._del_parent_link(), and psyclone.psyir.nodes.node.ChildrenList._node_reference.

Here is the call graph for this function:

◆ extend()

def psyclone.psyir.nodes.node.ChildrenList.extend (   self,
  items 
)
 Extends list extend method with children node validation.

:param items: list of items to be appened to the list.
:type items: list of :py:class:`psyclone.psyir.nodes.Node`

Definition at line 249 of file node.py.

249  def extend(self, items):
250  ''' Extends list extend method with children node validation.
251 
252  :param items: list of items to be appened to the list.
253  :type items: list of :py:class:`psyclone.psyir.nodes.Node`
254 
255  '''
256  for index, item in enumerate(items):
257  self._validate_item(len(self) + index, item)
258  self._check_is_orphan(item)
259  super().extend(items)
260  for item in items:
261  self._set_parent_link(item)
262  self._node_reference.update_signal()
263 

References psyclone.psyir.nodes.node.ChildrenList._check_is_orphan(), psyclone.psyir.nodes.node.ChildrenList._node_reference, psyclone.psyir.nodes.node.ChildrenList._set_parent_link(), and psyclone.psyir.nodes.node.ChildrenList._validate_item().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ insert()

def psyclone.psyir.nodes.node.ChildrenList.insert (   self,
  index,
  item 
)
 Extends list insert method with children node validation.

:param int index: position where to insert the item.
:param item: item to be inserted to the list.
:type item: :py:class:`psyclone.psyir.nodes.Node`

Definition at line 231 of file node.py.

231  def insert(self, index, item):
232  ''' Extends list insert method with children node validation.
233 
234  :param int index: position where to insert the item.
235  :param item: item to be inserted to the list.
236  :type item: :py:class:`psyclone.psyir.nodes.Node`
237 
238  '''
239  positiveindex = index if index >= 0 else len(self) - index
240  self._validate_item(positiveindex, item)
241  self._check_is_orphan(item)
242  # Check that all displaced items will still in valid positions
243  for position in range(positiveindex, len(self)):
244  self._validate_item(position + 1, self[position])
245  super().insert(index, item)
246  self._set_parent_link(item)
247  self._node_reference.update_signal()
248 

References psyclone.psyir.nodes.node.ChildrenList._check_is_orphan(), psyclone.psyir.nodes.node.ChildrenList._node_reference, psyclone.psyir.nodes.node.ChildrenList._set_parent_link(), and psyclone.psyir.nodes.node.ChildrenList._validate_item().

Here is the call graph for this function:

◆ pop()

def psyclone.psyir.nodes.node.ChildrenList.pop (   self,
  index = -1 
)
 Extends list pop method with children node validation.

:param int index: position of the item that is popped out, if not \
    given, the last element is popped out.

:returns: the last value or the given index value from the list.
:rtype: :py:class:`psyclone.psyir.nodes.Node`

Definition at line 292 of file node.py.

292  def pop(self, index=-1):
293  ''' Extends list pop method with children node validation.
294 
295  :param int index: position of the item that is popped out, if not \
296  given, the last element is popped out.
297 
298  :returns: the last value or the given index value from the list.
299  :rtype: :py:class:`psyclone.psyir.nodes.Node`
300 
301  '''
302  positiveindex = index if index >= 0 else len(self) - index
303  # Check if displaced items after 'positiveindex' will still be valid
304  for position in range(positiveindex + 1, len(self)):
305  self._validate_item(position - 1, self[position])
306  self._del_parent_link(self[index])
307  obj = super().pop(index)
308  self._node_reference.update_signal()
309  return obj
310 

References psyclone.psyir.nodes.node.ChildrenList._del_parent_link(), psyclone.psyir.nodes.node.ChildrenList._node_reference, and psyclone.psyir.nodes.node.ChildrenList._validate_item().

Here is the call graph for this function:

◆ remove()

def psyclone.psyir.nodes.node.ChildrenList.remove (   self,
  item 
)
 Extends list remove method with children node validation.

:param item: item to be deleted the list.
:type item: :py:class:`psyclone.psyir.nodes.Node`

Definition at line 279 of file node.py.

279  def remove(self, item):
280  ''' Extends list remove method with children node validation.
281 
282  :param item: item to be deleted the list.
283  :type item: :py:class:`psyclone.psyir.nodes.Node`
284 
285  '''
286  for position in range(self.index(item) + 1, len(self)):
287  self._validate_item(position - 1, self[position])
288  self._del_parent_link(item)
289  super().remove(item)
290  self._node_reference.update_signal()
291 

References psyclone.psyir.nodes.node.ChildrenList._del_parent_link(), psyclone.psyir.nodes.node.ChildrenList._node_reference, and psyclone.psyir.nodes.node.ChildrenList._validate_item().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reverse()

def psyclone.psyir.nodes.node.ChildrenList.reverse (   self)
 Extends list reverse method with children node validation. 

Definition at line 311 of file node.py.

311  def reverse(self):
312  ''' Extends list reverse method with children node validation. '''
313  for index, item in enumerate(self):
314  self._validate_item(len(self) - index - 1, item)
315  super().reverse()
316  # Reversing the order of e.g. Statements may alter the read/write
317  # properties of any References.
318  self._node_reference.update_signal()
319 

References psyclone.psyir.nodes.node.ChildrenList._node_reference, and psyclone.psyir.nodes.node.ChildrenList._validate_item().

Here is the call graph for this function:

◆ sort()

def psyclone.psyir.nodes.node.ChildrenList.sort (   self,
  reverse = False,
  key = None 
)
Override the default sort() implementation as this is not supported
for a ChildrenList.

:raises NotImplementedError: it makes no sense to sort the Children of
                             a Node.

Definition at line 328 of file node.py.

328  def sort(self, reverse=False, key=None):
329  '''Override the default sort() implementation as this is not supported
330  for a ChildrenList.
331 
332  :raises NotImplementedError: it makes no sense to sort the Children of
333  a Node.
334  '''
335  raise NotImplementedError("Sorting the Children of a Node is not "
336  "supported.")
337 
338 

The documentation for this class was generated from the following file: