def visit_Return(self, node: ast.Return): with fast.location_of(node): node.value = fast.Call( func=self._emitter_ast(), args=[TraceEvent.after_return.to_ast(), self._get_copy_id_ast(node.value)], keywords=fast.kwargs( ret=self._make_tuple_event_for( self.visit(node.value), TraceEvent.before_return, orig_node_id=id(node.value), ), ), ) return node
def visit_Return(self, n: Return): """ * Decrement the depth before exiting. We have to save the returned value into a temporary, and only then decrement; otherwise, if the return value itself is a Call, we lose the depth. """ var = Assign([Name(self._RETURN_VAR, Store())], n.value) n.value = Name(self._RETURN_VAR, Load()) return self._fix_location_all( [ var, self._make_print( [ self._parse_fstring( colored(f"return {{{self._RETURN_VAR}}}", self.RETURN_COLOR)) ], "< ", ), self._decrement_depth(), n, ], n, )