Skip to content

Commit

Permalink
#249 - Front-End Intermediate Code Enhancement
Browse files Browse the repository at this point in the history
Verified code for all four modules `fe_ic...py`.
Still many bugs to fix.
Next step: inherit from `Utils.Trees` package modules.
  • Loading branch information
schmouk committed Sep 16, 2019
1 parent 8101932 commit cd91a3e
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
1 change: 0 additions & 1 deletion src/FrontEnd/IntermediateCode/fe_icblock.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ def __init__(self) -> None: ##, parent:FEICNode=None):
Constructor.
'''
super().__init__( [] ) ## content is an empty list (of FEICNode-s)
##self.parent = parent

#-------------------------------------------------------------------------
def __iadd__(self, ic_node: FEICNode):
Expand Down
8 changes: 4 additions & 4 deletions src/FrontEnd/IntermediateCode/fe_icleaf.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@
#=============================================================================
class FEICLeaf( FEICNode ):
"""
Class description.
Class of leaves in Intermediate Code trees.
"""
#-------------------------------------------------------------------------
def __init__(self, content) -> None:
'''
Constructor.
Args:
content: a reference to the content opf this leaf
content: a reference to the content of this leaf.
'''
super().__init__( content )

Expand All @@ -58,8 +58,8 @@ def __next__(self):
#-------------------------------------------------------------------------
def walk(self) -> FEICNode:
'''
Walks through the list of nodes contained within this block.
Walk-through is depth-first implemented.
Walks over this leaf.
Returns:
A reference to the content of this leaf.
'''
Expand Down
6 changes: 1 addition & 5 deletions src/FrontEnd/IntermediateCode/fe_icnode.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@
SOFTWARE.
"""

#=============================================================================
#no imports


#=============================================================================
class FEICNode:
"""
Expand All @@ -44,7 +40,7 @@ def __init__(self, content=None) -> None:
self.content = content

#-------------------------------------------------------------------------
def set_parent(self, parent: FEICNode):
def set_parent(self, parent):
'''
Sets the parent of this node.
'''
Expand Down
7 changes: 5 additions & 2 deletions src/FrontEnd/IntermediateCode/fe_ictree.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,15 @@ def __init__(self) -> None:
#-------------------------------------------------------------------------
def __iadd__(self, ic_node: (FEICBlock,FEICNode)):
'''
Appends a new node into this block.
In-place appends a new block or node to this intermediate code tree.
Returns a reference to this IC tree.
'''
ic_node.set_parent( self._current )
self._current += ic_node
if isinstance( ic_node, FEICBlock ):
self._current = ic_node
return self

#-------------------------------------------------------------------------
def up_level(self) -> None:
Expand All @@ -60,7 +63,7 @@ def up_level(self) -> None:
#-------------------------------------------------------------------------
def walk(self) -> None:
'''
Walks through this Intermediate Code tree.
Walks through this Intermediate Code tree, starting at its root.
Walk-through is depth-first implemented.
'''
self._root.walk()
Expand Down

0 comments on commit cd91a3e

Please sign in to comment.