jets: roll

This commit is contained in:
Matthew LeVan 2024-06-14 16:11:34 -04:00
parent 63ccdf0832
commit 8f43be0801
2 changed files with 27 additions and 1 deletions

View File

@ -99,6 +99,11 @@ pub const URBIT_HOT_STATE: &[HotEntry] = &[
1,
jet_turn,
),
(
&[K_139, Left(b"one"), Left(b"two"), Left(b"roll")],
1,
jet_roll,
),
(
&[K_139, Left(b"one"), Left(b"two"), Left(b"zing")],
1,

View File

@ -3,7 +3,7 @@
use crate::interpreter::Context;
use crate::jets::util::{slot, BAIL_FAIL};
use crate::jets::Result;
use crate::noun::{Cell, Noun, D};
use crate::noun::{Cell, Noun, D, T};
use crate::site::{site_slam, Site};
crate::gdb!();
@ -54,6 +54,27 @@ pub fn jet_turn(context: &mut Context, subject: Noun) -> Result {
}
}
pub fn jet_roll(context: &mut Context, subject: Noun) -> Result {
let sample = slot(subject, 6)?;
let mut list = slot(sample, 2)?;
let mut gate = slot(sample, 3)?;
let mut pro = slot(gate, 13)?;
let site = Site::new(context, &mut gate);
loop {
if let Ok(list_cell) = list.as_cell() {
list = list_cell.tail();
let sam = T(&mut context.stack, &[list_cell.head(), pro]);
pro = site_slam(context, &site, sam);
} else {
if unsafe { !list.raw_equals(D(0)) } {
return Err(BAIL_FAIL);
}
return Ok(pro);
}
}
}
pub mod util {
use crate::jets::util::BAIL_EXIT;
use crate::jets::{JetErr, Result};