Skip to content

Commit

Permalink
fix return buffer for private returns
Browse files Browse the repository at this point in the history
  • Loading branch information
charles-cooper committed Jan 8, 2022
1 parent 613afd9 commit 0680464
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
7 changes: 1 addition & 6 deletions vyper/codegen/return_.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,7 @@ def finalize(fill_return_buffer):

if context.is_internal:
dst = LLLnode.from_list(["return_buffer"], typ=context.return_type, location="memory")
fill_return_buffer = [
"with",
dst,
"pass", # return_buffer is passed on the stack by caller
make_setter(dst, lll_val, context, pos=_pos),
]
fill_return_buffer = make_setter(dst, lll_val, context, pos=_pos)

return finalize(fill_return_buffer)

Expand Down
16 changes: 11 additions & 5 deletions vyper/codegen/self_call.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,13 @@ def lll_for_self_call(stmt_expr, context):

# allocate space for the return buffer
# TODO allocate in stmt and/or expr.py
return_buffer = (
context.new_internal_variable(sig.return_type) if sig.return_type is not None else None
)
return_buffer = LLLnode.from_list([return_buffer], annotation=f"{return_label}_return_buf")
if sig.return_type is not None:
return_buffer = LLLnode.from_list(
context.new_internal_variable(sig.return_type),
annotation=f"{return_label}_return_buf"
)
else:
return_buffer = None

# note: dst_tuple_t != args_tuple_t
dst_tuple_t = TupleType([arg.typ for arg in sig.args])
Expand Down Expand Up @@ -94,13 +97,16 @@ def lll_for_self_call(stmt_expr, context):
goto_op += [return_buffer]
# pass return label to subroutine
goto_op += [push_label_to_stack(return_label)]

call_sequence = [
"seq",
copy_args,
goto_op,
["label", return_label, ["var_list"], "pass"],
return_buffer, # push return buffer location to stack
]
if return_buffer is not None:
# push return buffer location to stack
call_sequence += [return_buffer]

o = LLLnode.from_list(
call_sequence,
Expand Down

0 comments on commit 0680464

Please sign in to comment.