Reference Guide  2.5.0
schedule.py
1 # -----------------------------------------------------------------------------
2 # BSD 3-Clause License
3 #
4 # Copyright (c) 2017-2024, Science and Technology Facilities Council.
5 # All rights reserved.
6 #
7 # Redistribution and use in source and binary forms, with or without
8 # modification, are permitted provided that the following conditions are met:
9 #
10 # * Redistributions of source code must retain the above copyright notice, this
11 # list of conditions and the following disclaimer.
12 #
13 # * Redistributions in binary form must reproduce the above copyright notice,
14 # this list of conditions and the following disclaimer in the documentation
15 # and/or other materials provided with the distribution.
16 #
17 # * Neither the name of the copyright holder nor the names of its
18 # contributors may be used to endorse or promote products derived from
19 # this software without specific prior written permission.
20 #
21 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 # COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 # POSSIBILITY OF SUCH DAMAGE.
33 # -----------------------------------------------------------------------------
34 # Authors R. W. Ford, A. R. Porter and S. Siso, STFC Daresbury Lab
35 # I. Kavcic, Met Office
36 # J. Henrichs, Bureau of Meteorology
37 # -----------------------------------------------------------------------------
38 
39 ''' This module contains the Schedule node implementation.'''
40 
41 from psyclone.psyir.nodes.scoping_node import ScopingNode
42 from psyclone.psyir.nodes.statement import Statement
43 
44 
46  ''' Stores schedule information for a sequence of statements (supplied
47  as a list of children).
48 
49  '''
50  # Textual description of the node.
51  _children_valid_format = "[Statement]*"
52  _text_name = "Schedule"
53  _colour = "white"
54 
55  @staticmethod
56  def _validate_child(position, child):
57  '''
58  :param int position: the position to be validated.
59  :param child: a child to be validated.
60  :type child: :py:class:`psyclone.psyir.nodes.Node`
61 
62  :return: whether the given child and position are valid for this node.
63  :rtype: bool
64 
65  '''
66  # pylint: disable=unused-argument
67  return isinstance(child, Statement)
68 
69  def __getitem__(self, index):
70  '''
71  Overload the subscript notation ([int]) to access specific statements
72  in the Schedule.
73 
74  :param int index: index of the statement to access.
75  :returns: statement in a given position in the Schedule sequence.
76  :rtype: :py:class:`psyclone.psyir.nodes.Node`
77  '''
78  return self._children_children[index]
79 
80  def __str__(self):
81  result = self.coloured_namecoloured_name(False) + ":\n"
82  for entity in self._children_children:
83  result += str(entity) + "\n"
84  result += "End " + self.coloured_namecoloured_name(False)
85  return result
86 
87  def gen_code(self, parent):
88  '''
89  A Schedule does not have any direct Fortran representation. We just
90  call gen_code() for all of its children.
91 
92  :param parent: node in the f2pygen AST to which to add content.
93  :type parent: :py:class:`psyclone.f2pygen.BaseGen`
94  '''
95  for child in self.childrenchildrenchildren:
96  child.gen_code(parent)
97 
98 
99 # For AutoAPI documentation generation
100 __all__ = ['Schedule']
def children(self, my_children)
Definition: node.py:935
def coloured_name(self, colour=True)
Definition: node.py:453