def _make_pattern(self): params = self.pyfunction.get_param_names() body = self._get_body() body = restructure.replace(body, "return", "pass") wildcards = list(params) wildcards.extend(self._find_temps()) if self._does_return(): if self._is_expression(): replacement = "${%s}" % self._rope_returned else: replacement = "%s = ${%s}" % (self._rope_result, self._rope_returned) body = restructure.replace(body, "return ${%s}" % self._rope_returned, replacement) wildcards.append(self._rope_result) return similarfinder.make_pattern(body, wildcards)
def get_body_pattern(self): variables = [] variables.extend(self._find_function_arguments()) variables.extend(self._find_function_returns()) variables.extend(self._find_temps()) return similarfinder.make_pattern(self._get_body(), variables)
def get_replacement_pattern(self): variables = [] variables.extend(self._find_function_arguments()) variables.extend(self._find_function_returns()) return similarfinder.make_pattern(self._get_call(), variables)