SDK: host methods for most native statements - #223
Open
robknight wants to merge 1 commit into
Open
Conversation
…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
force-pushed
the
sdk-statements
branch
from
August 21, 2026 09:09
d2ec6bf to
28951ac
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds Rhai host methods for most native POD2 statements, excluding
SignedByandPublicKey(it's not clear that we want to support these anyway).Stack created with GitHub Stacks CLI • Give Feedback 💬