Skip to content

SDK: host methods for most native statements - #223

Open
robknight wants to merge 1 commit into
mainfrom
sdk-statements
Open

SDK: host methods for most native statements#223
robknight wants to merge 1 commit into
mainfrom
sdk-statements

Conversation

@robknight

@robknight robknight commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator

This PR adds Rhai host methods for most native POD2 statements, excluding SignedBy and PublicKey (it's not clear that we want to support these anyway).


Stack created with GitHub Stacks CLIGive Feedback 💬

…rator*

The statement machinery was already predicate-generic: `Inst::Statement`
renders as `{pred}(args)`, `native_pred_to_op` maps all 27 native predicates,
and pod2 fills in Merkle aux for the container ops. Only the host surface was
missing, so add one `st_*` method per native predicate. One macro owns the
name/predicate/arg-type table and emits both the methods and their
registration, so a method cannot exist in Rust but not in Rhai. `SignedBy` and
`PublicKey` stay out: both need key material an action script has no way to
name, and `SignedBy` needs its signature as operation aux data.

A statement taking a whole container has to be built with that arg in the form
the rendered podlang names it -- `io.in_x` when the Object's side collapses
into the io record -- or the predicate and the operation disagree. `Inst::Set`
and `Inst::Update` already did this; body statements now resolve their args
the same way, which leaves `ReplaceValueWithEntry` for the cases that cannot
be rebuilt: intro pods, Tx events, and the sub-action chain lift.

`*` joins `+` and `-` as a witness-only operator inside an `unsafe` block,
paired with `action.st_product` the way the others pair with `st_sum`. They
stay `unsafe`-only rather than emitting their own statement outside a block:
`unsafe` covers the dynamic extent of its block, script function calls
included, so a context-dependent operator would constrain its result or not
according to its caller, and the unconstrained reading is the silent one.
Overflow and non-int operands are errors now instead of panics.
@robknight robknight changed the title SDK: a host method for every native statement, and safe arithmetic operators SDK: host methods for most native statements Aug 21, 2026
@robknight
robknight requested a review from dhvanipa August 21, 2026 09:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant