mirror of
https://github.com/urbit/ares.git
synced 2024-12-25 06:12:24 +03:00
interpreter: address lints for fast hints
This commit is contained in:
parent
4e292b88a0
commit
2db74f9c0f
@ -455,7 +455,7 @@ impl<T: Copy + Preserve> Preserve for Hamt<T> {
|
||||
position += 1;
|
||||
continue 'check_stem;
|
||||
}
|
||||
Some((Left(next_stem), idx)) => {
|
||||
Some((Left(next_stem), _idx)) => {
|
||||
stack.struct_is_in(next_stem.buffer, next_stem.size());
|
||||
assert!(traversal_depth <= 5); // will increment
|
||||
traversal_stack[traversal_depth - 1].as_mut().unwrap().1 = position + 1;
|
||||
@ -463,7 +463,7 @@ impl<T: Copy + Preserve> Preserve for Hamt<T> {
|
||||
traversal_depth += 1;
|
||||
continue 'check;
|
||||
}
|
||||
Some((Right(leaf), idx)) => {
|
||||
Some((Right(leaf), _idx)) => {
|
||||
stack.struct_is_in(leaf.buffer, leaf.len);
|
||||
for pair in leaf.to_mut_slice().iter() {
|
||||
pair.0.assert_in_stack(stack);
|
||||
|
@ -1,5 +1,5 @@
|
||||
use crate::hamt::Hamt;
|
||||
use crate::jets;
|
||||
|
||||
use crate::jets::cold::Cold;
|
||||
use crate::jets::hot::Hot;
|
||||
use crate::jets::warm::Warm;
|
||||
@ -761,13 +761,15 @@ fn push_formula(stack: &mut NockStack, formula: Noun, tail: bool) {
|
||||
|
||||
/** Note: axis must fit in a direct atom */
|
||||
pub fn raw_slot(noun: Noun, axis: u64) -> Noun {
|
||||
slot(noun, &BitSlice::from_element(&axis))
|
||||
slot(noun, BitSlice::from_element(&axis))
|
||||
}
|
||||
|
||||
#[allow(clippy::result_unit_err)]
|
||||
pub fn raw_slot_result(noun: Noun, axis: u64) -> Result<Noun, ()> {
|
||||
slot_result(noun, &BitSlice::from_element(&axis))
|
||||
slot_result(noun, BitSlice::from_element(&axis))
|
||||
}
|
||||
|
||||
#[allow(clippy::result_unit_err)]
|
||||
pub fn slot_result(mut noun: Noun, axis: &BitSlice<u64, Lsb0>) -> Result<Noun, ()> {
|
||||
let mut cursor = if let Some(x) = axis.last_one() {
|
||||
Ok(x)
|
||||
@ -866,10 +868,10 @@ pub fn inc(stack: &mut NockStack, atom: Atom) -> Atom {
|
||||
/** Match hints which apply before the formula is evaluated */
|
||||
fn match_pre_hint(
|
||||
stack: &mut NockStack,
|
||||
newt: &mut Option<&mut Newt>,
|
||||
_newt: &mut Option<&mut Newt>,
|
||||
subject: Noun,
|
||||
cell: Cell,
|
||||
formula: Noun,
|
||||
_formula: Noun,
|
||||
cache: &Hamt<Noun>,
|
||||
) -> Result<Noun, ()> {
|
||||
let direct = cell.head().as_direct()?;
|
||||
@ -913,6 +915,7 @@ fn match_pre_hint(
|
||||
}
|
||||
|
||||
/** Match static hints and dynamic hints after they're evaluated */
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn match_post_hint(
|
||||
stack: &mut NockStack,
|
||||
newt: &mut Option<&mut Newt>,
|
||||
@ -937,6 +940,7 @@ fn match_post_hint(
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn match_post_hinted(
|
||||
stack: &mut NockStack,
|
||||
subject: Noun,
|
||||
|
@ -170,13 +170,8 @@ impl Iterator for BatteriesList {
|
||||
}
|
||||
|
||||
impl BatteriesList {
|
||||
fn matches(self, stack: &mut NockStack, core: Noun) -> Option<Batteries> {
|
||||
for batteries in self {
|
||||
if batteries.matches(stack, core) {
|
||||
return Some(batteries);
|
||||
}
|
||||
}
|
||||
None
|
||||
fn matches(mut self, stack: &mut NockStack, core: Noun) -> Option<Batteries> {
|
||||
self.find(|&batteries| batteries.matches(stack, core))
|
||||
}
|
||||
}
|
||||
|
||||
@ -283,9 +278,9 @@ impl Cold {
|
||||
unsafe {
|
||||
let cold_mem_ptr: *mut ColdMem = stack.struct_alloc(1);
|
||||
*cold_mem_ptr = ColdMem {
|
||||
battery_to_paths: battery_to_paths,
|
||||
root_to_paths: root_to_paths,
|
||||
path_to_batteries: path_to_batteries,
|
||||
battery_to_paths,
|
||||
root_to_paths,
|
||||
path_to_batteries,
|
||||
};
|
||||
Cold(cold_mem_ptr)
|
||||
}
|
||||
@ -304,6 +299,7 @@ impl Cold {
|
||||
/// already registered)
|
||||
///
|
||||
/// XX TODO validate chum
|
||||
#[allow(clippy::result_unit_err)]
|
||||
pub fn register(
|
||||
&mut self,
|
||||
stack: &mut NockStack,
|
||||
@ -411,9 +407,9 @@ impl Cold {
|
||||
|
||||
let batteries_mem_ptr: *mut BatteriesMem = stack.struct_alloc(1);
|
||||
*batteries_mem_ptr = BatteriesMem {
|
||||
battery: battery,
|
||||
parent_axis: parent_axis,
|
||||
parent_batteries: parent_batteries,
|
||||
battery,
|
||||
parent_axis,
|
||||
parent_batteries,
|
||||
};
|
||||
|
||||
let current_batteries_list = path_to_batteries
|
||||
@ -460,9 +456,9 @@ impl Cold {
|
||||
|
||||
let batteries_mem_ptr: *mut BatteriesMem = stack.struct_alloc(1);
|
||||
*batteries_mem_ptr = BatteriesMem {
|
||||
battery: battery,
|
||||
parent_axis: parent_axis,
|
||||
parent_batteries: parent_batteries,
|
||||
battery,
|
||||
parent_axis,
|
||||
parent_batteries,
|
||||
};
|
||||
|
||||
let current_batteries_list = path_to_batteries
|
||||
@ -500,9 +496,9 @@ impl Cold {
|
||||
|
||||
let cold_mem_ptr: *mut ColdMem = stack.struct_alloc(1);
|
||||
*cold_mem_ptr = ColdMem {
|
||||
battery_to_paths: battery_to_paths,
|
||||
root_to_paths: root_to_paths,
|
||||
path_to_batteries: path_to_batteries,
|
||||
battery_to_paths,
|
||||
root_to_paths,
|
||||
path_to_batteries,
|
||||
};
|
||||
|
||||
*self = Cold(cold_mem_ptr);
|
||||
|
@ -7,6 +7,7 @@ use std::ptr::null_mut;
|
||||
const A_50: Either<u64, (u64, u64)> = Right((tas!(b"a"), 50));
|
||||
|
||||
// This is the const state all in one spot as literals
|
||||
#[allow(clippy::complexity)]
|
||||
const HOT_STATE: &[(&[Either<u64, (u64, u64)>], u64, Jet)] = &[
|
||||
(&[A_50, Left(tas!(b"dec"))], 1, jet_dec),
|
||||
(&[A_50, Left(tas!(b"add"))], 1, jet_add),
|
||||
@ -68,10 +69,10 @@ impl Hot {
|
||||
let axis = DirectAtom::new_panic(*axe).as_atom();
|
||||
let hot_mem_ptr: *mut HotMem = stack.struct_alloc(1);
|
||||
*hot_mem_ptr = HotMem {
|
||||
a_path: a_path,
|
||||
axis: axis,
|
||||
a_path,
|
||||
axis,
|
||||
jet: *jet,
|
||||
next: next,
|
||||
next,
|
||||
};
|
||||
next = Hot(hot_mem_ptr);
|
||||
}
|
||||
|
@ -84,6 +84,7 @@ impl Iterator for WarmEntry {
|
||||
}
|
||||
|
||||
impl Warm {
|
||||
#[allow(clippy::new_without_default)]
|
||||
pub fn new() -> Self {
|
||||
Warm(Hamt::new())
|
||||
}
|
||||
@ -100,9 +101,9 @@ impl Warm {
|
||||
unsafe {
|
||||
let warm_entry_mem_ptr: *mut WarmEntryMem = stack.struct_alloc(1);
|
||||
*warm_entry_mem_ptr = WarmEntryMem {
|
||||
batteries: batteries,
|
||||
jet: jet,
|
||||
path: path,
|
||||
batteries,
|
||||
jet,
|
||||
path,
|
||||
next: current_warm_entry,
|
||||
};
|
||||
self.0 = self.0.insert(stack, formula, WarmEntry(warm_entry_mem_ptr));
|
||||
@ -115,7 +116,7 @@ impl Warm {
|
||||
let batteries_list = cold.find(stack, &mut path);
|
||||
for batteries in batteries_list {
|
||||
let mut batteries_tmp = batteries;
|
||||
let (mut battery, _parent_axis) = batteries_tmp
|
||||
let (battery, _parent_axis) = batteries_tmp
|
||||
.next()
|
||||
.expect("IMPOSSIBLE: empty battery entry in cold state");
|
||||
if let Ok(mut formula) = unsafe { slot_result(*battery, axis.as_bitslice()) } {
|
||||
@ -131,7 +132,7 @@ impl Warm {
|
||||
|
||||
pub fn find_jet(&mut self, stack: &mut NockStack, s: &mut Noun, f: &mut Noun) -> Option<Jet> {
|
||||
let warm_it = self.0.lookup(stack, f)?;
|
||||
for (path, batteries, jet) in warm_it {
|
||||
for (_path, batteries, jet) in warm_it {
|
||||
if batteries.matches(stack, *s) {
|
||||
return Some(jet);
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
use crate::assert_acyclic;
|
||||
use crate::noun::{Atom, Cell, CellMemory, IndirectAtom, Noun, NounAllocator};
|
||||
use crate::snapshot::pma::{pma_in_arena, pma_malloc_w};
|
||||
use assert_no_alloc::permit_alloc;
|
||||
|
||||
use either::Either::{self, Left, Right};
|
||||
use ibig::Stack;
|
||||
use libc::{c_void, memcmp};
|
||||
@ -453,9 +453,8 @@ impl NockStack {
|
||||
self.stack_pointer
|
||||
}) as usize;
|
||||
let (low, hi) = if ap > sp { (sp, ap) } else { (ap, sp) };
|
||||
if (ptr as usize) < low && (ptr.add(count) as usize) <= low {
|
||||
return;
|
||||
} else if (ptr as usize) >= hi && (ptr.add(count) as usize) > hi {
|
||||
if ((ptr as usize) < low && (ptr.add(count) as usize) <= low)
|
||||
|| ((ptr as usize) >= hi && (ptr.add(count) as usize) > hi) {
|
||||
return;
|
||||
}
|
||||
panic!(
|
||||
|
@ -130,6 +130,7 @@ pub fn serf() -> io::Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn slam(
|
||||
stack: &mut NockStack,
|
||||
newt: &mut Newt,
|
||||
|
Loading…
Reference in New Issue
Block a user