mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-11-07 08:33:50 +08:00
Directly called functions returning a union of numbers, booleans, unit values and class instances, strings, records or arrays now return its tag and payload in registers, as scalar unions already did. A reference payload carries the reference the heap box held. A wrapped return value moves its reference into the pair, and a returned call with the same convention passes its pair through. Callers that only project the result keep it in a private stack box whose payload the statement frame releases by tag. A discarded result releases its payload from the registers. Locals bound to such results keep the tag and payload: with one reference arm through the existing owner slot, and with several through the box itself, released by tag on rebinding and scope exit. Other callers, and the boxed entry used by closures, dispatch and the runtime, box the pair. Functions with a finally block keep the boxed result.