# Path: AOR/DoubleList.py
# class DoubleList:
# 
#     # Constructor. 
#     def __init__(self, l1=None, l2=None):
#         if l1:
#             if type(l1) is ListType:
#                 self.l1 = l1
#             else:
#                 self.l1 = [l1]
#         else:
#             self.l1 = []
#         if l2:
#             if type(l2) is ListType:
#                 self.l2 = l2
#             else:
#                 self.l2 = [l2]
#         else:
#             self.l2 = []
#     # --------------------------------------------------------------------------
#     # This must distinguish the two above described cases
#     def append(self, e1, e2=None):
#         if not e2:
#             # This simplifies creating statements manually, since the
#             # , does not have to be added, (e.g. addVar(a), addVar(b)
#             # --> the , between say call(a,b) will be added automatically)
#             if len(self.l1)-1==len(self.l2):
#                 self.l1.append(e1)
#                 self.l2.append(",")
#             else:
#                 self.l1.append(e1)
#             return
#         if len(self.l1)==len(self.l2):
#             self.l1.append(e1)
#             self.l2.append(e2)
#         else:
#             self.l2.append(e1)
#             self.l1.append(e2)
#     # --------------------------------------------------------------------------
#     # Returns the 'main' list: l1
#     def GetMainList(self): return self.l1
#     # --------------------------------------------------------------------------
#     def lGetSecondaryList(self): return self.l2
#     # --------------------------------------------------------------------------
#     # Returns the number of elements in the main list, i.e. l1
#     def __len__(self): return len(self.l1)
#     # --------------------------------------------------------------------------
#     def __getitem__(self, n): return self.l1[n]
#     # --------------------------------------------------------------------------
#     def lGetAsSimpleList(self):
#         l = []
#         n = len(self.l1)
#         if n==0: return []
#         # Handle everything except the last element
#         for i in range(n-1):
#             l.append(self.l1[i])
#             l.append(self.l2[i])
#             
#         # Add the last element
#         l.append(self.l1[n-1])
#         # Add the corresponding element from the 2nd list if it exists
#         if len(self.l2)==n:
#             l.append(self.l2[n-1])
#         return l
#     # --------------------------------------------------------------------------
#     def ToList(self, stylesheet, l, bAddSpace=None):
#         n = len(self.l1)
#         if n==0:
#             return
#         if self.l1[0]:
#             stylesheet.ToList(self.l1[0], l)
# 
#         #if type(lTemp) is StringType:
#         #    l=[lTemp]
#         #else:
#         #    l = lTemp
#         #print "doublelist",self.l1,self.l2
#         if bAddSpace:
#             nIndent = 1
#         else:
#             nIndent = 0
#         for i in range(1,len(self.l1)):
#             l.append(self.l2[i-1])
#             if self.l1[i]:
#                 l.indent(nIndent)
#                 stylesheet.ToList(self.l1[i], l)
#         if len(self.l1)==len(self.l2):
#             l.indent(nIndent)
#             stylesheet.ToList(self.l2[-1], l)
#     # --------------------------------------------------------------------------
#     def __repr__(self):
#         return "%sx%s"%(`self.l1`, `self.l2`)
# 
# Path: AOR/BasicStatement.py
# class BasicStatement(Label, Location):
# 
#     def __init__(self, sLabel=None, loc=None, nIndent=0, isDeclaration=1):
#         Label.__init__(self, sLabel)
#         Location.__init__(self, loc)
#         self._isDeclaration=isDeclaration
#         self.nIndent=nIndent
#     # --------------------------------------------------------------------------
#     def isA(self, c):
#         return self.__class__ == c
#     # --------------------------------------------------------------------------
#     # Returns true if the statement is a 'real' fortran statement (as opposed to
#     # a compiler directive, comment line, preprocessor directive). This method
#     # is overwritten in those classes.
#     def isStatement(self): return 1
#     # --------------------------------------------------------------------------
#     # Returns if this statement is a declaration statement or not
#     def isDeclaration(self): return self._isDeclaration
#     # --------------------------------------------------------------------------
#     def ToString(self, stylesheet): return stylesheet.ToString(self)
#     # --------------------------------------------------------------------------
#     def GetIndentation(self): return self.nIndent
#     # --------------------------------------------------------------------------
#     def GetVarUsage(self, varUsage, sType="", obj=None, loc=None): return
#     # --------------------------------------------------------------------------
#     def ToList(self, stylesheet, l):
#         Label.ToList(self, stylesheet, l)
#         l.append(stylesheet.GetIndentation(self))
#     # --------------------------------------------------------------------------
#     def __str__(self): return self.__repr__()
#     # --------------------------------------------------------------------------
#     def __repr__(self):
#         stylesheet = DefaultStylesheet()
#         return "%s%s"%(Label.__repr__(self),
#                        "".join(stylesheet.ToString(self)))
# 
# class BasicRepr:
#     def __repr__(self):
#         ssheet = DefaultStylesheet()
#         return self.ToString(ssheet)
#     # --------------------------------------------------------------------------
#     def ToString(self, stylesheet): return stylesheet.ToString(self)
#     # --------------------------------------------------------------------------
#     def __str__(self): return self.__repr__()


import string
from   types              import StringType, IntType
from   AOR.DoubleList     import DoubleList
from   AOR.BasicStatement import BasicStatement, BasicRepr
    from AOR.Test.AllocateTest import RunTest
#!/usr/bin/env python


# ==============================================================================
# Stores an io-implied do list
class IODoList(BasicRepr):
    # Stores '(obj1, obj2, ..., objn, i=1, n)
    def __init__(self,sParOpen, obj1, sComma1):
        self.sParOpen    = sParOpen
        self.sParClose   = None

# Path: AOR/DoubleList.py
# class DoubleList:
# 
#     # Constructor. 
#     def __init__(self, l1=None, l2=None):
#         if l1:
#             if type(l1) is ListType:
#                 self.l1 = l1
#             else:
#                 self.l1 = [l1]
#         else:
#             self.l1 = []
#         if l2:
#             if type(l2) is ListType:
#                 self.l2 = l2
#             else:
#                 self.l2 = [l2]
#         else:
#             self.l2 = []
#     # --------------------------------------------------------------------------
#     # This must distinguish the two above described cases
#     def append(self, e1, e2=None):
#         if not e2:
#             # This simplifies creating statements manually, since the
#             # , does not have to be added, (e.g. addVar(a), addVar(b)
#             # --> the , between say call(a,b) will be added automatically)
#             if len(self.l1)-1==len(self.l2):
#                 self.l1.append(e1)
#                 self.l2.append(",")
#             else:
#                 self.l1.append(e1)
#             return
#         if len(self.l1)==len(self.l2):
#             self.l1.append(e1)
#             self.l2.append(e2)
#         else:
#             self.l2.append(e1)
#             self.l1.append(e2)
#     # --------------------------------------------------------------------------
#     # Returns the 'main' list: l1
#     def GetMainList(self): return self.l1
#     # --------------------------------------------------------------------------
#     def lGetSecondaryList(self): return self.l2
#     # --------------------------------------------------------------------------
#     # Returns the number of elements in the main list, i.e. l1
#     def __len__(self): return len(self.l1)
#     # --------------------------------------------------------------------------
#     def __getitem__(self, n): return self.l1[n]
#     # --------------------------------------------------------------------------
#     def lGetAsSimpleList(self):
#         l = []
#         n = len(self.l1)
#         if n==0: return []
#         # Handle everything except the last element
#         for i in range(n-1):
#             l.append(self.l1[i])
#             l.append(self.l2[i])
#             
#         # Add the last element
#         l.append(self.l1[n-1])
#         # Add the corresponding element from the 2nd list if it exists
#         if len(self.l2)==n:
#             l.append(self.l2[n-1])
#         return l
#     # --------------------------------------------------------------------------
#     def ToList(self, stylesheet, l, bAddSpace=None):
#         n = len(self.l1)
#         if n==0:
#             return
#         if self.l1[0]:
#             stylesheet.ToList(self.l1[0], l)
# 
#         #if type(lTemp) is StringType:
#         #    l=[lTemp]
#         #else:
#         #    l = lTemp
#         #print "doublelist",self.l1,self.l2
#         if bAddSpace:
#             nIndent = 1
#         else:
#             nIndent = 0
#         for i in range(1,len(self.l1)):
#             l.append(self.l2[i-1])
#             if self.l1[i]:
#                 l.indent(nIndent)
#                 stylesheet.ToList(self.l1[i], l)
#         if len(self.l1)==len(self.l2):
#             l.indent(nIndent)
#             stylesheet.ToList(self.l2[-1], l)
#     # --------------------------------------------------------------------------
#     def __repr__(self):
#         return "%sx%s"%(`self.l1`, `self.l2`)
# 
# Path: AOR/BasicStatement.py
# class BasicStatement(Label, Location):
# 
#     def __init__(self, sLabel=None, loc=None, nIndent=0, isDeclaration=1):
#         Label.__init__(self, sLabel)
#         Location.__init__(self, loc)
#         self._isDeclaration=isDeclaration
#         self.nIndent=nIndent
#     # --------------------------------------------------------------------------
#     def isA(self, c):
#         return self.__class__ == c
#     # --------------------------------------------------------------------------
#     # Returns true if the statement is a 'real' fortran statement (as opposed to
#     # a compiler directive, comment line, preprocessor directive). This method
#     # is overwritten in those classes.
#     def isStatement(self): return 1
#     # --------------------------------------------------------------------------
#     # Returns if this statement is a declaration statement or not
#     def isDeclaration(self): return self._isDeclaration
#     # --------------------------------------------------------------------------
#     def ToString(self, stylesheet): return stylesheet.ToString(self)
#     # --------------------------------------------------------------------------
#     def GetIndentation(self): return self.nIndent
#     # --------------------------------------------------------------------------
#     def GetVarUsage(self, varUsage, sType="", obj=None, loc=None): return
#     # --------------------------------------------------------------------------
#     def ToList(self, stylesheet, l):
#         Label.ToList(self, stylesheet, l)
#         l.append(stylesheet.GetIndentation(self))
#     # --------------------------------------------------------------------------
#     def __str__(self): return self.__repr__()
#     # --------------------------------------------------------------------------
#     def __repr__(self):
#         stylesheet = DefaultStylesheet()
#         return "%s%s"%(Label.__repr__(self),
#                        "".join(stylesheet.ToString(self)))
# 
# class BasicRepr:
#     def __repr__(self):
#         ssheet = DefaultStylesheet()
#         return self.ToString(ssheet)
#     # --------------------------------------------------------------------------
#     def ToString(self, stylesheet): return stylesheet.ToString(self)
#     # --------------------------------------------------------------------------
#     def __str__(self): return self.__repr__()


# Path: AOR/IO.py
import string
from   types              import StringType, IntType
from   AOR.DoubleList     import DoubleList
from   AOR.BasicStatement import BasicStatement, BasicRepr
    from AOR.Test.AllocateTest import RunTest

#!/usr/bin/env python


# ==============================================================================
# Stores an io-implied do list
class IODoList(BasicRepr):
    # Stores '(obj1, obj2, ..., objn, i=1, n)
    def __init__(self,sParOpen, obj1, sComma1):
        self.sParOpen    = sParOpen
        self.sParClose   = None

        self.lObj        = DoubleList(l1=[obj1], l2=[sComma1])