Expand description
Standard native (FFI) table shipped with the facade.
§Why Message make/unpack lives here (not as new opcodes)
crate::Value::Message is already a first-class wire/register value
(ABI v2). Building and tearing it apart in bytecode could be ISA ops
(MakeMessage, MsgSender, …), but that would burn opcode space and
force every embedder that never does request-reply to carry the
dispatch cost. Natives keep the envelope generic in the core while
the std table opts into the helpers — same pattern as print / now_ms
(design notes §30-31): host Rust owns the operation, bytecode only
picks a slot.
§Stable indices are an embed contract
Flash / separately-built .bf modules hard-code CallNative indices.
Renumbering an existing slot is a breaking change. Keep
std_native_map and std_native_table in lockstep; append only.
| Index | Name | Role |
|---|---|---|
| 0 | print | host crate::OutputSink (CLI uses stdout) |
| 1 | now_ms | wall-clock millis as Value::Int |
| 2 | make_msg | build crate::Message; no sender operand (stamped on Send) |
| 3 | msg_sender | extract sender → Value::Pid (authenticated after delivery) |
| 4 | msg_request_id | extract request_id → Value::Int |
| 5 | msg_tag | extract tag → Value::Int |
| 6 | msg_payload | extract payload → any crate::Value |
| 7 | msg_reply_cap | extract reply_cap → Value::Cap (SEND grant) |
§CallNative argument layout
CallNative ra, fb, nc takes args from r[a .. a+nc] and writes the
result back into r[a] — so a call destroys the first argument
register. Samples that need to keep a Message while unpacking must
Move it into the dest register first (see
crate::samples::atomic_request_reply).
Modules§
- std_
native - Stable
CallNativeindices forstd_native_table. Bytecode embeds these once assembled — append only; never renumber.
Functions§
- std_
native_ map - Name →
CallNativeindex for documentation / host-side lookups. - std_
native_ table - Default FFI table with
StdoutSink. Preferstd_native_table_within embedders that must not touch stdout. - std_
native_ table_ with - Std natives with an explicit print sink (
NullSinkin tests / libraries). - std_
natives - Build the default native table and its matching name map together.