mirror of
https://github.com/urbit/ares.git
synced 2024-12-23 13:25:03 +03:00
jets: +rep:by
This commit is contained in:
parent
8f43be0801
commit
68d6e5bd09
@ -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::*;
|
||||
|
@ -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,
|
||||
),
|
||||
//
|
||||
(
|
||||
&[
|
||||
|
34
rust/ares/src/jets/maps.rs
Normal file
34
rust/ares/src/jets/maps.rs
Normal 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)
|
||||
}
|
Loading…
Reference in New Issue
Block a user