Skip to content

Commit

Permalink
Remove parent argument of changeIfStatementsInIfConstructs
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastienRietteMTO committed Oct 14, 2024
1 parent dc55bdb commit cf6bf85
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
8 changes: 2 additions & 6 deletions src/pyft/cosmetics.py
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,7 @@ def getvalAfter(key):
node.text = re.sub(lf, repl, node.text, flags=re.IGNORECASE)

@debugDecor
def changeIfStatementsInIfConstructs(self, singleItem=None, parent=None):
def changeIfStatementsInIfConstructs(self, singleItem=None):
"""
Convert if-stmt to if-then-stmt. If singleItem is not filled, conversion to entire
object is performed.
Expand All @@ -862,7 +862,6 @@ def changeIfStatementsInIfConstructs(self, singleItem=None, parent=None):
END IF
Conversion is not done if 'CYLE' is found in action-stmt
:param singleItem: single if-stmt; in case transformation is applied on one if-stmt only
:param parent: parent of singleItem, if not provided will be recomputed
"""
if singleItem is not None:
ifstmt = [singleItem]
Expand All @@ -872,10 +871,7 @@ def changeIfStatementsInIfConstructs(self, singleItem=None, parent=None):
cycleStmt = item.findall('.//{*}cycle-stmt')
if len(cycleStmt) == 0:
# Get indentation from last sibling
if singleItem is not None and parent is not None:
par = parent
else:
par = self.getParent(item)
par = self.getParent(item)
ind = par[:].index(item)
if ind != 0 and par[ind - 1].tail is not None:
# if tail of previous sibling exists
Expand Down
7 changes: 3 additions & 4 deletions src/pyft/statements.py
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ def recur(elem, scope):
'{*}named-E/{*}R-LT/{*}array-R/../..')
if arr is not None:
# In this case we transform the if statement into an if-construct
scope.changeIfStatementsInIfConstructs(singleItem=sElem, parent=elem)
scope.changeIfStatementsInIfConstructs(singleItem=sElem)
recur(sElem, scope) # to transform the content of the if
arr = None # to do nothing more on this node
elif tag(sElem) == 'where-stmt':
Expand Down Expand Up @@ -1137,9 +1137,8 @@ def setFalseIfStmt(self, flags, simplify=False):
else:
# Solo condition
# <if-block><if-then-stmt>
if tag(scope.getParent(cond, level=1)).startswith('if-stmt'):
scope.changeIfStatementsInIfConstructs(
scope.getParent(cond, level=1))
if tag(scope.getParent(cond)).startswith('if-stmt'):
scope.changeIfStatementsInIfConstructs(scope.getParent(cond))
singleFalseBlock.append(scope.getParent(cond, level=2))
if simplify:
scope.removeStmtNode(singleFalseBlock, simplify, simplify)
Expand Down

0 comments on commit cf6bf85

Please sign in to comment.