Example #1
0
File: List.py Project: mdrom/PyAML
 def __getitem__(self,i):
    result = mkvar()
    code = '''
    &s %s [extract %s %s]
    ''' % (result,str(i),self)
    self.writecode(code)
    return '[value %s]' % result
Example #2
0
File: List.py Project: mdrom/PyAML
   def __getslice__(self,i=1,j=0):
      result = mkvar()
      code = '''
      /*
      /* Extracting a slice from a list
      /*
      '''
      self.writecode(code)
      if i != 1:
         code = '&s i %d\n' % i
         self.writecode(code)
      else:
         code = '&s i 1\n'
         self.writecode(code)
      if j != 0:
         code = '&s j %d\n' % j
         self.writecode(code)
      else:
         code = '&s j\n'
         self.writecode(code)

      # Generate code to extract a sublist. The sublist is stored in result
      code = AML.getslice(self.list,result)
      self.writecode(code)
      return List('[value %s]'% result,self.file)
Example #3
0
File: List.py Project: mdrom/PyAML
 def length(self):
    result = mkvar()
    code = '''
    &s %s [token %s -count]
    ''' % (result,self)
    self.writecode(code)
    return '[value %s]' % result
Example #4
0
File: List.py Project: mdrom/PyAML
 def find(self,item):
    result = mkvar()
    code = '''
    &s %s [token %s -find %s]
    ''' % (result,self,item)
    self.writecode(code)
    return '[ value %s]' % result
Example #5
0
File: List.py Project: mdrom/PyAML
 def __init__(self,list,file):
    self.name = mkvar()
    self.list = list
    self.file = file
    self.code = ''
    code = '''
    &s %s %s
    ''' % (self.name,self.list)
    self.writecode(code)
Example #6
0
File: List.py Project: mdrom/PyAML
 def compareto(self,validlist):
    # Compare a this list against another known correct list.
    # If an unknown value is found return false, else true  
    result = mkvar()
    code = '''
    &s %s .TRUE.
    &do i &list %s  
       &s found [calc  [token %s -find %%i%%] > 0]
       &if ^ %%found%% &then
          &do
          &s %s .FALSE.
          &end
       &end
    ''' % (result,self,validlist,result)
    self.writecode(code)
    return '[value %s]' % result
Example #7
0
File: Layer.py Project: mdrom/PyAML
 def count(self):
    num = mkvar()
    code = ''' &s %s = [show definedlayer %s count] ''' % (num,self.name)
    self.writecode(code)
    return num
Example #8
0
File: List.py Project: mdrom/PyAML
 def isequal(self,other):
    result = mkvar()
    code = AML.isequal(self.list,other.list,result)
    self.writecode(code)
    return '[value %s]' % result