From 086822f22ccd4a7f30204950682f11710d427602 Mon Sep 17 00:00:00 2001 From: Alex Shelkovnykov Date: Wed, 18 Oct 2023 15:40:34 -0600 Subject: [PATCH] Fix merge conflicts --- rust/ares/src/jets.rs | 8 ++--- rust/ares/src/jets/hot.rs | 4 +++ rust/ares/src/jets/math.rs | 8 ++--- rust/ares/src/jets/sort.rs | 60 ++++++++++++++------------------------ rust/ares/src/jets/text.rs | 3 -- 5 files changed, 32 insertions(+), 51 deletions(-) diff --git a/rust/ares/src/jets.rs b/rust/ares/src/jets.rs index b45081f..c5f90da 100644 --- a/rust/ares/src/jets.rs +++ b/rust/ares/src/jets.rs @@ -93,13 +93,13 @@ pub fn get_jet(jet_name: Noun) -> Option { // tas!(b"mug") => Some(jet_mug), // - tas!(b"scow") => Some(jet_scow), - // - tas!(b"mink") => Some(jet_mink), - // tas!(b"dor") => Some(jet_dor), tas!(b"gor") => Some(jet_gor), tas!(b"mor") => Some(jet_mor), + // + tas!(b"scow") => Some(jet_scow), + // + tas!(b"mink") => Some(jet_mink), _ => { // eprintln!("Unknown jet: {:?}", jet_name); None diff --git a/rust/ares/src/jets/hot.rs b/rust/ares/src/jets/hot.rs index 78ca9ed..b808ad9 100644 --- a/rust/ares/src/jets/hot.rs +++ b/rust/ares/src/jets/hot.rs @@ -45,6 +45,10 @@ const HOT_STATE: &[(&[Either], u64, Jet)] = &[ // (&[A_50, Left(tas!(b"mug"))], 1, jet_mug), // + (&[A_50, Left(tas!(b"dor"))], 1, jet_dor), + (&[A_50, Left(tas!(b"gor"))], 1, jet_gor), + (&[A_50, Left(tas!(b"mor"))], 1, jet_mor), + // (&[A_50, Left(tas!(b"scow"))], 1, jet_scow), // (&[A_50, Left(tas!(b"mink"))], 1, jet_mink), diff --git a/rust/ares/src/jets/math.rs b/rust/ares/src/jets/math.rs index 201eb3f..5d075ad 100644 --- a/rust/ares/src/jets/math.rs +++ b/rust/ares/src/jets/math.rs @@ -190,11 +190,7 @@ pub fn jet_lte(context: &mut Context, subject: Noun) -> Result { }) } -pub fn jet_lth( - _stack: &mut NockStack, - _newt: &mut Option<&mut Newt>, - subject: Noun, -) -> jets::Result { +pub fn jet_lth(_context: &mut Context, subject: Noun) -> Result { let arg = slot(subject, 6)?; let a = slot(arg, 2)?.as_atom()?; let b = slot(arg, 3)?.as_atom()?; @@ -256,7 +252,7 @@ pub fn jet_sub(context: &mut Context, subject: Noun) -> Result { pub mod util { use crate::jets::util::test::init_stack; - use crate::noun::{Atom, Noun, YES, NO}; + use crate::noun::{Atom, Noun, NO, YES}; pub fn lth(a: Atom, b: Atom) -> Noun { let s = &mut init_stack(); diff --git a/rust/ares/src/jets/sort.rs b/rust/ares/src/jets/sort.rs index 6a59d71..65b105a 100644 --- a/rust/ares/src/jets/sort.rs +++ b/rust/ares/src/jets/sort.rs @@ -1,19 +1,17 @@ /** Sorting jets */ +use crate::interpreter::Context; use crate::jets; use crate::jets::util::slot; -use crate::mem::NockStack; use crate::mug::mug; -use crate::newt::Newt; use crate::noun::{Noun, NO, YES}; +use std::cmp::Ordering; crate::gdb!(); -pub fn jet_mor( - stack: &mut NockStack, - _newt: &mut Option<&mut Newt>, - subject: Noun, -) -> jets::Result { +pub fn jet_mor(context: &mut Context, subject: Noun) -> jets::Result { + let stack = &mut context.stack; + let sam = slot(subject, 6)?; let a = slot(sam, 2)?; let b = slot(sam, 3)?; @@ -24,22 +22,16 @@ pub fn jet_mor( let e = mug(stack, c.as_noun()); let f = mug(stack, d.as_noun()); - if e.data() == f.data() { - Ok(util::dor(a, b)) - } else { - if e.data() < f.data() { - Ok(YES) - } else { - Ok(NO) - } + match e.data().cmp(&f.data()) { + Ordering::Greater => Ok(NO), + Ordering::Less => Ok(YES), + Ordering::Equal => Ok(util::dor(a, b)), } } -pub fn jet_gor( - stack: &mut NockStack, - _newt: &mut Option<&mut Newt>, - subject: Noun, -) -> jets::Result { +pub fn jet_gor(context: &mut Context, subject: Noun) -> jets::Result { + let stack = &mut context.stack; + let sam = slot(subject, 6)?; let a = slot(sam, 2)?; let b = slot(sam, 3)?; @@ -47,22 +39,14 @@ pub fn jet_gor( let c = mug(stack, a); let d = mug(stack, b); - if c.data() == d.data() { - Ok(util::dor(a, b)) - } else { - if c.data() < d.data() { - Ok(YES) - } else { - Ok(NO) - } + match c.data().cmp(&d.data()) { + Ordering::Greater => Ok(NO), + Ordering::Less => Ok(YES), + Ordering::Equal => Ok(util::dor(a, b)), } } -pub fn jet_dor( - _stack: &mut NockStack, - _newt: &mut Option<&mut Newt>, - subject: Noun, -) -> jets::Result { +pub fn jet_dor(_context: &mut Context, subject: Noun) -> jets::Result { let sam = slot(subject, 6)?; let a = slot(sam, 2)?; let b = slot(sam, 3)?; @@ -71,10 +55,10 @@ pub fn jet_dor( } pub mod util { - use either::{Left, Right}; - use crate::jets::util::slot; use crate::jets::math::util::lth; - use crate::noun::{Noun, YES, NO}; + use crate::jets::util::slot; + use crate::noun::{Noun, NO, YES}; + use either::{Left, Right}; pub fn dor(a: Noun, b: Noun) -> Noun { if unsafe { a.raw_equals(b) } { @@ -106,9 +90,9 @@ pub mod util { #[cfg(test)] mod tests { use super::*; - use ibig::ubig; - use crate::jets::util::test::{A, assert_jet, init_stack}; + use crate::jets::util::test::{assert_jet, init_stack, A}; use crate::noun::{D, T}; + use ibig::ubig; #[test] fn test_dor() { diff --git a/rust/ares/src/jets/text.rs b/rust/ares/src/jets/text.rs index 6500505..c26fdf7 100644 --- a/rust/ares/src/jets/text.rs +++ b/rust/ares/src/jets/text.rs @@ -3,9 +3,6 @@ use crate::interpreter::Context; use crate::jets::util::slot; use crate::jets::Result; -use crate::jets::util::slot; -use crate::mem::NockStack; -use crate::newt::Newt; use crate::noun::{Noun, D}; crate::gdb!();