[ares] rustfmt

This commit is contained in:
Philip Monk 2023-02-23 20:37:14 -07:00
parent e1d3f574c4
commit 966074d928
6 changed files with 28 additions and 26 deletions

View File

@ -309,8 +309,10 @@ pub fn interpret(
Nock11ComputeHint => { Nock11ComputeHint => {
let hint = *stack.local_noun_pointer(1); let hint = *stack.local_noun_pointer(1);
if let Ok(hint_cell) = hint.as_cell() { if let Ok(hint_cell) = hint.as_cell() {
let formula = *stack.local_noun_pointer(2); let formula = *stack.local_noun_pointer(2);
if let Ok(found) = match_pre_hint(stack, newt, subject, hint_cell, formula, &cache) { if let Ok(found) =
match_pre_hint(stack, newt, subject, hint_cell, formula, &cache)
{
res = found; res = found;
stack.preserve(&mut cache); stack.preserve(&mut cache);
stack.preserve(&mut res); stack.preserve(&mut res);
@ -344,7 +346,8 @@ pub fn interpret(
stack.pop(); stack.pop();
} }
}; };
}}); }
});
res res
} }

View File

@ -10,9 +10,9 @@ pub mod newt;
pub mod noun; pub mod noun;
pub mod serf; pub mod serf;
//pub mod bytecode; //pub mod bytecode;
pub mod hamt;
pub mod serialization; pub mod serialization;
pub mod snapshot; pub mod snapshot;
pub mod hamt;
/** Introduce useful functions for debugging /** Introduce useful functions for debugging
* *
@ -36,9 +36,9 @@ macro_rules! gdb {
}; };
} }
#[cfg(debug_assertions)] // #[cfg(debug_assertions)]
#[global_allocator] // #[global_allocator]
static A: assert_no_alloc::AllocDisabler = assert_no_alloc::AllocDisabler; // static A: assert_no_alloc::AllocDisabler = assert_no_alloc::AllocDisabler;
pub(crate) use gdb; pub(crate) use gdb;

View File

@ -116,12 +116,8 @@ impl NockStack {
pub fn in_frame<T>(&self, ptr: *const T) -> bool { pub fn in_frame<T>(&self, ptr: *const T) -> bool {
let ptr_u64 = ptr as *const u64; let ptr_u64 = ptr as *const u64;
match &self.polarity { match &self.polarity {
Polarity::East => { Polarity::East => ptr_u64 >= self.stack_pointer && ptr_u64 < self.frame_pointer,
ptr_u64 >= self.stack_pointer && ptr_u64 < self.frame_pointer Polarity::West => ptr_u64 >= self.frame_pointer && ptr_u64 < self.stack_pointer,
},
Polarity::West => {
ptr_u64 >= self.frame_pointer && ptr_u64 < self.stack_pointer
},
} }
} }
@ -250,14 +246,16 @@ impl NockStack {
let prev_stack_pointer_pointer = self.previous_stack_pointer_pointer_east(); let prev_stack_pointer_pointer = self.previous_stack_pointer_pointer_east();
// note that the allocation is on the west frame, and thus resembles raw_alloc_west // note that the allocation is on the west frame, and thus resembles raw_alloc_west
let alloc = *(prev_stack_pointer_pointer); let alloc = *(prev_stack_pointer_pointer);
*prev_stack_pointer_pointer = (*prev_stack_pointer_pointer).add(word_size_of::<T>() * count); *prev_stack_pointer_pointer =
(*prev_stack_pointer_pointer).add(word_size_of::<T>() * count);
alloc as *mut T alloc as *mut T
} }
unsafe fn struct_alloc_in_previous_frame_west<T>(&mut self, count: usize) -> *mut T { unsafe fn struct_alloc_in_previous_frame_west<T>(&mut self, count: usize) -> *mut T {
let prev_stack_pointer_pointer = self.previous_stack_pointer_pointer_west(); let prev_stack_pointer_pointer = self.previous_stack_pointer_pointer_west();
// note that the allocation is on the east frame, and thus resembles raw_alloc_east // note that the allocation is on the east frame, and thus resembles raw_alloc_east
*prev_stack_pointer_pointer = (*prev_stack_pointer_pointer).sub(word_size_of::<T>() * count); *prev_stack_pointer_pointer =
(*prev_stack_pointer_pointer).sub(word_size_of::<T>() * count);
*prev_stack_pointer_pointer as *mut T *prev_stack_pointer_pointer as *mut T
} }
@ -871,11 +869,11 @@ impl Preserve for IndirectAtom {
impl Preserve for Atom { impl Preserve for Atom {
unsafe fn preserve(&mut self, stack: &mut NockStack) { unsafe fn preserve(&mut self, stack: &mut NockStack) {
match self.as_either() { match self.as_either() {
Left(_direct) => {}, Left(_direct) => {}
Right(mut indirect) => { Right(mut indirect) => {
indirect.preserve(stack); indirect.preserve(stack);
*self = indirect.as_atom(); *self = indirect.as_atom();
}, }
} }
} }
} }
@ -885,10 +883,10 @@ impl Preserve for Noun {
match stack.polarity { match stack.polarity {
Polarity::East => { Polarity::East => {
stack.copy_east(self); stack.copy_east(self);
}, }
Polarity::West => { Polarity::West => {
stack.copy_west(self); stack.copy_west(self);
}, }
} }
} }
} }

View File

@ -183,10 +183,10 @@ impl fmt::Display for DirectAtom {
std::str::from_utf8_unchecked(&bytes[..n]) std::str::from_utf8_unchecked(&bytes[..n])
}) })
} else { } else {
write!(f, "{}", self.0) write!(f, "{}", self.0)
}
} }
} }
}
#[allow(non_snake_case)] #[allow(non_snake_case)]
pub const fn D(n: u64) -> Noun { pub const fn D(n: u64) -> Noun {

View File

@ -31,7 +31,7 @@ pub fn serf() -> io::Result<()> {
snap_path.push("chk"); snap_path.push("chk");
create_dir_all(&snap_path)?; create_dir_all(&snap_path)?;
let ref mut stack = NockStack::new(21 << 10 << 10, 0); let ref mut stack = NockStack::new(96 << 10 << 10, 0);
let ref mut newt = Newt::new(); let ref mut newt = Newt::new();
let mut event_number; let mut event_number;
let mut arvo; let mut arvo;

View File

@ -1,7 +1,7 @@
use crate::assert_acyclic; use crate::assert_acyclic;
use crate::hamt::MutHamt;
use crate::mem::NockStack; use crate::mem::NockStack;
use crate::noun::{Atom, Cell, DirectAtom, IndirectAtom, Noun}; use crate::noun::{Atom, Cell, DirectAtom, IndirectAtom, Noun};
use crate::hamt::MutHamt;
use bitvec::prelude::{BitSlice, Lsb0}; use bitvec::prelude::{BitSlice, Lsb0};
use either::Either::{Left, Right}; use either::Either::{Left, Right};
@ -49,7 +49,8 @@ pub fn cue(stack: &mut NockStack, buffer: Atom) -> Noun {
// 11 bits - cue backreference // 11 bits - cue backreference
cursor += 2; cursor += 2;
unsafe { unsafe {
let mut backref_noun = Atom::new(stack, rub_backref(&mut cursor, buffer_bitslice)).as_noun(); let mut backref_noun =
Atom::new(stack, rub_backref(&mut cursor, buffer_bitslice)).as_noun();
let reffed_noun = backref_map let reffed_noun = backref_map
.lookup(stack, &mut backref_noun) .lookup(stack, &mut backref_noun)
.expect("Invalid backref in cue"); .expect("Invalid backref in cue");
@ -191,10 +192,10 @@ pub fn jam(stack: &mut NockStack, noun: Noun) -> Atom {
} else { } else {
jam_backref(stack, &mut state, backref); jam_backref(stack, &mut state, backref);
} }
}, }
Right(_cell) => { Right(_cell) => {
jam_backref(stack, &mut state, backref); jam_backref(stack, &mut state, backref);
}, }
} }
unsafe { unsafe {
stack.reclaim_in_previous_frame::<Noun>(); stack.reclaim_in_previous_frame::<Noun>();