Lines Matching refs:self

26   def __init__(self, statement, lineNo, variables):  argument
27 self.statement = statement
28 self.lineNo = lineNo
29 self.variables = variables
32 def __init__(self, msg, lineNo): argument
33 self.msg = msg
34 self.lineNo = lineNo
66 def __init__(self): argument
67 self.stack = []
69 def CanExecute(self): argument
74 if self.__isEmpty():
76 return abs(self.__peek()) == IfStack.BranchTaken
78 def Handle(self, statement, variables): argument
85 self.__if(statement, variables)
87 self.__elif(statement, variables)
89 self.__else(statement)
92 self.__fi(statement)
94 def Eof(self): argument
98 if not self.__isEmpty():
101 def __isEmpty(self): argument
102 return len(self.stack) == 0
104 def __if(self, statement, variables): argument
105 if not self.__isEmpty() and abs(self.__peek()) in [ IfStack.BranchNotTaken,
107 self.__push(IfStack.BranchNotTaken)
109 self.__push(IfStack.BranchTaken)
111 self.__push(IfStack.BranchNotTakenYet)
113 def __elif(self, statement, variables): argument
114 if self.__isEmpty():
117 if self.__peek() < 0:
119 if self.__peek() == IfStack.BranchTaken:
120 self.__setLast(IfStack.BranchNotTaken)
121 elif self.__peek() == IfStack.BranchNotTakenYet:
123 self.__setLast(IfStack.BranchTaken)
127 assert self.__peek() == IfStack.BranchNotTaken
129 def __else(self, statement): argument
130 if self.__isEmpty():
133 if self.__peek() < 0:
135 if self.__peek() in [ IfStack.BranchTaken, IfStack.BranchNotTaken ]:
138 self.__setLast(-IfStack.BranchNotTaken)
140 assert self.__peek() == IfStack.BranchNotTakenYet
142 self.__setLast(-IfStack.BranchTaken)
144 def __fi(self, statement): argument
145 if self.__isEmpty():
147 self.stack.pop()
149 def __peek(self): argument
150 assert not self.__isEmpty()
151 return self.stack[-1]
153 def __push(self, element): argument
154 self.stack.append(element)
156 def __setLast(self, element): argument
157 self.stack[-1] = element
178 def __init__(self, c1Pass, variables={}): argument
179 self.cursor = 0
180 self.c1Pass = c1Pass
181 self.c1Length = len(c1Pass.body)
182 self.variables = ImmutableDict(variables)
183 self.dagQueue = []
184 self.notQueue = []
185 self.ifStack = IfStack()
186 self.lastVariant = None
188 def moveCursor(self, match): argument
189 assert self.cursor <= match.scope.end
192 self.handleNotQueue(MatchScope(self.cursor, match.scope.start))
194 self.cursor = match.scope.end + 1
195 self.variables = match.variables
197 def handleDagQueue(self, scope): argument
208 if not self.dagQueue:
212 variables = self.variables
214 for statement in self.dagQueue:
216 match = findMatchingLine(statement, self.c1Pass, scope, variables, matchedLines)
223 self.dagQueue = []
224 self.moveCursor(match)
226 def handleNotQueue(self, scope): argument
232 for statement in self.notQueue:
235 if MatchLines(statement, self.c1Pass.body[i], self.variables) is not None:
236 raise MatchFailedException(statement, i, self.variables)
237 self.notQueue = []
239 def handleEOF(self): argument
241 match = MatchInfo(MatchScope(self.c1Length, self.c1Length), None)
242 self.moveCursor(match)
244 def handleInOrder(self, statement): argument
250 scope = MatchScope(self.cursor, self.c1Length)
251 match = findMatchingLine(statement, self.c1Pass, scope, self.variables)
252 self.moveCursor(match)
254 def handleNextLine(self, statement): argument
260 if self.lastVariant not in [ TestStatement.Variant.InOrder, TestStatement.Variant.NextLine ]:
265 scope = MatchScope(self.cursor, self.cursor + 1)
266 match = findMatchingLine(statement, self.c1Pass, scope, self.variables)
267 self.moveCursor(match)
269 def handleEval(self, statement): argument
274 if not EvaluateLine(statement, self.variables):
275 raise MatchFailedException(statement, self.cursor, self.variables)
277 def handle(self, statement): argument
284 self.ifStack.Handle(statement, self.variables)
288 self.ifStack.Eof()
290 if not self.ifStack.CanExecute():
296 self.handleDagQueue(MatchScope(self.cursor, self.c1Length))
299 self.handleEOF()
301 self.handleInOrder(statement)
303 self.handleNextLine(statement)
305 self.dagQueue.append(statement)
307 self.notQueue.append(statement)
310 self.handleEval(statement)
312 self.lastVariant = variant