Issue 3223: Second phase of migration to Rust Edition
Reformat via `cargo fmt`
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
use dashu::base::{Abs, Gcd, Signed, UnsignedAbs};
|
||||
use dashu::integer::fast_div::ConstDivisor;
|
||||
use dashu::integer::IBig;
|
||||
use dashu::integer::fast_div::ConstDivisor;
|
||||
use divrem::*;
|
||||
use num_order::NumOrd;
|
||||
|
||||
|
||||
@@ -564,9 +564,7 @@ fn thread_choice_instr_at_to(
|
||||
) {
|
||||
loop {
|
||||
match &mut code[instr_loc] {
|
||||
Instruction::TryMeElse(o) | Instruction::RetryMeElse(o)
|
||||
if target_loc >= instr_loc =>
|
||||
{
|
||||
Instruction::TryMeElse(o) | Instruction::RetryMeElse(o) if target_loc >= instr_loc => {
|
||||
retraction_info.push_record(RetractionRecord::ReplacedChoiceOffset(instr_loc, *o));
|
||||
|
||||
*o = target_loc - instr_loc;
|
||||
@@ -1632,8 +1630,7 @@ impl<'a, LS: LoadState<'a>> Loader<'a, LS> {
|
||||
};
|
||||
|
||||
match &mut self.wam_prelude.code[clause_loc] {
|
||||
Instruction::DynamicElse(_, d, _)
|
||||
| Instruction::DynamicInternalElse(_, d, _) => {
|
||||
Instruction::DynamicElse(_, d, _) | Instruction::DynamicInternalElse(_, d, _) => {
|
||||
*d = Death::Finite(LS::machine_st(&mut self.payload).global_clock);
|
||||
}
|
||||
_ => unreachable!(),
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
use std::borrow::Cow;
|
||||
use std::io::Write;
|
||||
use std::sync::mpsc::{channel, Receiver, Sender};
|
||||
use std::sync::mpsc::{Receiver, Sender, channel};
|
||||
|
||||
use rand::{rngs::StdRng, SeedableRng};
|
||||
use rand::{SeedableRng, rngs::StdRng};
|
||||
|
||||
use crate::Machine;
|
||||
|
||||
use super::{
|
||||
bootstrapping_compile, current_dir, import_builtin_impls, libraries, load_module, Arena, Atom,
|
||||
Callback, CompilationTarget, IndexStore, ListingSource, MachineArgs, MachineState, Stream,
|
||||
Arena, Atom, Callback, CompilationTarget, IndexStore, ListingSource, MachineArgs, MachineState,
|
||||
Stream, bootstrapping_compile, current_dir, import_builtin_impls, libraries, load_module,
|
||||
};
|
||||
|
||||
#[derive(Default)]
|
||||
|
||||
@@ -1366,9 +1366,7 @@ impl Machine {
|
||||
|
||||
let indexed_choice_instrs = match &self.code[p] {
|
||||
Instruction::IndexingCode(indexing_code) => match &indexing_code[oi as usize] {
|
||||
IndexingLine::DynamicIndexedChoice(indexed_choice_instrs) => {
|
||||
indexed_choice_instrs
|
||||
}
|
||||
IndexingLine::DynamicIndexedChoice(indexed_choice_instrs) => indexed_choice_instrs,
|
||||
_ => unreachable!(),
|
||||
},
|
||||
_ => unreachable!(),
|
||||
|
||||
@@ -57,38 +57,41 @@ struct InnerHeap {
|
||||
}
|
||||
|
||||
impl InnerHeap {
|
||||
unsafe fn grow(&mut self) -> bool { unsafe {
|
||||
let new_cap = if self.byte_cap == 0 {
|
||||
256 * 256 * 8
|
||||
} else {
|
||||
2 * self.byte_cap
|
||||
};
|
||||
unsafe fn grow(&mut self) -> bool {
|
||||
unsafe {
|
||||
let new_cap = if self.byte_cap == 0 {
|
||||
256 * 256 * 8
|
||||
} else {
|
||||
2 * self.byte_cap
|
||||
};
|
||||
|
||||
let new_layout =
|
||||
alloc::Layout::from_size_align(new_cap, size_of::<HeapCellValue>()).unwrap();
|
||||
let new_layout =
|
||||
alloc::Layout::from_size_align(new_cap, size_of::<HeapCellValue>()).unwrap();
|
||||
|
||||
assert!(
|
||||
new_layout.size() <= isize::MAX as usize,
|
||||
"Allocation too large. We should probably GC (TODO)"
|
||||
);
|
||||
assert!(
|
||||
new_layout.size() <= isize::MAX as usize,
|
||||
"Allocation too large. We should probably GC (TODO)"
|
||||
);
|
||||
|
||||
let new_ptr = if self.byte_cap == 0 {
|
||||
alloc::alloc(new_layout)
|
||||
} else {
|
||||
let old_layout =
|
||||
alloc::Layout::from_size_align(self.byte_cap, size_of::<HeapCellValue>()).unwrap();
|
||||
alloc::realloc(self.ptr, old_layout, new_layout.size())
|
||||
};
|
||||
let new_ptr = if self.byte_cap == 0 {
|
||||
alloc::alloc(new_layout)
|
||||
} else {
|
||||
let old_layout =
|
||||
alloc::Layout::from_size_align(self.byte_cap, size_of::<HeapCellValue>())
|
||||
.unwrap();
|
||||
alloc::realloc(self.ptr, old_layout, new_layout.size())
|
||||
};
|
||||
|
||||
if !new_ptr.is_null() {
|
||||
self.ptr = new_ptr;
|
||||
self.byte_cap = new_cap;
|
||||
if !new_ptr.is_null() {
|
||||
self.ptr = new_ptr;
|
||||
self.byte_cap = new_cap;
|
||||
|
||||
true
|
||||
} else {
|
||||
false
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
}}
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl Send for Heap {}
|
||||
@@ -101,48 +104,52 @@ pub struct HeapStringScan<'a> {
|
||||
}
|
||||
|
||||
// The heap_slice should be inside the heap
|
||||
unsafe fn scan_slice_to_str(heap_slice: &[u8]) -> HeapStringScan<'_> { unsafe {
|
||||
let string_len = heap_slice
|
||||
.iter()
|
||||
.position(|b| *b == 0u8)
|
||||
.unwrap_or(heap_slice.len());
|
||||
let zero_byte_addr = heap_slice.as_ptr().add(string_len);
|
||||
unsafe fn scan_slice_to_str(heap_slice: &[u8]) -> HeapStringScan<'_> {
|
||||
unsafe {
|
||||
let string_len = heap_slice
|
||||
.iter()
|
||||
.position(|b| *b == 0u8)
|
||||
.unwrap_or(heap_slice.len());
|
||||
let zero_byte_addr = heap_slice.as_ptr().add(string_len);
|
||||
|
||||
let sentinel_len = pstr_sentinel_length(zero_byte_addr.addr());
|
||||
let tail_idx = cell_index!(
|
||||
(string_len + sentinel_len).next_multiple_of(ALIGN)
|
||||
+ if sentinel_len <= 1 { heap_index!(1) } else { 0 }
|
||||
);
|
||||
let sentinel_len = pstr_sentinel_length(zero_byte_addr.addr());
|
||||
let tail_idx = cell_index!(
|
||||
(string_len + sentinel_len).next_multiple_of(ALIGN)
|
||||
+ if sentinel_len <= 1 { heap_index!(1) } else { 0 }
|
||||
);
|
||||
|
||||
let str_slice = &heap_slice[..string_len];
|
||||
let str_slice = &heap_slice[..string_len];
|
||||
|
||||
HeapStringScan {
|
||||
string: std::str::from_utf8_unchecked(str_slice),
|
||||
tail_idx,
|
||||
HeapStringScan {
|
||||
string: std::str::from_utf8_unchecked(str_slice),
|
||||
tail_idx,
|
||||
}
|
||||
}
|
||||
}}
|
||||
}
|
||||
|
||||
// Same as scan_slice_to_str but assumes that the slice is from the start of a string.
|
||||
// Can be used on strings out of the heap.
|
||||
unsafe fn scan_slice_to_str_from_start(heap_slice: &[u8]) -> HeapStringScan<'_> { unsafe {
|
||||
let string_len = heap_slice
|
||||
.iter()
|
||||
.position(|b| *b == 0u8)
|
||||
.unwrap_or(heap_slice.len());
|
||||
unsafe fn scan_slice_to_str_from_start(heap_slice: &[u8]) -> HeapStringScan<'_> {
|
||||
unsafe {
|
||||
let string_len = heap_slice
|
||||
.iter()
|
||||
.position(|b| *b == 0u8)
|
||||
.unwrap_or(heap_slice.len());
|
||||
|
||||
let sentinel_len = pstr_sentinel_length(string_len);
|
||||
let tail_idx = cell_index!(
|
||||
(string_len + sentinel_len).next_multiple_of(ALIGN)
|
||||
+ if sentinel_len <= 1 { heap_index!(1) } else { 0 }
|
||||
);
|
||||
let sentinel_len = pstr_sentinel_length(string_len);
|
||||
let tail_idx = cell_index!(
|
||||
(string_len + sentinel_len).next_multiple_of(ALIGN)
|
||||
+ if sentinel_len <= 1 { heap_index!(1) } else { 0 }
|
||||
);
|
||||
|
||||
let str_slice = &heap_slice[..string_len];
|
||||
let str_slice = &heap_slice[..string_len];
|
||||
|
||||
HeapStringScan {
|
||||
string: std::str::from_utf8_unchecked(str_slice),
|
||||
tail_idx,
|
||||
HeapStringScan {
|
||||
string: std::str::from_utf8_unchecked(str_slice),
|
||||
tail_idx,
|
||||
}
|
||||
}
|
||||
}}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub(crate) enum PStrContinuable {
|
||||
@@ -450,11 +457,7 @@ fn pstr_sentinel_length(chunk_len: usize) -> usize {
|
||||
let res = chunk_len.next_multiple_of(ALIGN) - chunk_len;
|
||||
|
||||
// No bytes available in last chunk
|
||||
if res == 0 {
|
||||
ALIGN
|
||||
} else {
|
||||
res
|
||||
}
|
||||
if res == 0 { ALIGN } else { res }
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
@@ -585,9 +588,9 @@ impl Heap {
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
unsafe fn grow(&mut self) -> bool { unsafe {
|
||||
self.inner.grow()
|
||||
}}
|
||||
unsafe fn grow(&mut self) -> bool {
|
||||
unsafe { self.inner.grow() }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn resource_error_offset(&self) -> usize {
|
||||
|
||||
@@ -3,23 +3,23 @@ use std::collections::BTreeMap;
|
||||
use std::rc::Rc;
|
||||
|
||||
use crate::atom_table;
|
||||
use crate::heap_iter::{stackful_post_order_iter, NonListElider};
|
||||
use crate::heap_iter::{NonListElider, stackful_post_order_iter};
|
||||
use crate::machine::heap::AllocError;
|
||||
use crate::machine::machine_indices::VarKey;
|
||||
use crate::machine::mock_wam::CompositeOpDir;
|
||||
use crate::machine::{
|
||||
ArenaHeaderTag, Fixnum, Number, BREAK_FROM_DISPATCH_LOOP_LOC, LIB_QUERY_SUCCESS,
|
||||
ArenaHeaderTag, BREAK_FROM_DISPATCH_LOOP_LOC, Fixnum, LIB_QUERY_SUCCESS, Number,
|
||||
};
|
||||
use crate::offset_table::*;
|
||||
use crate::parser::ast::{Var, VarPtr};
|
||||
use crate::parser::parser::{Parser, Tokens};
|
||||
use crate::read::{write_term_to_heap, TermWriteResult};
|
||||
use crate::read::{TermWriteResult, write_term_to_heap};
|
||||
use crate::types::UntypedArenaPtr;
|
||||
|
||||
use dashu::{Integer, Rational};
|
||||
use indexmap::IndexMap;
|
||||
|
||||
use super::{streams::Stream, Atom, AtomCell, HeapCellValue, HeapCellValueTag, Machine};
|
||||
use super::{Atom, AtomCell, HeapCellValue, HeapCellValueTag, Machine, streams::Stream};
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
@@ -819,11 +819,8 @@ impl<'a, LS: LoadState<'a>> Loader<'a, LS> {
|
||||
if let Instruction::IndexingCode(ref mut indexing_code) =
|
||||
self.wam_prelude.code[index_loc]
|
||||
{
|
||||
if let IndexingLine::Indexing(IndexingInstruction::SwitchOnTerm(
|
||||
_,
|
||||
v,
|
||||
..,
|
||||
)) = &mut indexing_code[0]
|
||||
if let IndexingLine::Indexing(IndexingInstruction::SwitchOnTerm(_, v, ..)) =
|
||||
&mut indexing_code[0]
|
||||
{
|
||||
*v = old_v;
|
||||
}
|
||||
@@ -1364,14 +1361,12 @@ impl<'a> MachinePreludeView<'a> {
|
||||
) -> CompositeOpDir<'_, '_> {
|
||||
match compilation_target {
|
||||
CompilationTarget::User => CompositeOpDir::new(&self.indices.op_dir, None),
|
||||
CompilationTarget::Module(module_name) => {
|
||||
match self.indices.modules.get(module_name) {
|
||||
Some(module) => CompositeOpDir::new(&self.indices.op_dir, Some(&module.op_dir)),
|
||||
None => {
|
||||
unreachable!()
|
||||
}
|
||||
CompilationTarget::Module(module_name) => match self.indices.modules.get(module_name) {
|
||||
Some(module) => CompositeOpDir::new(&self.indices.op_dir, Some(&module.op_dir)),
|
||||
None => {
|
||||
unreachable!()
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1504,9 +1499,10 @@ impl Machine {
|
||||
}
|
||||
|
||||
pub(crate) fn load_compiled_library(&mut self) -> CallResult {
|
||||
let library = cell_as_atom!(self
|
||||
.machine_st
|
||||
.store(self.machine_st.deref(self.machine_st.registers[1])));
|
||||
let library = cell_as_atom!(
|
||||
self.machine_st
|
||||
.store(self.machine_st.deref(self.machine_st.registers[1]))
|
||||
);
|
||||
|
||||
if let Some(module) = self.indices.modules.get(&library) {
|
||||
if let ListingSource::DynamicallyGenerated = module.listing_src {
|
||||
@@ -1537,9 +1533,10 @@ impl Machine {
|
||||
}
|
||||
|
||||
pub(crate) fn declare_module(&mut self) -> CallResult {
|
||||
let module_name = cell_as_atom!(self
|
||||
.machine_st
|
||||
.store(self.machine_st.deref(self.machine_st.registers[1])));
|
||||
let module_name = cell_as_atom!(
|
||||
self.machine_st
|
||||
.store(self.machine_st.deref(self.machine_st.registers[1]))
|
||||
);
|
||||
|
||||
let mut loader = self.loader_from_heap_evacuable(temp_v!(3));
|
||||
|
||||
@@ -1649,9 +1646,10 @@ impl Machine {
|
||||
}
|
||||
|
||||
pub(crate) fn add_goal_expansion_clause(&mut self) -> CallResult {
|
||||
let target_module_name = cell_as_atom!(self
|
||||
.machine_st
|
||||
.store(self.machine_st.deref(self.machine_st.registers[1])));
|
||||
let target_module_name = cell_as_atom!(
|
||||
self.machine_st
|
||||
.store(self.machine_st.deref(self.machine_st.registers[1]))
|
||||
);
|
||||
|
||||
let mut loader = self.loader_from_heap_evacuable(temp_v!(3));
|
||||
|
||||
@@ -1744,9 +1742,10 @@ impl Machine {
|
||||
&mut self,
|
||||
r: RegType,
|
||||
) -> Loader<'_, LiveLoadAndMachineState<'_>> {
|
||||
let mut load_state = cell_as_load_state_payload!(self
|
||||
.machine_st
|
||||
.store(self.machine_st.deref(self.machine_st[r])));
|
||||
let mut load_state = cell_as_load_state_payload!(
|
||||
self.machine_st
|
||||
.store(self.machine_st.deref(self.machine_st[r]))
|
||||
);
|
||||
|
||||
load_state.set_tag(ArenaHeaderTag::LiveLoadState);
|
||||
|
||||
@@ -2098,9 +2097,10 @@ impl Machine {
|
||||
}
|
||||
|
||||
pub(crate) fn abolish_clause(&mut self) -> CallResult {
|
||||
let module_name = cell_as_atom!(self
|
||||
.machine_st
|
||||
.store(self.machine_st.deref(self.machine_st.registers[1])));
|
||||
let module_name = cell_as_atom!(
|
||||
self.machine_st
|
||||
.store(self.machine_st.deref(self.machine_st.registers[1]))
|
||||
);
|
||||
|
||||
let key = self
|
||||
.machine_st
|
||||
@@ -2214,9 +2214,10 @@ impl Machine {
|
||||
_ => unreachable!(),
|
||||
};
|
||||
|
||||
let module_name = cell_as_atom!(self
|
||||
.machine_st
|
||||
.store(self.machine_st.deref(self.machine_st.registers[4])));
|
||||
let module_name = cell_as_atom!(
|
||||
self.machine_st
|
||||
.store(self.machine_st.deref(self.machine_st.registers[4]))
|
||||
);
|
||||
|
||||
let compilation_target = match module_name {
|
||||
atom!("user") => CompilationTarget::User,
|
||||
@@ -2269,9 +2270,10 @@ impl Machine {
|
||||
}
|
||||
|
||||
pub(crate) fn is_consistent_with_term_queue(&mut self) -> CallResult {
|
||||
let module_name = cell_as_atom!(self
|
||||
.machine_st
|
||||
.store(self.machine_st.deref(self.machine_st.registers[1])));
|
||||
let module_name = cell_as_atom!(
|
||||
self.machine_st
|
||||
.store(self.machine_st.deref(self.machine_st.registers[1]))
|
||||
);
|
||||
|
||||
let key = self
|
||||
.machine_st
|
||||
@@ -2309,9 +2311,10 @@ impl Machine {
|
||||
}
|
||||
|
||||
pub(crate) fn remove_module_exports(&mut self) -> CallResult {
|
||||
let module_name = cell_as_atom!(self
|
||||
.machine_st
|
||||
.store(self.machine_st.deref(self.machine_st.registers[1])));
|
||||
let module_name = cell_as_atom!(
|
||||
self.machine_st
|
||||
.store(self.machine_st.deref(self.machine_st.registers[1]))
|
||||
);
|
||||
|
||||
let mut loader = self.loader_from_heap_evacuable(temp_v!(2));
|
||||
|
||||
@@ -2337,9 +2340,10 @@ impl Machine {
|
||||
}
|
||||
|
||||
pub(crate) fn meta_predicate_property(&mut self) {
|
||||
let module_name = cell_as_atom!(self
|
||||
.machine_st
|
||||
.store(self.machine_st.deref(self.machine_st.registers[1])));
|
||||
let module_name = cell_as_atom!(
|
||||
self.machine_st
|
||||
.store(self.machine_st.deref(self.machine_st.registers[1]))
|
||||
);
|
||||
|
||||
let (predicate_name, arity) = self
|
||||
.machine_st
|
||||
@@ -2401,9 +2405,10 @@ impl Machine {
|
||||
}
|
||||
|
||||
pub(crate) fn dynamic_property(&mut self) {
|
||||
let module_name = cell_as_atom!(self
|
||||
.machine_st
|
||||
.store(self.machine_st.deref(self.machine_st.registers[1])));
|
||||
let module_name = cell_as_atom!(
|
||||
self.machine_st
|
||||
.store(self.machine_st.deref(self.machine_st.registers[1]))
|
||||
);
|
||||
|
||||
let key = self
|
||||
.machine_st
|
||||
@@ -2428,9 +2433,10 @@ impl Machine {
|
||||
}
|
||||
|
||||
pub(crate) fn multifile_property(&mut self) {
|
||||
let module_name = cell_as_atom!(self
|
||||
.machine_st
|
||||
.store(self.machine_st.deref(self.machine_st.registers[1])));
|
||||
let module_name = cell_as_atom!(
|
||||
self.machine_st
|
||||
.store(self.machine_st.deref(self.machine_st.registers[1]))
|
||||
);
|
||||
|
||||
let key = self
|
||||
.machine_st
|
||||
@@ -2455,9 +2461,10 @@ impl Machine {
|
||||
}
|
||||
|
||||
pub(crate) fn discontiguous_property(&mut self) {
|
||||
let module_name = cell_as_atom!(self
|
||||
.machine_st
|
||||
.store(self.machine_st.deref(self.machine_st.registers[1])));
|
||||
let module_name = cell_as_atom!(
|
||||
self.machine_st
|
||||
.store(self.machine_st.deref(self.machine_st.registers[1]))
|
||||
);
|
||||
|
||||
let key = self
|
||||
.machine_st
|
||||
|
||||
@@ -777,7 +777,9 @@ impl MachineState {
|
||||
// throw an error pre-allocated in the heap
|
||||
pub(super) fn throw_resource_error(&mut self, err: AllocError) {
|
||||
if self.throwing_resource_error {
|
||||
panic!("attempted to throw `error(resource_error(memory), [])` while attempting to throw `error(resource_error(memory), [])`");
|
||||
panic!(
|
||||
"attempted to throw `error(resource_error(memory), [])` while attempting to throw `error(resource_error(memory), [])`"
|
||||
);
|
||||
}
|
||||
self.throwing_resource_error = true;
|
||||
|
||||
|
||||
@@ -2,17 +2,17 @@ use crate::parser::ast::*;
|
||||
|
||||
use crate::atom_table::*;
|
||||
use crate::forms::*;
|
||||
use crate::machine::ClauseType;
|
||||
use crate::machine::MachineStubGen;
|
||||
use crate::machine::loader::*;
|
||||
use crate::machine::machine_state::*;
|
||||
use crate::machine::streams::{Stream, StreamOptions};
|
||||
use crate::machine::ClauseType;
|
||||
use crate::machine::MachineStubGen;
|
||||
use crate::offset_table::*;
|
||||
|
||||
use fxhash::FxBuildHasher;
|
||||
use indexmap::{IndexMap, IndexSet};
|
||||
use modular_bitfield::specifiers::*;
|
||||
use modular_bitfield::{bitfield, Specifier};
|
||||
use modular_bitfield::{Specifier, bitfield};
|
||||
|
||||
use std::cmp::Ordering;
|
||||
use std::collections::BTreeSet;
|
||||
|
||||
@@ -3,6 +3,7 @@ use crate::atom_table::*;
|
||||
use crate::forms::*;
|
||||
use crate::heap_iter::*;
|
||||
use crate::heap_print::*;
|
||||
use crate::machine::Machine;
|
||||
use crate::machine::attributed_variables::*;
|
||||
use crate::machine::copier::*;
|
||||
use crate::machine::heap::AllocError;
|
||||
@@ -11,7 +12,6 @@ use crate::machine::machine_errors::*;
|
||||
use crate::machine::machine_indices::*;
|
||||
use crate::machine::stack::*;
|
||||
use crate::machine::streams::*;
|
||||
use crate::machine::Machine;
|
||||
use crate::parser::ast::*;
|
||||
use crate::read::TermWriteResult;
|
||||
use crate::types::*;
|
||||
|
||||
@@ -61,8 +61,8 @@ use std::env;
|
||||
use std::io::Read;
|
||||
use std::path::PathBuf;
|
||||
use std::process::ExitCode;
|
||||
use std::sync::atomic::AtomicBool;
|
||||
use std::sync::OnceLock;
|
||||
use std::sync::atomic::AtomicBool;
|
||||
|
||||
pub static INTERRUPT: AtomicBool = AtomicBool::new(false);
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ fn setup_op_decl(mut terms: Vec<Term>) -> Result<OpDecl, CompilationError> {
|
||||
other => {
|
||||
return Err(CompilationError::InvalidDirective(
|
||||
DirectiveError::InvalidOpDeclSpecDomain(other),
|
||||
))
|
||||
));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -175,15 +175,17 @@ impl Stack {
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
unsafe fn alloc(&mut self, frame_size: usize) -> Result<NonNull<u8>, AllocError> { unsafe {
|
||||
loop {
|
||||
let ptr = self.buf.alloc(frame_size);
|
||||
if let Some(ptr) = NonNull::new(ptr) {
|
||||
return Ok(ptr);
|
||||
unsafe fn alloc(&mut self, frame_size: usize) -> Result<NonNull<u8>, AllocError> {
|
||||
unsafe {
|
||||
loop {
|
||||
let ptr = self.buf.alloc(frame_size);
|
||||
if let Some(ptr) = NonNull::new(ptr) {
|
||||
return Ok(ptr);
|
||||
}
|
||||
self.buf.grow()?;
|
||||
}
|
||||
self.buf.grow()?;
|
||||
}
|
||||
}}
|
||||
}
|
||||
|
||||
pub(crate) fn allocate_and_frame(&mut self, num_cells: usize) -> Result<usize, AllocError> {
|
||||
let frame_size = AndFrame::size_of(num_cells);
|
||||
|
||||
@@ -15,7 +15,7 @@ use crate::types::*;
|
||||
pub use modular_bitfield::prelude::*;
|
||||
|
||||
#[cfg(feature = "http")]
|
||||
use bytes::{buf::Reader as BufReader, Buf, Bytes};
|
||||
use bytes::{Buf, Bytes, buf::Reader as BufReader};
|
||||
use std::cmp::Ordering;
|
||||
use std::error::Error;
|
||||
use std::fmt;
|
||||
@@ -2195,8 +2195,8 @@ mod test {
|
||||
use crate::*;
|
||||
use std::{cell::RefCell, io::Read, io::Write, rc::Rc};
|
||||
|
||||
use crate::machine::config::*;
|
||||
use crate::LeafAnswer;
|
||||
use crate::machine::config::*;
|
||||
|
||||
use super::{Stream, StreamOptions};
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ use crate::machine::machine_state::*;
|
||||
use crate::machine::partial_string::*;
|
||||
use crate::machine::stack::*;
|
||||
use crate::machine::streams::*;
|
||||
use crate::machine::{get_structure_index, Machine};
|
||||
use crate::machine::{Machine, get_structure_index};
|
||||
use crate::parser::ast::*;
|
||||
use crate::parser::char_reader::*;
|
||||
use crate::parser::dashu::Integer;
|
||||
@@ -48,7 +48,7 @@ use std::ffi::CString;
|
||||
use std::fs;
|
||||
use std::hash::{BuildHasher, BuildHasherDefault};
|
||||
use std::io::{ErrorKind, Read, Write};
|
||||
use std::iter::{once, FromIterator};
|
||||
use std::iter::{FromIterator, once};
|
||||
use std::mem;
|
||||
#[cfg(feature = "http")]
|
||||
use std::net::{SocketAddr, ToSocketAddrs};
|
||||
@@ -63,13 +63,13 @@ use std::sync::LazyLock;
|
||||
use std::sync::{Arc, Condvar, Mutex};
|
||||
use tokio::sync::Notify;
|
||||
|
||||
use chrono::{offset::Local, DateTime};
|
||||
use chrono::{DateTime, offset::Local};
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
use cpu_time::ProcessTime;
|
||||
use std::time::{Duration, SystemTime};
|
||||
|
||||
#[cfg(feature = "repl")]
|
||||
use crate::read::user_interaction::{get_key, KeyCode, KeyModifiers};
|
||||
use crate::read::user_interaction::{KeyCode, KeyModifiers, get_key};
|
||||
|
||||
use blake2::{Blake2b512, Blake2s256};
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::machine::Number;
|
||||
use crate::Machine;
|
||||
use crate::machine::Number;
|
||||
use ordered_float::OrderedFloat;
|
||||
use puruspe::beta::*;
|
||||
use puruspe::error::*;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use crate::arena::*;
|
||||
use crate::forms::*;
|
||||
use crate::heap_iter::{stackful_preorder_iter, NonListElider};
|
||||
use crate::heap_iter::{NonListElider, stackful_preorder_iter};
|
||||
use crate::machine::machine_state::*;
|
||||
use crate::machine::*;
|
||||
use crate::offset_table::*;
|
||||
|
||||
Reference in New Issue
Block a user