Use the universal prefix argument to send current line/region (C-u),

defun (C-u C-u) or whole buffer (C-u C-u C-u) when switching to the repl
with C-c C-z