def apply_all(self, ast): """ Apply mutation to all matches @return last node changed """ start_node = None self.ast = ast f = OmpParallelForFilter() num = 0 try: for elem in f.iterate(ast): # Save previous state old_name = self.kernel_name old_clauses = self._clauses self.kernel_name = self.kernel_name + str(num) # Current scope variables self._func_def = f.get_func_def() self._parallel = f.get_parallel() self._ompFor = f.get_ompFor() # Apply mutation start_node = self.mutatorFunction(ast, self._ompFor) # Restore previous state self.kernel_name = old_name self._clauses = old_clauses num += 1 except NodeNotFound as nf: print " This is the one " print str(nf) except StopIteration: return self._parallel return start_node
def filter(self, ast): """ Filter definition @return first node matching with the filter """ # Build a visitor , matching the OmpFor node of the AST f = OmpParallelForFilter() node = f.apply(ast) self._func_def = f.get_func_def() self._parallel = f.get_parallel() return node