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 stdout log line (flow-visible) |
| 1 | now_ms | wall-clock millis as Value::Int |
| 2 | make_msg | build crate::Message from four scalars (untrusted sender) |
| 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 → Value::Int |
| 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).
Functions§
- std_
native_ map - Name →
CallNativeindex for documentation / host-side lookups. - std_
native_ table - Default FFI table: print, clock, and Message make/unpack.
- std_
natives - Build the default native table and its matching name map together.