jets: +rep:by

This commit is contained in:
Matthew LeVan 2024-06-14 16:54:24 -04:00
parent 8f43be0801
commit 68d6e5bd09
3 changed files with 41 additions and 0 deletions

View File

@ -8,6 +8,7 @@ pub mod hash;
pub mod list;
pub mod lock;
pub mod lute;
pub mod maps;
pub mod math;
pub mod nock;
pub mod parse;
@ -27,6 +28,7 @@ use crate::jets::lock::aes::*;
use crate::jets::lock::ed::*;
use crate::jets::lock::sha::*;
use crate::jets::lute::*;
use crate::jets::maps::*;
use crate::jets::math::*;
use crate::jets::nock::*;
use crate::jets::parse::*;

View File

@ -224,6 +224,11 @@ pub const URBIT_HOT_STATE: &[HotEntry] = &[
1,
jet_jam,
),
(
&[K_139, Left(b"one"), Left(b"two"), Left(b"by"), Left(b"rep")],
1,
jet_by_rep,
),
//
(
&[

View File

@ -0,0 +1,34 @@
/** Map jets. */
use crate::interpreter::Context;
use crate::jets::util::slot;
use crate::jets::Result;
use crate::noun::{Noun, D, T};
use crate::site::{site_slam, Site};
crate::gdb!();
fn by_rep(context: &mut Context, tree: Noun, site: &Site, out: &mut Noun) {
if unsafe { tree.raw_equals(D(0)) } {
return;
} else {
let node = slot(tree, 2).unwrap();
let left = slot(node, 6).unwrap();
let rite = slot(node, 7).unwrap();
let acc = T(&mut context.stack, &[node, *out]);
*out = site_slam(context, site, acc);
by_rep(context, left, site, out);
by_rep(context, rite, site, out);
}
}
pub fn jet_by_rep(context: &mut Context, subject: Noun) -> Result {
let tree = slot(subject, 30)?;
let mut gate = slot(subject, 6)?;
let mut pro = slot(gate, 13)?;
let site = Site::new(context, &mut gate);
by_rep(context, tree, &site, &mut pro);
Ok(pro)
}