def GetFrame(self, var): if var.GetLocation() == 'GF': return Model.GF elif var.GetLocation() == 'LF': return Model.LF elif var.GetLocation() == 'TF': if Model.TF == None: raise Err.UndefinedFrameException("TF not defined.") return Model.TF else: raise Err.UndefinedFrameException('unknown frame')
def GetValue(self, name): """ Returns top Frame variable value. Will throw exception, if empty, or not initialized. """ try: return self.frames.Top().GetValue(name) except AttributeError: raise Err.UndefinedFrameException("Empty stackframe!")
def DefVar(self, name, c): """ Creates new top Frame variable. Will throw exception, if empty. """ try: self.frames.Top().DefVar(name, c) except AttributeError: raise Err.UndefinedFrameException("Empty stackframe!")
def PopFrame(self): """ Pops Frame and returns it. Will throw exception, if empty. """ try: return self.frames.Pop() except IndexError: raise Err.UndefinedFrameException("Empty stackframe!")
def Set(self, name, c): """ Initializes top Frame variable. Will throw exception, if does not exist. """ try: self.frames.Top().Set(name, c) except AttributeError: raise Err.UndefinedFrameException("Empty stackframe!")
def Top(self): """ Returns top item. Will throw exception, if empty. """ try: return self.data[-1] except: raise Err.UndefinedFrameException('empty framestack')
def PushFrame(): """ Pushes Frame onto LF. Aims LF operations on it. Will throw exception, if TF is not defined. """ global TF global LF if TF is not None: LF.PushFrame(TF) TF = None else: raise Err.UndefinedFrameException("TF is not defined!")