mirror of
https://github.com/urbit/ares.git
synced 2024-12-23 21:31:57 +03:00
jets: roll
This commit is contained in:
parent
63ccdf0832
commit
8f43be0801
@ -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,
|
||||
|
@ -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};
|
||||
|
Loading…
Reference in New Issue
Block a user