Reference Guide  2.5.0
psyclone.f2pygen.SelectionGen Class Reference
Inheritance diagram for psyclone.f2pygen.SelectionGen:
Collaboration diagram for psyclone.f2pygen.SelectionGen:

Public Member Functions

def __init__ (self, parent, expr="UNSET", typeselect=False)
 
def addcase (self, casenames, content=None)
 
def adddefault (self)
 
- Public Member Functions inherited from psyclone.f2pygen.BaseGen
def __init__ (self, parent, root)
 
def parent (self)
 
def children (self)
 
def root (self)
 
def add (self, new_object, position=None)
 
def previous_loop (self)
 
def last_declaration (self)
 
def start_parent_loop (self, debug=False)
 

Detailed Description

 Generate a Fortran SELECT block 

Definition at line 1296 of file f2pygen.py.

Constructor & Destructor Documentation

◆ __init__()

def psyclone.f2pygen.SelectionGen.__init__ (   self,
  parent,
  expr = "UNSET",
  typeselect = False 
)
Construct a SelectionGen for creating a SELECT block

:param parent: node to which to add this select block as a child
:type parent: :py:class:`psyclone.f2pygen.BaseGen`
:param str expr: the CASE expression
:param bool typeselect: whether or not this is a SELECT TYPE rather
                        than a SELECT CASE

Definition at line 1300 of file f2pygen.py.

1300  def __init__(self, parent, expr="UNSET", typeselect=False):
1301  '''
1302  Construct a SelectionGen for creating a SELECT block
1303 
1304  :param parent: node to which to add this select block as a child
1305  :type parent: :py:class:`psyclone.f2pygen.BaseGen`
1306  :param str expr: the CASE expression
1307  :param bool typeselect: whether or not this is a SELECT TYPE rather
1308  than a SELECT CASE
1309  '''
1310  self._typeselect = typeselect
1311  reader = FortranStringReader(
1312  "SELECT CASE (x)\nCASE (1)\nCASE DEFAULT\nEND SELECT")
1313  reader.set_format(FortranFormat(True, True)) # free form, strict
1314  select_line = reader.next()
1315  self._case_line = reader.next()
1316  self._case_default_line = reader.next()
1317  end_select_line = reader.next()
1318  if self._typeselect:
1319  select = SelectType(parent.root, select_line)
1320  else:
1321  select = SelectCase(parent.root, select_line)
1322  endselect = EndSelect(select, end_select_line)
1323  select.expr = expr
1324  select.content.append(endselect)
1325  BaseGen.__init__(self, parent, select)
1326 

References psyclone.f2pygen.SelectionGen._case_default_line, psyclone.f2pygen.SelectionGen._case_line, and psyclone.f2pygen.SelectionGen._typeselect.

Member Function Documentation

◆ addcase()

def psyclone.f2pygen.SelectionGen.addcase (   self,
  casenames,
  content = None 
)
 Add a case to this select block 

Definition at line 1327 of file f2pygen.py.

1327  def addcase(self, casenames, content=None):
1328  ''' Add a case to this select block '''
1329  if content is None:
1330  content = []
1331  if self._typeselect:
1332  case = TypeCase(self.root, self._case_line)
1333  else:
1334  case = Case(self.root, self._case_line)
1335  case.items = [casenames]
1336  self.root.content.insert(0, case)
1337  idx = 0
1338  for stmt in content:
1339  idx += 1
1340  self.root.content.insert(idx, stmt.root)
1341 

References psyclone.f2pygen.SelectionGen._case_line, psyclone.f2pygen.SelectionGen._typeselect, psyclone.f2pygen.BaseGen.root(), psyclone.f2pygen.BaseDeclGen.root(), and psyclone.psyir.nodes.node.Node.root().

Here is the call graph for this function:

◆ adddefault()

def psyclone.f2pygen.SelectionGen.adddefault (   self)
 Add the default case to this select block 

Definition at line 1342 of file f2pygen.py.

1342  def adddefault(self):
1343  ''' Add the default case to this select block '''
1344  if self._typeselect:
1345  case_default = TypeCase(self.root, self._case_default_line)
1346  else:
1347  case_default = Case(self.root, self._case_default_line)
1348  self.root.content.insert(len(self.root.content)-1, case_default)
1349 
1350 

References psyclone.f2pygen.SelectionGen._case_default_line, psyclone.f2pygen.SelectionGen._typeselect, psyclone.f2pygen.BaseGen.root(), psyclone.f2pygen.BaseDeclGen.root(), and psyclone.psyir.nodes.node.Node.root().

Here is the call graph for this function:

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