This commit is contained in:
Matthew LeVan 2023-11-20 15:06:14 -05:00
parent bdc9224995
commit da6e8b2522
2 changed files with 34 additions and 33 deletions

View File

@ -6,10 +6,10 @@ pub mod bits;
pub mod form;
pub mod hash;
pub mod list;
pub mod parse;
pub mod lute;
pub mod math;
pub mod nock;
pub mod parse;
pub mod serial;
pub mod sort;
pub mod tree;
@ -21,10 +21,10 @@ use crate::jets::form::*;
use crate::jets::hash::*;
use crate::jets::hot::Hot;
use crate::jets::list::*;
use crate::jets::parse::*;
use crate::jets::lute::*;
use crate::jets::math::*;
use crate::jets::nock::*;
use crate::jets::parse::*;
use crate::jets::serial::*;
use crate::jets::sort::*;
@ -32,7 +32,7 @@ use crate::jets::tree::*;
use crate::jets::warm::Warm;
use crate::mem::NockStack;
use crate::newt::Newt;
use crate::noun::{self, Noun, Atom, Slots, D};
use crate::noun::{self, Noun, Slots, D};
use ares_macros::tas;
crate::gdb!();
@ -126,6 +126,9 @@ pub fn get_jet(jet_name: Noun) -> Option<Jet> {
tas!(b"scow") => Some(jet_scow),
//
tas!(b"mink") => Some(jet_mink),
//
tas!(b"pose") => Some(jet_pose),
tas!(b"last") => Some(jet_last),
_ => {
// eprintln!("Unknown jet: {:?}", jet_name);
None

View File

@ -2,11 +2,10 @@ use either::Either::{Left, Right};
/** Parsing jets
*/
use crate::interpreter::{Context, interpret};
use crate::jets::util::{slot, kick};
use crate::interpreter::Context;
use crate::jets::util::{kick, slot};
use crate::jets::Result;
use crate::noun::{Noun, D, T};
use crate::jets::nock::util::slam_gate_fol;
crate::gdb!();
@ -28,23 +27,24 @@ pub fn jet_pose(context: &mut Context, subject: Noun) -> Result {
match vex.as_either_atom_cell() {
Left(_a) => {
assert!(vex.raw_equals(D(0)));
assert!(unsafe { vex.raw_equals(D(0)) });
//let fol = slam_gate_fol(&mut context.stack);
let roq = kick(context, sab, D(2))?;
Ok(T(&mut context.stack,
&[util::last(vex.as_cell()?.head(),
roq.as_cell()?.head())?,
roq.as_cell()?.tail()]))
},
Right(_c) => {
Ok(vex)
Ok(T(
&mut context.stack,
&[
util::last(vex.as_cell()?.head(), roq.as_cell()?.head())?,
roq.as_cell()?.tail(),
],
))
}
Right(_c) => Ok(vex),
}
}
pub fn jet_last(context: &mut Context, subject: Noun) -> Result {
pub fn jet_last(_context: &mut Context, subject: Noun) -> Result {
let sam = slot(subject, 6)?;
let zyc = slot(sam, 2)?;
let naz = slot(sam, 3)?;
@ -53,12 +53,10 @@ pub fn jet_last(context: &mut Context, subject: Noun) -> Result {
}
pub mod util {
use crate::interpreter::{Context, interpret};
use crate::jets::util::slot;
use crate::jets::Result;
use crate::noun::{Noun, D};
pub fn last(zyc: Noun, naz:Noun) -> Result {
use crate::noun::Noun;
pub fn last(zyc: Noun, naz: Noun) -> Result {
let zyl = zyc.as_cell()?;
let nal = naz.as_cell()?;
@ -67,22 +65,22 @@ pub mod util {
assert!(nal.head().is_direct());
assert!(nal.tail().is_direct());
if zyl.head().raw_equals(nal.head()) {
if zyl.tail().as_direct().as_u64() > nal.tail().as_direct().as_u64() {
Ok(zyc)
unsafe {
if zyl.head().raw_equals(nal.head()) {
if zyl.tail().as_atom()?.as_u64()? > nal.tail().as_atom()?.as_u64()? {
Ok(zyc)
} else {
Ok(naz)
}
} else {
Ok(naz)
}
} else {
if zyl.head().as_direct().as_u64() > nal.head().as_direct().as_u64() {
Ok(zyc)
} else {
Ok(naz)
if zyl.head().as_atom()?.as_u64()? > nal.head().as_atom()?.as_u64()? {
Ok(zyc)
} else {
Ok(naz)
}
}
}
}
}
pub mod test {
}
pub mod test {}