mirror of
https://github.com/urbit/ares.git
synced 2024-12-24 13:55:23 +03:00
Post ++xeb jet.
This commit is contained in:
parent
3f4bd26aaf
commit
45501cbb5a
@ -4,6 +4,7 @@ use crate::interpreter::Context;
|
||||
use crate::jets::util::*;
|
||||
use crate::jets::JetErr::*;
|
||||
use crate::jets::Result;
|
||||
use crate::noun::DIRECT_MAX;
|
||||
use crate::noun::{DirectAtom, IndirectAtom, Noun, D};
|
||||
use std::cmp;
|
||||
|
||||
@ -346,6 +347,17 @@ pub fn jet_mix(context: &mut Context, subject: Noun) -> Result {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn jet_xeb(context: &mut Context, subject: Noun) -> Result {
|
||||
let sam = slot(subject, 6)?;
|
||||
let a = slot(sam, 1)?.as_atom()?;
|
||||
|
||||
let syz = met(0, a) as u64;
|
||||
|
||||
unsafe {
|
||||
Ok(DirectAtom::new_unchecked(syz).as_atom().as_noun())
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
@ -710,4 +722,17 @@ mod tests {
|
||||
let sam = T(s, &[a128, a0]);
|
||||
assert_jet(s, jet_mix, sam, a128);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_xeb() {
|
||||
let s = &mut init_stack();
|
||||
assert_jet(s, jet_xeb, D(0), D(0));
|
||||
assert_jet(s, jet_xeb, D(1), D(1));
|
||||
assert_jet(s, jet_xeb, D(31), D(5));
|
||||
assert_jet(s, jet_xeb, D(32), D(6));
|
||||
assert_jet(s, jet_xeb, D(0xfff), D(12));
|
||||
assert_jet(s, jet_xeb, D(0xffff), D(16));
|
||||
assert_jet(s, jet_xeb, D(0x3fffffffffffffff), D(62));
|
||||
assert_jet(s, jet_xeb, D(0x4000000000000000), D(63));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user