addressToReference

addressToReference (address modelValue -- reconstructedValue)

Inputs

Outputs

addressToReference reconstructs a typed result from a numeric storage address and a model value.

The model value is used only to choose the result schema case and, for Ref-like model values, the result mutability. It is not dereferenced and it is not read from the supplied address.

If the model value is already Ref-like, the result has that same schema. Otherwise, a non-Meta non-Ref-like model produces a Ref to the model schema. For an In-place local or field, NAME or .NAME supplies the immutable Ref model case, while @NAME or .@NAME supplies the mutable case.

Behavior

Example

{} () {} [
  value: 7;
  text: "hello";
  code: {} () {} codeRef;

  "-- Ref model value --" printCompilerMessage
  @value storageAddress @value addressToReference printStack _:;
  0nx @value addressToReference printStack _:;

  "-- In-place model value --" printCompilerMessage
  @value storageAddress value addressToReference printStack _:;
  0nx value addressToReference printStack _:;

  "-- text and code targets --" printCompilerMessage
  text storageAddress text addressToReference printStack _:;
  0nx text addressToReference printStack _:;
  0nx @code addressToReference printStack _:;
] "main" exportFunction

Expected Output During Compilation

-- Ref model value --
Int32 Ref
Int32 NIL
-- In-place model value --
Int32 Cref
Int32 CNIL
-- text and code targets --
Text
Text CNIL
{} () {} codeRef CNIL

See also