This PR changes external slightly so that any labelled outputs get treated as "inout" arguments. They are pushed back on the stack after the external call. This makes it possible to call functions that follow the extremely common pattern (in C, C++, Rust) of data that is passed by reference and modified in place.
Note how foo is declared to have two outputs -- a labelled resource output +x:+Res and an unlabelled value output CInt -- but the corresponding C function only has the int output. That's because the labelled resource output +x is taken from the inputs and pushed back on the stack.
If an output label is not present in the input, the compiler raises an error.
This PR changes
external
slightly so that any labelled outputs get treated as "inout" arguments. They are pushed back on the stack after theexternal
call. This makes it possible to call functions that follow the extremely common pattern (in C, C++, Rust) of data that is passed by reference and modified in place.E.g.
Note how
foo
is declared to have two outputs -- a labelled resource output+x:+Res
and an unlabelled value outputCInt
-- but the corresponding C function only has theint
output. That's because the labelled resource output+x
is taken from the inputs and pushed back on the stack.If an output label is not present in the input, the compiler raises an error.