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

Public Member Functions

def __init__ (self, parent, clause)
 
def add (self, content, position=None)
 
- Public Member Functions inherited from psyclone.f2pygen.BaseGen
def parent (self)
 
def children (self)
 
def root (self)
 
def previous_loop (self)
 
def last_declaration (self)
 
def start_parent_loop (self, debug=False)
 

Detailed Description

 Generate a fortran if, then, end if statement. 

Definition at line 1402 of file f2pygen.py.

Constructor & Destructor Documentation

◆ __init__()

def psyclone.f2pygen.IfThenGen.__init__ (   self,
  parent,
  clause 
)
:param parent: Node to which to add this IfThen as a child
:type parent: :py:class:`psyclone.f2pygen.BaseGen`
:param str clause: the condition, xx, to evaluate in the if(xx)then

Reimplemented from psyclone.f2pygen.BaseGen.

Definition at line 1405 of file f2pygen.py.

1405  def __init__(self, parent, clause):
1406  '''
1407  :param parent: Node to which to add this IfThen as a child
1408  :type parent: :py:class:`psyclone.f2pygen.BaseGen`
1409  :param str clause: the condition, xx, to evaluate in the if(xx)then
1410  '''
1411  reader = FortranStringReader("if (dummy) then\nend if")
1412  reader.set_format(FortranFormat(True, True)) # free form, strict
1413  ifthenline = reader.next()
1414  endifline = reader.next()
1415 
1416  my_if = fparser1.block_statements.IfThen(parent.root, ifthenline)
1417  my_if.expr = clause
1418  my_endif = fparser1.block_statements.EndIfThen(my_if, endifline)
1419  my_if.content.append(my_endif)
1420 
1421  BaseGen.__init__(self, parent, my_if)
1422 

Member Function Documentation

◆ add()

def psyclone.f2pygen.IfThenGen.add (   self,
  new_object,
  position = None 
)
Adds a new object to the tree. The actual position is determined by
the position argument. Note, there are two trees, the first is
the f2pygen object tree, the other is the f2py generated code
tree. These are similar but different. At the moment we
specify where to add things in terms of the f2pygen tree
(which is a higher level api) but we also insert into the f2py
tree at exactly the same location which needs to be sorted out
at some point.

Reimplemented from psyclone.f2pygen.BaseGen.

Definition at line 1423 of file f2pygen.py.

1423  def add(self, content, position=None):
1424  if position is None:
1425  position = ["auto"]
1426  if position[0] == "auto" or position[0] == "append":
1427  if position[0] == "auto" and bubble_up_type(content):
1428  # use and declaration statements cannot appear in an if
1429  # block so pass on (bubble-up) to parent
1430  self.parent.add(content, bubble_up=True)
1431  else:
1432  # append at the end of the loop. This is not a simple
1433  # append as the last element in the if is the "end if"
1434  # so we insert at the penultimate location
1435  BaseGen.add(self, content,
1436  position=["insert", len(self.root.content)-1])
1437  else:
1438  BaseGen.add(self, content, position=position)
1439 
1440 

References psyclone.f2pygen.BaseGen.parent(), psyclone.psyir.nodes.node.Node.parent(), psyclone.f2pygen.BaseGen.root(), psyclone.f2pygen.BaseDeclGen.root(), and psyclone.psyir.nodes.node.Node.root().

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

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