Issue 3223: Second phase of migration to Rust Edition

Reformat via `cargo fmt`
This commit is contained in:
Alexander McLin
2026-04-02 16:08:06 -04:00
parent efbddeaeee
commit fcd6c3f127
40 changed files with 468 additions and 496 deletions

View File

@@ -1,5 +1,5 @@
#[cfg(not(all(target_arch = "wasm32", target_os = "unknown")))] #[cfg(not(all(target_arch = "wasm32", target_os = "unknown")))]
use criterion::{criterion_group, criterion_main, BatchSize, Criterion}; use criterion::{BatchSize, Criterion, criterion_group, criterion_main};
#[cfg(not(all(target_arch = "wasm32", target_os = "unknown")))] #[cfg(not(all(target_arch = "wasm32", target_os = "unknown")))]
#[cfg(not(target_os = "windows"))] #[cfg(not(target_os = "windows"))]

View File

@@ -4,7 +4,7 @@
// //
use proc_macro2::TokenStream; use proc_macro2::TokenStream;
use quote::{format_ident, quote, ToTokens, TokenStreamExt}; use quote::{ToTokens, TokenStreamExt, format_ident, quote};
use strum_macros::{EnumDiscriminants, EnumProperty, EnumString}; use strum_macros::{EnumDiscriminants, EnumProperty, EnumString};
use syn::*; use syn::*;
use to_syn_value_derive::ToDeriveInput; use to_syn_value_derive::ToDeriveInput;

View File

@@ -8,9 +8,9 @@ use std::collections::BTreeMap;
use std::env; use std::env;
use std::fs::File; use std::fs::File;
use std::io::Write; use std::io::Write;
use std::path::MAIN_SEPARATOR_STR;
use std::path::Path; use std::path::Path;
use std::path::PathBuf; use std::path::PathBuf;
use std::path::MAIN_SEPARATOR_STR;
use std::process::{Command, Stdio}; use std::process::{Command, Stdio};
fn find_prolog_files(path_prefix: &str, current_dir: &Path) -> Vec<(String, PathBuf)> { fn find_prolog_files(path_prefix: &str, current_dir: &Path) -> Vec<(String, PathBuf)> {

View File

@@ -21,8 +21,8 @@ use std::net::TcpListener;
use std::ops::{Deref, DerefMut}; use std::ops::{Deref, DerefMut};
use std::process::Child; use std::process::Child;
use std::ptr; use std::ptr;
use std::ptr::addr_of_mut;
use std::ptr::NonNull; use std::ptr::NonNull;
use std::ptr::addr_of_mut;
macro_rules! arena_alloc { macro_rules! arena_alloc {
($e:expr, $arena:expr) => {{ ($e:expr, $arena:expr) => {{
@@ -32,9 +32,7 @@ macro_rules! arena_alloc {
} }
macro_rules! float_alloc { macro_rules! float_alloc {
($e:expr, $arena:expr) => {{ ($e:expr, $arena:expr) => {{ $arena.f64_tbl.build_with(OrderedFloat($e)) }};
$arena.f64_tbl.build_with(OrderedFloat($e))
}};
} }
pub fn header_offset_from_payload<T: ?Sized + ArenaAllocated>() -> usize pub fn header_offset_from_payload<T: ?Sized + ArenaAllocated>() -> usize
@@ -281,14 +279,16 @@ pub trait ArenaAllocated {
unsafe fn typed_ptr(ptr: UntypedArenaPtr) -> TypedArenaPtr<Self> unsafe fn typed_ptr(ptr: UntypedArenaPtr) -> TypedArenaPtr<Self>
where where
Self::Payload: Sized, Self::Payload: Sized,
{ unsafe { {
TypedArenaPtr(NonNull::new_unchecked( unsafe {
ptr.get_ptr() TypedArenaPtr(NonNull::new_unchecked(
.byte_add(Self::header_offset_from_payload()) ptr.get_ptr()
.cast_mut() .byte_add(Self::header_offset_from_payload())
.cast::<Self::Payload>(), .cast_mut()
)) .cast::<Self::Payload>(),
}} ))
}
}
#[allow(clippy::missing_safety_doc)] #[allow(clippy::missing_safety_doc)]
fn alloc(arena: &mut Arena, value: Self::Payload) -> TypedArenaPtr<Self> fn alloc(arena: &mut Arena, value: Self::Payload) -> TypedArenaPtr<Self>
@@ -496,91 +496,93 @@ impl Arena {
} }
} }
unsafe fn drop_slab_in_place(value: NonNull<AllocSlab>, tag: ArenaHeaderTag) { unsafe { unsafe fn drop_slab_in_place(value: NonNull<AllocSlab>, tag: ArenaHeaderTag) {
macro_rules! drop_typed_slab_in_place { unsafe {
($payload: ty, $value: expr) => { macro_rules! drop_typed_slab_in_place {
<$payload as ArenaAllocated>::dealloc($value.cast::<TypedAllocSlab<$payload>>()) ($payload: ty, $value: expr) => {
}; <$payload as ArenaAllocated>::dealloc($value.cast::<TypedAllocSlab<$payload>>())
} };
}
match tag { match tag {
ArenaHeaderTag::Integer => { ArenaHeaderTag::Integer => {
drop_typed_slab_in_place!(Integer, value); drop_typed_slab_in_place!(Integer, value);
} }
ArenaHeaderTag::Rational => { ArenaHeaderTag::Rational => {
drop_typed_slab_in_place!(Rational, value); drop_typed_slab_in_place!(Rational, value);
} }
ArenaHeaderTag::InputFileStream => { ArenaHeaderTag::InputFileStream => {
drop_typed_slab_in_place!(InputFileStream, value); drop_typed_slab_in_place!(InputFileStream, value);
} }
ArenaHeaderTag::OutputFileStream => { ArenaHeaderTag::OutputFileStream => {
drop_typed_slab_in_place!(OutputFileStream, value); drop_typed_slab_in_place!(OutputFileStream, value);
} }
ArenaHeaderTag::NamedTcpStream => { ArenaHeaderTag::NamedTcpStream => {
drop_typed_slab_in_place!(NamedTcpStream, value); drop_typed_slab_in_place!(NamedTcpStream, value);
} }
ArenaHeaderTag::NamedTlsStream => { ArenaHeaderTag::NamedTlsStream => {
#[cfg(feature = "tls")] #[cfg(feature = "tls")]
drop_typed_slab_in_place!(NamedTlsStream, value); drop_typed_slab_in_place!(NamedTlsStream, value);
} }
ArenaHeaderTag::HttpReadStream => { ArenaHeaderTag::HttpReadStream => {
#[cfg(feature = "http")] #[cfg(feature = "http")]
drop_typed_slab_in_place!(HttpReadStream, value); drop_typed_slab_in_place!(HttpReadStream, value);
} }
ArenaHeaderTag::HttpWriteStream => { ArenaHeaderTag::HttpWriteStream => {
#[cfg(feature = "http")] #[cfg(feature = "http")]
drop_typed_slab_in_place!(HttpWriteStream, value); drop_typed_slab_in_place!(HttpWriteStream, value);
} }
ArenaHeaderTag::ReadlineStream => { ArenaHeaderTag::ReadlineStream => {
drop_typed_slab_in_place!(ReadlineStream, value); drop_typed_slab_in_place!(ReadlineStream, value);
} }
ArenaHeaderTag::StaticStringStream => { ArenaHeaderTag::StaticStringStream => {
drop_typed_slab_in_place!(StaticStringStream, value); drop_typed_slab_in_place!(StaticStringStream, value);
} }
ArenaHeaderTag::ByteStream => { ArenaHeaderTag::ByteStream => {
drop_typed_slab_in_place!(ByteStream, value); drop_typed_slab_in_place!(ByteStream, value);
} }
ArenaHeaderTag::CallbackStream => { ArenaHeaderTag::CallbackStream => {
drop_typed_slab_in_place!(CallbackStream, value); drop_typed_slab_in_place!(CallbackStream, value);
} }
ArenaHeaderTag::InputChannelStream => { ArenaHeaderTag::InputChannelStream => {
drop_typed_slab_in_place!(InputChannelStream, value); drop_typed_slab_in_place!(InputChannelStream, value);
} }
ArenaHeaderTag::LiveLoadState | ArenaHeaderTag::InactiveLoadState => { ArenaHeaderTag::LiveLoadState | ArenaHeaderTag::InactiveLoadState => {
drop_typed_slab_in_place!(LiveLoadState, value); drop_typed_slab_in_place!(LiveLoadState, value);
} }
ArenaHeaderTag::Dropped => {} ArenaHeaderTag::Dropped => {}
ArenaHeaderTag::TcpListener => { ArenaHeaderTag::TcpListener => {
drop_typed_slab_in_place!(TcpListener, value); drop_typed_slab_in_place!(TcpListener, value);
} }
ArenaHeaderTag::HttpListener => { ArenaHeaderTag::HttpListener => {
#[cfg(feature = "http")] #[cfg(feature = "http")]
drop_typed_slab_in_place!(HttpListener, value); drop_typed_slab_in_place!(HttpListener, value);
} }
ArenaHeaderTag::HttpResponse => { ArenaHeaderTag::HttpResponse => {
#[cfg(feature = "http")] #[cfg(feature = "http")]
drop_typed_slab_in_place!(HttpResponse, value); drop_typed_slab_in_place!(HttpResponse, value);
} }
ArenaHeaderTag::StandardOutputStream => { ArenaHeaderTag::StandardOutputStream => {
drop_typed_slab_in_place!(StandardOutputStream, value); drop_typed_slab_in_place!(StandardOutputStream, value);
} }
ArenaHeaderTag::StandardErrorStream => { ArenaHeaderTag::StandardErrorStream => {
drop_typed_slab_in_place!(StandardErrorStream, value); drop_typed_slab_in_place!(StandardErrorStream, value);
} }
ArenaHeaderTag::PipeReader => { ArenaHeaderTag::PipeReader => {
drop_typed_slab_in_place!(PipeReader, value); drop_typed_slab_in_place!(PipeReader, value);
} }
ArenaHeaderTag::PipeWriter => { ArenaHeaderTag::PipeWriter => {
drop_typed_slab_in_place!(PipeWriter, value); drop_typed_slab_in_place!(PipeWriter, value);
} }
ArenaHeaderTag::ChildProcess => { ArenaHeaderTag::ChildProcess => {
drop_typed_slab_in_place!(Child, value); drop_typed_slab_in_place!(Child, value);
} }
ArenaHeaderTag::NullStream => { ArenaHeaderTag::NullStream => {
unreachable!("NullStream is never arena allocated!"); unreachable!("NullStream is never arena allocated!");
}
} }
} }
}} }
impl Drop for Arena { impl Drop for Arena {
fn drop(&mut self) { fn drop(&mut self) {

View File

@@ -64,7 +64,7 @@ impl<'a> ArithInstructionIterator<'a> {
return Err(ArithmeticError::NonEvaluableFunctor( return Err(ArithmeticError::NonEvaluableFunctor(
Literal::Atom(atom!(".")), Literal::Atom(atom!(".")),
2, 2,
)) ));
} }
Term::Var(cell, var_ptr) => TermIterState::Var(Level::Shallow, cell, var_ptr.clone()), Term::Var(cell, var_ptr) => TermIterState::Var(Level::Shallow, cell, var_ptr.clone()),
}; };
@@ -519,26 +519,16 @@ impl PartialEq for Number {
(&Number::Fixnum(n1), Number::Rational(n2)) => { (&Number::Fixnum(n1), Number::Rational(n2)) => {
Integer::from(n1.get_num()).num_eq(&**n2) Integer::from(n1.get_num()).num_eq(&**n2)
} }
(Number::Rational(n1), &Number::Fixnum(n2)) => { (Number::Rational(n1), &Number::Fixnum(n2)) => n1.num_eq(&Integer::from(n2.get_num())),
n1.num_eq(&Integer::from(n2.get_num()))
}
(&Number::Fixnum(n1), &Number::Float(n2)) => OrderedFloat(n1.get_num() as f64).eq(&n2), (&Number::Fixnum(n1), &Number::Float(n2)) => OrderedFloat(n1.get_num() as f64).eq(&n2),
(&Number::Float(n1), &Number::Fixnum(n2)) => n1.eq(&OrderedFloat(n2.get_num() as f64)), (&Number::Float(n1), &Number::Fixnum(n2)) => n1.eq(&OrderedFloat(n2.get_num() as f64)),
(Number::Integer(n1), Number::Integer(n2)) => n1.eq(n2), (Number::Integer(n1), Number::Integer(n2)) => n1.eq(n2),
(Number::Integer(n1), Number::Float(n2)) => { (Number::Integer(n1), Number::Float(n2)) => OrderedFloat(n1.to_f64().value()).eq(n2),
OrderedFloat(n1.to_f64().value()).eq(n2) (&Number::Float(n1), Number::Integer(n2)) => n1.eq(&OrderedFloat(n2.to_f64().value())),
}
(&Number::Float(n1), Number::Integer(n2)) => {
n1.eq(&OrderedFloat(n2.to_f64().value()))
}
(Number::Integer(n1), Number::Rational(n2)) => n1.num_eq(&**n2), (Number::Integer(n1), Number::Rational(n2)) => n1.num_eq(&**n2),
(Number::Rational(n1), Number::Integer(n2)) => n1.num_eq(&**n2), (Number::Rational(n1), Number::Integer(n2)) => n1.num_eq(&**n2),
(Number::Rational(n1), &Number::Float(n2)) => { (Number::Rational(n1), &Number::Float(n2)) => OrderedFloat(n1.to_f64().value()).eq(&n2),
OrderedFloat(n1.to_f64().value()).eq(&n2) (&Number::Float(n1), Number::Rational(n2)) => n1.eq(&OrderedFloat(n2.to_f64().value())),
}
(&Number::Float(n1), Number::Rational(n2)) => {
n1.eq(&OrderedFloat(n2.to_f64().value()))
}
(&Number::Float(f1), &Number::Float(f2)) => f1.eq(&f2), (&Number::Float(f1), &Number::Float(f2)) => f1.eq(&f2),
(Number::Rational(r1), Number::Rational(r2)) => r1.eq(r2), (Number::Rational(r1), Number::Rational(r2)) => r1.eq(r2),
} }
@@ -607,9 +597,7 @@ impl Ord for Number {
(&Number::Float(n1), &Number::Fixnum(n2)) => n1.cmp(&OrderedFloat(n2.get_num() as f64)), (&Number::Float(n1), &Number::Fixnum(n2)) => n1.cmp(&OrderedFloat(n2.get_num() as f64)),
(&Number::Integer(n1), &Number::Integer(n2)) => (*n1).cmp(&*n2), (&Number::Integer(n1), &Number::Integer(n2)) => (*n1).cmp(&*n2),
(&Number::Integer(n1), Number::Float(n2)) => OrderedFloat(n1.to_f64().value()).cmp(n2), (&Number::Integer(n1), Number::Float(n2)) => OrderedFloat(n1.to_f64().value()).cmp(n2),
(&Number::Float(n1), Number::Integer(n2)) => { (&Number::Float(n1), Number::Integer(n2)) => n1.cmp(&OrderedFloat(n2.to_f64().value())),
n1.cmp(&OrderedFloat(n2.to_f64().value()))
}
(&Number::Integer(n1), &Number::Rational(n2)) => { (&Number::Integer(n1), &Number::Rational(n2)) => {
(*n1).num_partial_cmp(&*n2).unwrap_or(Ordering::Less) (*n1).num_partial_cmp(&*n2).unwrap_or(Ordering::Less)
} }

View File

@@ -14,10 +14,10 @@ use std::sync::Mutex;
use std::sync::RwLock; use std::sync::RwLock;
use std::sync::Weak; use std::sync::Weak;
use arcu::Rcu;
use arcu::atomic::Arcu; use arcu::atomic::Arcu;
use arcu::epoch_counters::GlobalEpochCounterPool; use arcu::epoch_counters::GlobalEpochCounterPool;
use arcu::rcu_ref::RcuRef; use arcu::rcu_ref::RcuRef;
use arcu::Rcu;
use indexmap::IndexSet; use indexmap::IndexSet;
use modular_bitfield::prelude::*; use modular_bitfield::prelude::*;
@@ -344,11 +344,7 @@ impl Atom {
let c1 = it.next(); let c1 = it.next();
let c2 = it.next(); let c2 = it.next();
if c2.is_none() { if c2.is_none() { c1 } else { None }
c1
} else {
None
}
} }
#[inline] #[inline]
@@ -388,7 +384,9 @@ impl Atom {
} }
unsafe fn write_to_ptr(string: &str, ptr: *mut u8) { unsafe fn write_to_ptr(string: &str, ptr: *mut u8) {
unsafe { ptr::write(ptr as *mut _, AtomHeader::build_with(string.len() as u64)); } unsafe {
ptr::write(ptr as *mut _, AtomHeader::build_with(string.len() as u64));
}
unsafe { unsafe {
let str_ptr = ptr.add(mem::size_of::<AtomHeader>()); let str_ptr = ptr.add(mem::size_of::<AtomHeader>());
ptr::copy_nonoverlapping(string.as_ptr(), str_ptr, string.len()); ptr::copy_nonoverlapping(string.as_ptr(), str_ptr, string.len());

View File

@@ -551,8 +551,7 @@ impl DebrayAllocator {
} else if let Some(&temp_var_num) = self.shallow_temp_mappings.get(&self.arg_c) { } else if let Some(&temp_var_num) = self.shallow_temp_mappings.get(&self.arg_c) {
match &mut self.var_data.records[temp_var_num].allocation { match &mut self.var_data.records[temp_var_num].allocation {
VarAlloc::Temp { VarAlloc::Temp {
to_perm_var_num, to_perm_var_num, ..
..
} => { } => {
*to_perm_var_num = Some(var_num); *to_perm_var_num = Some(var_num);
} }
@@ -578,13 +577,7 @@ impl DebrayAllocator {
let branch_designator = Arc::new(self.branch_stack.current_branch_designator()); let branch_designator = Arc::new(self.branch_stack.current_branch_designator());
match &mut self.var_data.records[var_num].allocation { match &mut self.var_data.records[var_num].allocation {
VarAlloc::Perm( VarAlloc::Perm(_, PermVarAllocation::Done { shallow_safety, .. }) => {
_,
PermVarAllocation::Done {
shallow_safety,
..
},
) => {
if !self.in_tail_position if !self.in_tail_position
|| self || self
.branch_stack .branch_stack
@@ -614,13 +607,7 @@ impl DebrayAllocator {
let branch_designator = Arc::new(self.branch_stack.current_branch_designator()); let branch_designator = Arc::new(self.branch_stack.current_branch_designator());
match &mut self.var_data.records[var_num].allocation { match &mut self.var_data.records[var_num].allocation {
VarAlloc::Perm( VarAlloc::Perm(_, PermVarAllocation::Done { deep_safety, .. }) => {
_,
PermVarAllocation::Done {
deep_safety,
..
},
) => {
if self if self
.branch_stack .branch_stack
.safety_unneeded_in_branch(deep_safety, &branch_designator) .safety_unneeded_in_branch(deep_safety, &branch_designator)

View File

@@ -32,7 +32,7 @@ use ordered_float::OrderedFloat;
use std::alloc::{self, Layout}; use std::alloc::{self, Layout};
use std::collections::HashMap; use std::collections::HashMap;
use std::error::Error; use std::error::Error;
use std::ffi::{c_char, c_void, CStr, CString}; use std::ffi::{CStr, CString, c_char, c_void};
use std::fmt::Debug; use std::fmt::Debug;
use std::marker::PhantomData; use std::marker::PhantomData;
use std::mem::ManuallyDrop; use std::mem::ManuallyDrop;
@@ -53,27 +53,33 @@ pub struct FunctionImpl {
} }
impl FunctionImpl { impl FunctionImpl {
unsafe fn call_void(&self, args: &[Arg], _: &mut Arena) -> Result<Value, FfiError> { unsafe { unsafe fn call_void(&self, args: &[Arg], _: &mut Arena) -> Result<Value, FfiError> {
self.cif.call_return_into(self.code_ptr, args, Ret::void()); unsafe {
Ok(Value::Number(Number::Fixnum(Fixnum::build_with(0)))) self.cif.call_return_into(self.code_ptr, args, Ret::void());
}} Ok(Value::Number(Number::Fixnum(Fixnum::build_with(0))))
}
}
unsafe fn call_int<T>(&self, args: &[Arg], arena: &mut Arena) -> Result<Value, FfiError> unsafe fn call_int<T>(&self, args: &[Arg], arena: &mut Arena) -> Result<Value, FfiError>
where where
Integer: From<T>, Integer: From<T>,
T: Copy + TryInto<i64> + MightNotFitInFixnum, T: Copy + TryInto<i64> + MightNotFitInFixnum,
{ unsafe { {
let n = self.cif.call::<T>(self.code_ptr, args); unsafe {
Ok(Value::Number(fixnum!(Number, n, arena))) let n = self.cif.call::<T>(self.code_ptr, args);
}} Ok(Value::Number(fixnum!(Number, n, arena)))
}
}
unsafe fn call_float<T>(&self, args: &[Arg], _: &mut Arena) -> Result<Value, FfiError> unsafe fn call_float<T>(&self, args: &[Arg], _: &mut Arena) -> Result<Value, FfiError>
where where
T: Into<f64>, T: Into<f64>,
{ unsafe { {
let n = self.cif.call::<T>(self.code_ptr, args); unsafe {
Ok(Value::Number(Number::Float(OrderedFloat(n.into())))) let n = self.cif.call::<T>(self.code_ptr, args);
}} Ok(Value::Number(Number::Float(OrderedFloat(n.into()))))
}
}
unsafe fn call_ptr(&self, args: &[Arg], arena: &mut Arena) -> Result<Value, FfiError> { unsafe fn call_ptr(&self, args: &[Arg], arena: &mut Arena) -> Result<Value, FfiError> {
let ptr = unsafe { self.cif.call::<*mut c_void>(self.code_ptr, args) }; let ptr = unsafe { self.cif.call::<*mut c_void>(self.code_ptr, args) };
@@ -147,7 +153,7 @@ impl FunctionImpl {
FfiType::Ptr => FunctionImpl::call_ptr, FfiType::Ptr => FunctionImpl::call_ptr,
FfiType::CStr => FunctionImpl::call_cstr, FfiType::CStr => FunctionImpl::call_cstr,
FfiType::Struct(name) => { FfiType::Struct(name) => {
return unsafe { self.call_struct(name, args, arena, structs_table) } return unsafe { self.call_struct(name, args, arena, structs_table) };
} }
}; };
unsafe { call_fn(self, args, arena) } unsafe { call_fn(self, args, arena) }
@@ -197,14 +203,16 @@ impl StructImpl {
ptr: NonNull<c_void>, ptr: NonNull<c_void>,
layout: &mut Layout, layout: &mut Layout,
val: T, val: T,
) -> Result<(), FfiError> { unsafe { ) -> Result<(), FfiError> {
let (new_layout, offset) = layout unsafe {
.extend(Layout::new::<T>()) let (new_layout, offset) = layout
.map_err(|_| FfiError::LayoutError)?; .extend(Layout::new::<T>())
*layout = new_layout; .map_err(|_| FfiError::LayoutError)?;
ptr.byte_offset(offset as isize).cast::<T>().write(val); *layout = new_layout;
Ok(()) ptr.byte_offset(offset as isize).cast::<T>().write(val);
}} Ok(())
}
}
for arg in args { for arg in args {
unsafe { unsafe {
@@ -258,14 +266,16 @@ impl StructImpl {
unsafe fn read_primitive<T>( unsafe fn read_primitive<T>(
ptr: *mut c_void, ptr: *mut c_void,
layout: &mut Layout, layout: &mut Layout,
) -> Result<T, FfiError> { unsafe { ) -> Result<T, FfiError> {
let (new_layout, offset) = layout unsafe {
.extend(Layout::new::<T>()) let (new_layout, offset) = layout
.map_err(|_| FfiError::LayoutError)?; .extend(Layout::new::<T>())
*layout = new_layout; .map_err(|_| FfiError::LayoutError)?;
let n = std::ptr::read::<T>(ptr.byte_offset(offset as isize).cast()); *layout = new_layout;
Ok(n) let n = std::ptr::read::<T>(ptr.byte_offset(offset as isize).cast());
}} Ok(n)
}
}
unsafe fn read_int<T>( unsafe fn read_int<T>(
ptr: *mut c_void, ptr: *mut c_void,
@@ -275,10 +285,12 @@ impl StructImpl {
where where
T: Copy + TryInto<i64> + MightNotFitInFixnum, T: Copy + TryInto<i64> + MightNotFitInFixnum,
Integer: From<T>, Integer: From<T>,
{ unsafe { {
let n = read_primitive::<T>(ptr, layout)?; unsafe {
Ok(Value::Number(fixnum!(Number, n, arena))) let n = read_primitive::<T>(ptr, layout)?;
}} Ok(Value::Number(fixnum!(Number, n, arena)))
}
}
unsafe fn read_float<T>( unsafe fn read_float<T>(
ptr: *mut c_void, ptr: *mut c_void,
@@ -286,10 +298,12 @@ impl StructImpl {
) -> Result<Value, FfiError> ) -> Result<Value, FfiError>
where where
T: Into<f64>, T: Into<f64>,
{ unsafe { {
let n = read_primitive::<T>(ptr, layout)?; unsafe {
Ok(Value::Number(Number::Float(OrderedFloat(n.into())))) let n = read_primitive::<T>(ptr, layout)?;
}} Ok(Value::Number(Number::Float(OrderedFloat(n.into()))))
}
}
let mut layout = Layout::from_size_align(0, 1).map_err(|_| FfiError::LayoutError)?; let mut layout = Layout::from_size_align(0, 1).map_err(|_| FfiError::LayoutError)?;
@@ -332,7 +346,7 @@ impl StructImpl {
Ok(struct_val) Ok(struct_val)
} }
FfiType::Void => { FfiType::Void => {
return Err(FfiError::UnsupportedArgumentType(Some(atom!("void")))) return Err(FfiError::UnsupportedArgumentType(Some(atom!("void"))));
} }
}; };
returns.push(val?); returns.push(val?);
@@ -788,10 +802,12 @@ impl ForeignFunctionTable {
where where
T: Copy + TryInto<i64> + MightNotFitInFixnum, T: Copy + TryInto<i64> + MightNotFitInFixnum,
Integer: From<T>, Integer: From<T>,
{ unsafe { {
let n = ptr.cast::<T>().read(); unsafe {
Value::Number(fixnum!(Number, n, arena)) let n = ptr.cast::<T>().read();
}} Value::Number(fixnum!(Number, n, arena))
}
}
let ptr = ptr.as_ptr()?; let ptr = ptr.as_ptr()?;

View File

@@ -230,9 +230,9 @@ pub(crate) fn variadic_functor(
#[allow(unused_parens)] #[allow(unused_parens)]
mod tests { mod tests {
use super::*; use super::*;
use FunctorElement::*;
use indexmap::indexmap; use indexmap::indexmap;
use std::string::String; use std::string::String;
use FunctorElement::*;
#[test] #[test]
fn basic_terms() { fn basic_terms() {

View File

@@ -3,7 +3,7 @@ use crate::atom_table::*;
use crate::parser::ast::*; use crate::parser::ast::*;
use crate::parser::dashu::base::RemEuclid; use crate::parser::dashu::base::RemEuclid;
use crate::parser::dashu::integer::Sign; use crate::parser::dashu::integer::Sign;
use crate::parser::dashu::{ibig, Integer, Rational}; use crate::parser::dashu::{Integer, Rational, ibig};
use crate::forms::*; use crate::forms::*;
use crate::heap_iter::*; use crate::heap_iter::*;

View File

@@ -1,4 +1,4 @@
use bytes::{buf::Reader, Bytes}; use bytes::{Bytes, buf::Reader};
use std::sync::{Arc, Condvar, Mutex}; use std::sync::{Arc, Condvar, Mutex};
use tokio::sync::Notify; use tokio::sync::Notify;

View File

@@ -491,33 +491,29 @@ impl<'a> IndexingCodeMergingPtr<'a> {
let indexing_code_len = self.indexing_code.len(); let indexing_code_len = self.indexing_code.len();
match &mut self.indexing_code[self.offset] { match &mut self.indexing_code[self.offset] {
IndexingLine::Indexing(IndexingInstruction::SwitchOnTerm( IndexingLine::Indexing(IndexingInstruction::SwitchOnTerm(_, _, _, _, s)) => {
_, match *s {
_, IndexingCodePtr::Fail if self.is_dynamic => {
_, *s = IndexingCodePtr::DynamicExternal(index);
_, break;
s, }
)) => match *s { IndexingCodePtr::Fail => {
IndexingCodePtr::Fail if self.is_dynamic => { *s = IndexingCodePtr::External(index);
*s = IndexingCodePtr::DynamicExternal(index); break;
break; }
IndexingCodePtr::DynamicExternal(o) => {
*s = IndexingCodePtr::Internal(indexing_code_len - self.offset);
self.internalize_structure(IndexingCodePtr::DynamicExternal(o));
}
IndexingCodePtr::External(o) => {
*s = IndexingCodePtr::Internal(indexing_code_len - self.offset);
self.internalize_structure(IndexingCodePtr::External(o));
}
IndexingCodePtr::Internal(o) => {
self.offset += o;
}
} }
IndexingCodePtr::Fail => { }
*s = IndexingCodePtr::External(index);
break;
}
IndexingCodePtr::DynamicExternal(o) => {
*s = IndexingCodePtr::Internal(indexing_code_len - self.offset);
self.internalize_structure(IndexingCodePtr::DynamicExternal(o));
}
IndexingCodePtr::External(o) => {
*s = IndexingCodePtr::Internal(indexing_code_len - self.offset);
self.internalize_structure(IndexingCodePtr::External(o));
}
IndexingCodePtr::Internal(o) => {
self.offset += o;
}
},
IndexingLine::Indexing(IndexingInstruction::SwitchOnStructure(structures)) => { IndexingLine::Indexing(IndexingInstruction::SwitchOnStructure(structures)) => {
match structures.get(&key).cloned() { match structures.get(&key).cloned() {
None | Some(IndexingCodePtr::Fail) if self.is_dynamic => { None | Some(IndexingCodePtr::Fail) if self.is_dynamic => {
@@ -559,52 +555,50 @@ impl<'a> IndexingCodeMergingPtr<'a> {
let indexing_code_len = self.indexing_code.len(); let indexing_code_len = self.indexing_code.len();
match &mut self.indexing_code[self.offset] { match &mut self.indexing_code[self.offset] {
IndexingLine::Indexing(IndexingInstruction::SwitchOnTerm(_, _, _, l, _)) => { IndexingLine::Indexing(IndexingInstruction::SwitchOnTerm(_, _, _, l, _)) => match *l {
match *l { IndexingCodePtr::Fail if self.is_dynamic => {
IndexingCodePtr::Fail if self.is_dynamic => { *l = IndexingCodePtr::DynamicExternal(index);
*l = IndexingCodePtr::DynamicExternal(index);
}
IndexingCodePtr::Fail => {
*l = IndexingCodePtr::External(index);
}
IndexingCodePtr::DynamicExternal(o) => {
*l = IndexingCodePtr::Internal(indexing_code_len - self.offset);
let third_level_index = if self.append_or_prepend.is_append() {
vec![o, index].into()
} else {
vec![index, o].into()
};
self.indexing_code
.push(IndexingLine::DynamicIndexedChoice(third_level_index));
}
IndexingCodePtr::External(o) => {
*l = IndexingCodePtr::Internal(indexing_code_len - self.offset);
let third_level_index = if self.append_or_prepend.is_append() {
vec![
IndexedChoiceInstruction::Try(o),
IndexedChoiceInstruction::Trust(index),
]
.into()
} else {
vec![
IndexedChoiceInstruction::Try(index),
IndexedChoiceInstruction::Trust(o),
]
.into()
};
self.indexing_code
.push(IndexingLine::IndexedChoice(third_level_index));
}
IndexingCodePtr::Internal(o) => {
self.offset += o;
self.extend_indexed_choice(index);
}
} }
} IndexingCodePtr::Fail => {
*l = IndexingCodePtr::External(index);
}
IndexingCodePtr::DynamicExternal(o) => {
*l = IndexingCodePtr::Internal(indexing_code_len - self.offset);
let third_level_index = if self.append_or_prepend.is_append() {
vec![o, index].into()
} else {
vec![index, o].into()
};
self.indexing_code
.push(IndexingLine::DynamicIndexedChoice(third_level_index));
}
IndexingCodePtr::External(o) => {
*l = IndexingCodePtr::Internal(indexing_code_len - self.offset);
let third_level_index = if self.append_or_prepend.is_append() {
vec![
IndexedChoiceInstruction::Try(o),
IndexedChoiceInstruction::Trust(index),
]
.into()
} else {
vec![
IndexedChoiceInstruction::Try(index),
IndexedChoiceInstruction::Trust(o),
]
.into()
};
self.indexing_code
.push(IndexingLine::IndexedChoice(third_level_index));
}
IndexingCodePtr::Internal(o) => {
self.offset += o;
self.extend_indexed_choice(index);
}
},
_ => { _ => {
unreachable!() unreachable!()
} }
@@ -676,20 +670,18 @@ pub(crate) fn remove_constant_indices(
let iter = once(&constant).chain(overlapping_constants.iter()); let iter = once(&constant).chain(overlapping_constants.iter());
match &mut indexing_code[index] { match &mut indexing_code[index] {
IndexingLine::Indexing(IndexingInstruction::SwitchOnTerm(_, _, c, ..)) => { IndexingLine::Indexing(IndexingInstruction::SwitchOnTerm(_, _, c, ..)) => match *c {
match *c { IndexingCodePtr::DynamicExternal(_) | IndexingCodePtr::External(_) => {
IndexingCodePtr::DynamicExternal(_) | IndexingCodePtr::External(_) => { *c = IndexingCodePtr::Fail;
*c = IndexingCodePtr::Fail; return;
return;
}
IndexingCodePtr::Internal(o) => {
index += o;
}
IndexingCodePtr::Fail => {
return;
}
} }
} IndexingCodePtr::Internal(o) => {
index += o;
}
IndexingCodePtr::Fail => {
return;
}
},
_ => { _ => {
unreachable!() unreachable!()
} }
@@ -700,9 +692,7 @@ pub(crate) fn remove_constant_indices(
for constant in iter.map(|l| HeapCellValue::from(*l)) { for constant in iter.map(|l| HeapCellValue::from(*l)) {
loop { loop {
match &mut indexing_code[index] { match &mut indexing_code[index] {
IndexingLine::Indexing(IndexingInstruction::SwitchOnConstant( IndexingLine::Indexing(IndexingInstruction::SwitchOnConstant(constants)) => {
constants,
)) => {
constants_index = index; constants_index = index;
match constants.get(&constant).cloned() { match constants.get(&constant).cloned() {
@@ -819,20 +809,18 @@ pub(crate) fn remove_structure_index(
let mut index = 0; let mut index = 0;
match &mut indexing_code[index] { match &mut indexing_code[index] {
IndexingLine::Indexing(IndexingInstruction::SwitchOnTerm(_, _, _, _, s)) => { IndexingLine::Indexing(IndexingInstruction::SwitchOnTerm(_, _, _, _, s)) => match *s {
match *s { IndexingCodePtr::DynamicExternal(_) | IndexingCodePtr::External(_) => {
IndexingCodePtr::DynamicExternal(_) | IndexingCodePtr::External(_) => { *s = IndexingCodePtr::Fail;
*s = IndexingCodePtr::Fail; return;
return;
}
IndexingCodePtr::Internal(o) => {
index += o;
}
IndexingCodePtr::Fail => {
return;
}
} }
} IndexingCodePtr::Internal(o) => {
index += o;
}
IndexingCodePtr::Fail => {
return;
}
},
_ => { _ => {
unreachable!() unreachable!()
} }
@@ -932,13 +920,7 @@ pub(crate) fn remove_structure_index(
if structures.is_empty() => if structures.is_empty() =>
{ {
match &mut indexing_code[0] { match &mut indexing_code[0] {
IndexingLine::Indexing(IndexingInstruction::SwitchOnTerm( IndexingLine::Indexing(IndexingInstruction::SwitchOnTerm(_, _, _, _, s)) => {
_,
_,
_,
_,
s,
)) => {
*s = IndexingCodePtr::Fail; *s = IndexingCodePtr::Fail;
} }
_ => { _ => {
@@ -954,20 +936,18 @@ pub(crate) fn remove_list_index(indexing_code: &mut [IndexingLine], offset: usiz
let mut index = 0; let mut index = 0;
match &mut indexing_code[index] { match &mut indexing_code[index] {
IndexingLine::Indexing(IndexingInstruction::SwitchOnTerm(_, _, _, l, _)) => { IndexingLine::Indexing(IndexingInstruction::SwitchOnTerm(_, _, _, l, _)) => match *l {
match *l { IndexingCodePtr::DynamicExternal(_) | IndexingCodePtr::External(_) => {
IndexingCodePtr::DynamicExternal(_) | IndexingCodePtr::External(_) => { *l = IndexingCodePtr::Fail;
*l = IndexingCodePtr::Fail; return;
return;
}
IndexingCodePtr::Internal(o) => {
index += o;
}
IndexingCodePtr::Fail => {
return;
}
} }
} IndexingCodePtr::Internal(o) => {
index += o;
}
IndexingCodePtr::Fail => {
return;
}
},
_ => { _ => {
unreachable!() unreachable!()
} }

View File

@@ -90,7 +90,7 @@ impl<'a> QueryIterator<'a> {
| Term::CompleteString(..) => { | Term::CompleteString(..) => {
return QueryIterator { return QueryIterator {
state_stack: vec![], state_stack: vec![],
} };
} }
Term::Clause(r, name, terms) => TermIterState::Clause(Level::Root, 0, r, *name, terms), Term::Clause(r, name, terms) => TermIterState::Clause(Level::Root, 0, r, *name, terms),
Term::Var(cell, var_ptr) => TermIterState::Var(Level::Root, cell, var_ptr.clone()), Term::Var(cell, var_ptr) => TermIterState::Var(Level::Root, cell, var_ptr.clone()),
@@ -143,7 +143,7 @@ impl<'a> Iterator for QueryIterator<'a> {
return match lvl { return match lvl {
Level::Root => None, Level::Root => None,
lvl => Some(TermRef::Clause(lvl, cell, name, child_terms)), lvl => Some(TermRef::Clause(lvl, cell, name, child_terms)),
} };
} }
}; };
} else { } else {
@@ -293,7 +293,7 @@ impl<'a> Iterator for FactIterator<'a> {
return Some(TermRef::CompleteString(lvl, cell, atom)); return Some(TermRef::CompleteString(lvl, cell, atom));
} }
TermIterState::Literal(lvl, cell, constant) => { TermIterState::Literal(lvl, cell, constant) => {
return Some(TermRef::Literal(lvl, cell, constant)) return Some(TermRef::Literal(lvl, cell, constant));
} }
TermIterState::Var(lvl, cell, var_ptr) => { TermIterState::Var(lvl, cell, var_ptr) => {
return Some(TermRef::Var(lvl, cell, var_ptr)); return Some(TermRef::Var(lvl, cell, var_ptr));

View File

@@ -43,9 +43,9 @@ mod targets;
pub(crate) mod types; pub(crate) mod types;
// Re-exports // Re-exports
pub use machine::Machine;
pub use machine::config::*; pub use machine::config::*;
pub use machine::lib_machine::*; pub use machine::lib_machine::*;
pub use machine::Machine;
#[cfg(target_arch = "wasm32")] #[cfg(target_arch = "wasm32")]
pub mod wasm; pub mod wasm;

View File

@@ -1,6 +1,6 @@
use dashu::base::{Abs, Gcd, Signed, UnsignedAbs}; use dashu::base::{Abs, Gcd, Signed, UnsignedAbs};
use dashu::integer::fast_div::ConstDivisor;
use dashu::integer::IBig; use dashu::integer::IBig;
use dashu::integer::fast_div::ConstDivisor;
use divrem::*; use divrem::*;
use num_order::NumOrd; use num_order::NumOrd;

View File

@@ -564,9 +564,7 @@ fn thread_choice_instr_at_to(
) { ) {
loop { loop {
match &mut code[instr_loc] { match &mut code[instr_loc] {
Instruction::TryMeElse(o) | Instruction::RetryMeElse(o) Instruction::TryMeElse(o) | Instruction::RetryMeElse(o) if target_loc >= instr_loc => {
if target_loc >= instr_loc =>
{
retraction_info.push_record(RetractionRecord::ReplacedChoiceOffset(instr_loc, *o)); retraction_info.push_record(RetractionRecord::ReplacedChoiceOffset(instr_loc, *o));
*o = target_loc - instr_loc; *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] { match &mut self.wam_prelude.code[clause_loc] {
Instruction::DynamicElse(_, d, _) Instruction::DynamicElse(_, d, _) | Instruction::DynamicInternalElse(_, d, _) => {
| Instruction::DynamicInternalElse(_, d, _) => {
*d = Death::Finite(LS::machine_st(&mut self.payload).global_clock); *d = Death::Finite(LS::machine_st(&mut self.payload).global_clock);
} }
_ => unreachable!(), _ => unreachable!(),

View File

@@ -1,14 +1,14 @@
use std::borrow::Cow; use std::borrow::Cow;
use std::io::Write; 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 crate::Machine;
use super::{ use super::{
bootstrapping_compile, current_dir, import_builtin_impls, libraries, load_module, Arena, Atom, Arena, Atom, Callback, CompilationTarget, IndexStore, ListingSource, MachineArgs, MachineState,
Callback, CompilationTarget, IndexStore, ListingSource, MachineArgs, MachineState, Stream, Stream, bootstrapping_compile, current_dir, import_builtin_impls, libraries, load_module,
}; };
#[derive(Default)] #[derive(Default)]

View File

@@ -1366,9 +1366,7 @@ impl Machine {
let indexed_choice_instrs = match &self.code[p] { let indexed_choice_instrs = match &self.code[p] {
Instruction::IndexingCode(indexing_code) => match &indexing_code[oi as usize] { Instruction::IndexingCode(indexing_code) => match &indexing_code[oi as usize] {
IndexingLine::DynamicIndexedChoice(indexed_choice_instrs) => { IndexingLine::DynamicIndexedChoice(indexed_choice_instrs) => indexed_choice_instrs,
indexed_choice_instrs
}
_ => unreachable!(), _ => unreachable!(),
}, },
_ => unreachable!(), _ => unreachable!(),

View File

@@ -57,38 +57,41 @@ struct InnerHeap {
} }
impl InnerHeap { impl InnerHeap {
unsafe fn grow(&mut self) -> bool { unsafe { unsafe fn grow(&mut self) -> bool {
let new_cap = if self.byte_cap == 0 { unsafe {
256 * 256 * 8 let new_cap = if self.byte_cap == 0 {
} else { 256 * 256 * 8
2 * self.byte_cap } else {
}; 2 * self.byte_cap
};
let new_layout = let new_layout =
alloc::Layout::from_size_align(new_cap, size_of::<HeapCellValue>()).unwrap(); alloc::Layout::from_size_align(new_cap, size_of::<HeapCellValue>()).unwrap();
assert!( assert!(
new_layout.size() <= isize::MAX as usize, new_layout.size() <= isize::MAX as usize,
"Allocation too large. We should probably GC (TODO)" "Allocation too large. We should probably GC (TODO)"
); );
let new_ptr = if self.byte_cap == 0 { let new_ptr = if self.byte_cap == 0 {
alloc::alloc(new_layout) alloc::alloc(new_layout)
} else { } else {
let old_layout = let old_layout =
alloc::Layout::from_size_align(self.byte_cap, size_of::<HeapCellValue>()).unwrap(); alloc::Layout::from_size_align(self.byte_cap, size_of::<HeapCellValue>())
alloc::realloc(self.ptr, old_layout, new_layout.size()) .unwrap();
}; alloc::realloc(self.ptr, old_layout, new_layout.size())
};
if !new_ptr.is_null() { if !new_ptr.is_null() {
self.ptr = new_ptr; self.ptr = new_ptr;
self.byte_cap = new_cap; self.byte_cap = new_cap;
true true
} else { } else {
false false
}
} }
}} }
} }
unsafe impl Send for Heap {} unsafe impl Send for Heap {}
@@ -101,48 +104,52 @@ pub struct HeapStringScan<'a> {
} }
// The heap_slice should be inside the heap // The heap_slice should be inside the heap
unsafe fn scan_slice_to_str(heap_slice: &[u8]) -> HeapStringScan<'_> { unsafe { unsafe fn scan_slice_to_str(heap_slice: &[u8]) -> HeapStringScan<'_> {
let string_len = heap_slice unsafe {
.iter() let string_len = heap_slice
.position(|b| *b == 0u8) .iter()
.unwrap_or(heap_slice.len()); .position(|b| *b == 0u8)
let zero_byte_addr = heap_slice.as_ptr().add(string_len); .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 sentinel_len = pstr_sentinel_length(zero_byte_addr.addr());
let tail_idx = cell_index!( let tail_idx = cell_index!(
(string_len + sentinel_len).next_multiple_of(ALIGN) (string_len + sentinel_len).next_multiple_of(ALIGN)
+ if sentinel_len <= 1 { heap_index!(1) } else { 0 } + if sentinel_len <= 1 { heap_index!(1) } else { 0 }
); );
let str_slice = &heap_slice[..string_len]; let str_slice = &heap_slice[..string_len];
HeapStringScan { HeapStringScan {
string: std::str::from_utf8_unchecked(str_slice), string: std::str::from_utf8_unchecked(str_slice),
tail_idx, tail_idx,
}
} }
}} }
// Same as scan_slice_to_str but assumes that the slice is from the start of a string. // 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. // Can be used on strings out of the heap.
unsafe fn scan_slice_to_str_from_start(heap_slice: &[u8]) -> HeapStringScan<'_> { unsafe { unsafe fn scan_slice_to_str_from_start(heap_slice: &[u8]) -> HeapStringScan<'_> {
let string_len = heap_slice unsafe {
.iter() let string_len = heap_slice
.position(|b| *b == 0u8) .iter()
.unwrap_or(heap_slice.len()); .position(|b| *b == 0u8)
.unwrap_or(heap_slice.len());
let sentinel_len = pstr_sentinel_length(string_len); let sentinel_len = pstr_sentinel_length(string_len);
let tail_idx = cell_index!( let tail_idx = cell_index!(
(string_len + sentinel_len).next_multiple_of(ALIGN) (string_len + sentinel_len).next_multiple_of(ALIGN)
+ if sentinel_len <= 1 { heap_index!(1) } else { 0 } + if sentinel_len <= 1 { heap_index!(1) } else { 0 }
); );
let str_slice = &heap_slice[..string_len]; let str_slice = &heap_slice[..string_len];
HeapStringScan { HeapStringScan {
string: std::str::from_utf8_unchecked(str_slice), string: std::str::from_utf8_unchecked(str_slice),
tail_idx, tail_idx,
}
} }
}} }
#[derive(Debug, Clone, Copy)] #[derive(Debug, Clone, Copy)]
pub(crate) enum PStrContinuable { 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; let res = chunk_len.next_multiple_of(ALIGN) - chunk_len;
// No bytes available in last chunk // No bytes available in last chunk
if res == 0 { if res == 0 { ALIGN } else { res }
ALIGN
} else {
res
}
} }
#[must_use] #[must_use]
@@ -585,9 +588,9 @@ impl Heap {
} }
#[inline(always)] #[inline(always)]
unsafe fn grow(&mut self) -> bool { unsafe { unsafe fn grow(&mut self) -> bool {
self.inner.grow() unsafe { self.inner.grow() }
}} }
#[inline] #[inline]
fn resource_error_offset(&self) -> usize { fn resource_error_offset(&self) -> usize {

View File

@@ -3,23 +3,23 @@ use std::collections::BTreeMap;
use std::rc::Rc; use std::rc::Rc;
use crate::atom_table; 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::heap::AllocError;
use crate::machine::machine_indices::VarKey; use crate::machine::machine_indices::VarKey;
use crate::machine::mock_wam::CompositeOpDir; use crate::machine::mock_wam::CompositeOpDir;
use crate::machine::{ 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::offset_table::*;
use crate::parser::ast::{Var, VarPtr}; use crate::parser::ast::{Var, VarPtr};
use crate::parser::parser::{Parser, Tokens}; 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 crate::types::UntypedArenaPtr;
use dashu::{Integer, Rational}; use dashu::{Integer, Rational};
use indexmap::IndexMap; use indexmap::IndexMap;
use super::{streams::Stream, Atom, AtomCell, HeapCellValue, HeapCellValueTag, Machine}; use super::{Atom, AtomCell, HeapCellValue, HeapCellValueTag, Machine, streams::Stream};
#[cfg(test)] #[cfg(test)]
mod tests; mod tests;

View File

@@ -819,11 +819,8 @@ impl<'a, LS: LoadState<'a>> Loader<'a, LS> {
if let Instruction::IndexingCode(ref mut indexing_code) = if let Instruction::IndexingCode(ref mut indexing_code) =
self.wam_prelude.code[index_loc] self.wam_prelude.code[index_loc]
{ {
if let IndexingLine::Indexing(IndexingInstruction::SwitchOnTerm( if let IndexingLine::Indexing(IndexingInstruction::SwitchOnTerm(_, v, ..)) =
_, &mut indexing_code[0]
v,
..,
)) = &mut indexing_code[0]
{ {
*v = old_v; *v = old_v;
} }
@@ -1364,14 +1361,12 @@ impl<'a> MachinePreludeView<'a> {
) -> CompositeOpDir<'_, '_> { ) -> CompositeOpDir<'_, '_> {
match compilation_target { match compilation_target {
CompilationTarget::User => CompositeOpDir::new(&self.indices.op_dir, None), CompilationTarget::User => CompositeOpDir::new(&self.indices.op_dir, None),
CompilationTarget::Module(module_name) => { CompilationTarget::Module(module_name) => match self.indices.modules.get(module_name) {
match self.indices.modules.get(module_name) { Some(module) => CompositeOpDir::new(&self.indices.op_dir, Some(&module.op_dir)),
Some(module) => CompositeOpDir::new(&self.indices.op_dir, Some(&module.op_dir)), None => {
None => { unreachable!()
unreachable!()
}
} }
} },
} }
} }
} }
@@ -1504,9 +1499,10 @@ impl Machine {
} }
pub(crate) fn load_compiled_library(&mut self) -> CallResult { pub(crate) fn load_compiled_library(&mut self) -> CallResult {
let library = cell_as_atom!(self let library = cell_as_atom!(
.machine_st self.machine_st
.store(self.machine_st.deref(self.machine_st.registers[1]))); .store(self.machine_st.deref(self.machine_st.registers[1]))
);
if let Some(module) = self.indices.modules.get(&library) { if let Some(module) = self.indices.modules.get(&library) {
if let ListingSource::DynamicallyGenerated = module.listing_src { if let ListingSource::DynamicallyGenerated = module.listing_src {
@@ -1537,9 +1533,10 @@ impl Machine {
} }
pub(crate) fn declare_module(&mut self) -> CallResult { pub(crate) fn declare_module(&mut self) -> CallResult {
let module_name = cell_as_atom!(self let module_name = cell_as_atom!(
.machine_st self.machine_st
.store(self.machine_st.deref(self.machine_st.registers[1]))); .store(self.machine_st.deref(self.machine_st.registers[1]))
);
let mut loader = self.loader_from_heap_evacuable(temp_v!(3)); 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 { pub(crate) fn add_goal_expansion_clause(&mut self) -> CallResult {
let target_module_name = cell_as_atom!(self let target_module_name = cell_as_atom!(
.machine_st self.machine_st
.store(self.machine_st.deref(self.machine_st.registers[1]))); .store(self.machine_st.deref(self.machine_st.registers[1]))
);
let mut loader = self.loader_from_heap_evacuable(temp_v!(3)); let mut loader = self.loader_from_heap_evacuable(temp_v!(3));
@@ -1744,9 +1742,10 @@ impl Machine {
&mut self, &mut self,
r: RegType, r: RegType,
) -> Loader<'_, LiveLoadAndMachineState<'_>> { ) -> Loader<'_, LiveLoadAndMachineState<'_>> {
let mut load_state = cell_as_load_state_payload!(self let mut load_state = cell_as_load_state_payload!(
.machine_st self.machine_st
.store(self.machine_st.deref(self.machine_st[r]))); .store(self.machine_st.deref(self.machine_st[r]))
);
load_state.set_tag(ArenaHeaderTag::LiveLoadState); load_state.set_tag(ArenaHeaderTag::LiveLoadState);
@@ -2098,9 +2097,10 @@ impl Machine {
} }
pub(crate) fn abolish_clause(&mut self) -> CallResult { pub(crate) fn abolish_clause(&mut self) -> CallResult {
let module_name = cell_as_atom!(self let module_name = cell_as_atom!(
.machine_st self.machine_st
.store(self.machine_st.deref(self.machine_st.registers[1]))); .store(self.machine_st.deref(self.machine_st.registers[1]))
);
let key = self let key = self
.machine_st .machine_st
@@ -2214,9 +2214,10 @@ impl Machine {
_ => unreachable!(), _ => unreachable!(),
}; };
let module_name = cell_as_atom!(self let module_name = cell_as_atom!(
.machine_st self.machine_st
.store(self.machine_st.deref(self.machine_st.registers[4]))); .store(self.machine_st.deref(self.machine_st.registers[4]))
);
let compilation_target = match module_name { let compilation_target = match module_name {
atom!("user") => CompilationTarget::User, atom!("user") => CompilationTarget::User,
@@ -2269,9 +2270,10 @@ impl Machine {
} }
pub(crate) fn is_consistent_with_term_queue(&mut self) -> CallResult { pub(crate) fn is_consistent_with_term_queue(&mut self) -> CallResult {
let module_name = cell_as_atom!(self let module_name = cell_as_atom!(
.machine_st self.machine_st
.store(self.machine_st.deref(self.machine_st.registers[1]))); .store(self.machine_st.deref(self.machine_st.registers[1]))
);
let key = self let key = self
.machine_st .machine_st
@@ -2309,9 +2311,10 @@ impl Machine {
} }
pub(crate) fn remove_module_exports(&mut self) -> CallResult { pub(crate) fn remove_module_exports(&mut self) -> CallResult {
let module_name = cell_as_atom!(self let module_name = cell_as_atom!(
.machine_st self.machine_st
.store(self.machine_st.deref(self.machine_st.registers[1]))); .store(self.machine_st.deref(self.machine_st.registers[1]))
);
let mut loader = self.loader_from_heap_evacuable(temp_v!(2)); 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) { pub(crate) fn meta_predicate_property(&mut self) {
let module_name = cell_as_atom!(self let module_name = cell_as_atom!(
.machine_st self.machine_st
.store(self.machine_st.deref(self.machine_st.registers[1]))); .store(self.machine_st.deref(self.machine_st.registers[1]))
);
let (predicate_name, arity) = self let (predicate_name, arity) = self
.machine_st .machine_st
@@ -2401,9 +2405,10 @@ impl Machine {
} }
pub(crate) fn dynamic_property(&mut self) { pub(crate) fn dynamic_property(&mut self) {
let module_name = cell_as_atom!(self let module_name = cell_as_atom!(
.machine_st self.machine_st
.store(self.machine_st.deref(self.machine_st.registers[1]))); .store(self.machine_st.deref(self.machine_st.registers[1]))
);
let key = self let key = self
.machine_st .machine_st
@@ -2428,9 +2433,10 @@ impl Machine {
} }
pub(crate) fn multifile_property(&mut self) { pub(crate) fn multifile_property(&mut self) {
let module_name = cell_as_atom!(self let module_name = cell_as_atom!(
.machine_st self.machine_st
.store(self.machine_st.deref(self.machine_st.registers[1]))); .store(self.machine_st.deref(self.machine_st.registers[1]))
);
let key = self let key = self
.machine_st .machine_st
@@ -2455,9 +2461,10 @@ impl Machine {
} }
pub(crate) fn discontiguous_property(&mut self) { pub(crate) fn discontiguous_property(&mut self) {
let module_name = cell_as_atom!(self let module_name = cell_as_atom!(
.machine_st self.machine_st
.store(self.machine_st.deref(self.machine_st.registers[1]))); .store(self.machine_st.deref(self.machine_st.registers[1]))
);
let key = self let key = self
.machine_st .machine_st

View File

@@ -777,7 +777,9 @@ impl MachineState {
// throw an error pre-allocated in the heap // throw an error pre-allocated in the heap
pub(super) fn throw_resource_error(&mut self, err: AllocError) { pub(super) fn throw_resource_error(&mut self, err: AllocError) {
if self.throwing_resource_error { 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; self.throwing_resource_error = true;

View File

@@ -2,17 +2,17 @@ use crate::parser::ast::*;
use crate::atom_table::*; use crate::atom_table::*;
use crate::forms::*; use crate::forms::*;
use crate::machine::ClauseType;
use crate::machine::MachineStubGen;
use crate::machine::loader::*; use crate::machine::loader::*;
use crate::machine::machine_state::*; use crate::machine::machine_state::*;
use crate::machine::streams::{Stream, StreamOptions}; use crate::machine::streams::{Stream, StreamOptions};
use crate::machine::ClauseType;
use crate::machine::MachineStubGen;
use crate::offset_table::*; use crate::offset_table::*;
use fxhash::FxBuildHasher; use fxhash::FxBuildHasher;
use indexmap::{IndexMap, IndexSet}; use indexmap::{IndexMap, IndexSet};
use modular_bitfield::specifiers::*; use modular_bitfield::specifiers::*;
use modular_bitfield::{bitfield, Specifier}; use modular_bitfield::{Specifier, bitfield};
use std::cmp::Ordering; use std::cmp::Ordering;
use std::collections::BTreeSet; use std::collections::BTreeSet;

View File

@@ -3,6 +3,7 @@ use crate::atom_table::*;
use crate::forms::*; use crate::forms::*;
use crate::heap_iter::*; use crate::heap_iter::*;
use crate::heap_print::*; use crate::heap_print::*;
use crate::machine::Machine;
use crate::machine::attributed_variables::*; use crate::machine::attributed_variables::*;
use crate::machine::copier::*; use crate::machine::copier::*;
use crate::machine::heap::AllocError; use crate::machine::heap::AllocError;
@@ -11,7 +12,6 @@ use crate::machine::machine_errors::*;
use crate::machine::machine_indices::*; use crate::machine::machine_indices::*;
use crate::machine::stack::*; use crate::machine::stack::*;
use crate::machine::streams::*; use crate::machine::streams::*;
use crate::machine::Machine;
use crate::parser::ast::*; use crate::parser::ast::*;
use crate::read::TermWriteResult; use crate::read::TermWriteResult;
use crate::types::*; use crate::types::*;

View File

@@ -61,8 +61,8 @@ use std::env;
use std::io::Read; use std::io::Read;
use std::path::PathBuf; use std::path::PathBuf;
use std::process::ExitCode; use std::process::ExitCode;
use std::sync::atomic::AtomicBool;
use std::sync::OnceLock; use std::sync::OnceLock;
use std::sync::atomic::AtomicBool;
pub static INTERRUPT: AtomicBool = AtomicBool::new(false); pub static INTERRUPT: AtomicBool = AtomicBool::new(false);

View File

@@ -37,7 +37,7 @@ fn setup_op_decl(mut terms: Vec<Term>) -> Result<OpDecl, CompilationError> {
other => { other => {
return Err(CompilationError::InvalidDirective( return Err(CompilationError::InvalidDirective(
DirectiveError::InvalidOpDeclSpecDomain(other), DirectiveError::InvalidOpDeclSpecDomain(other),
)) ));
} }
}; };

View File

@@ -175,15 +175,17 @@ impl Stack {
} }
#[inline(always)] #[inline(always)]
unsafe fn alloc(&mut self, frame_size: usize) -> Result<NonNull<u8>, AllocError> { unsafe { unsafe fn alloc(&mut self, frame_size: usize) -> Result<NonNull<u8>, AllocError> {
loop { unsafe {
let ptr = self.buf.alloc(frame_size); loop {
if let Some(ptr) = NonNull::new(ptr) { let ptr = self.buf.alloc(frame_size);
return Ok(ptr); 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> { pub(crate) fn allocate_and_frame(&mut self, num_cells: usize) -> Result<usize, AllocError> {
let frame_size = AndFrame::size_of(num_cells); let frame_size = AndFrame::size_of(num_cells);

View File

@@ -15,7 +15,7 @@ use crate::types::*;
pub use modular_bitfield::prelude::*; pub use modular_bitfield::prelude::*;
#[cfg(feature = "http")] #[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::cmp::Ordering;
use std::error::Error; use std::error::Error;
use std::fmt; use std::fmt;
@@ -2195,8 +2195,8 @@ mod test {
use crate::*; use crate::*;
use std::{cell::RefCell, io::Read, io::Write, rc::Rc}; use std::{cell::RefCell, io::Read, io::Write, rc::Rc};
use crate::machine::config::*;
use crate::LeafAnswer; use crate::LeafAnswer;
use crate::machine::config::*;
use super::{Stream, StreamOptions}; use super::{Stream, StreamOptions};

View File

@@ -24,7 +24,7 @@ use crate::machine::machine_state::*;
use crate::machine::partial_string::*; use crate::machine::partial_string::*;
use crate::machine::stack::*; use crate::machine::stack::*;
use crate::machine::streams::*; 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::ast::*;
use crate::parser::char_reader::*; use crate::parser::char_reader::*;
use crate::parser::dashu::Integer; use crate::parser::dashu::Integer;
@@ -48,7 +48,7 @@ use std::ffi::CString;
use std::fs; use std::fs;
use std::hash::{BuildHasher, BuildHasherDefault}; use std::hash::{BuildHasher, BuildHasherDefault};
use std::io::{ErrorKind, Read, Write}; use std::io::{ErrorKind, Read, Write};
use std::iter::{once, FromIterator}; use std::iter::{FromIterator, once};
use std::mem; use std::mem;
#[cfg(feature = "http")] #[cfg(feature = "http")]
use std::net::{SocketAddr, ToSocketAddrs}; use std::net::{SocketAddr, ToSocketAddrs};
@@ -63,13 +63,13 @@ use std::sync::LazyLock;
use std::sync::{Arc, Condvar, Mutex}; use std::sync::{Arc, Condvar, Mutex};
use tokio::sync::Notify; use tokio::sync::Notify;
use chrono::{offset::Local, DateTime}; use chrono::{DateTime, offset::Local};
#[cfg(not(target_arch = "wasm32"))] #[cfg(not(target_arch = "wasm32"))]
use cpu_time::ProcessTime; use cpu_time::ProcessTime;
use std::time::{Duration, SystemTime}; use std::time::{Duration, SystemTime};
#[cfg(feature = "repl")] #[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}; use blake2::{Blake2b512, Blake2s256};

View File

@@ -1,5 +1,5 @@
use crate::machine::Number;
use crate::Machine; use crate::Machine;
use crate::machine::Number;
use ordered_float::OrderedFloat; use ordered_float::OrderedFloat;
use puruspe::beta::*; use puruspe::beta::*;
use puruspe::error::*; use puruspe::error::*;

View File

@@ -1,6 +1,6 @@
use crate::arena::*; use crate::arena::*;
use crate::forms::*; 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::machine_state::*;
use crate::machine::*; use crate::machine::*;
use crate::offset_table::*; use crate::offset_table::*;

View File

@@ -138,9 +138,7 @@ macro_rules! typed_arena_ptr_as_cell {
} }
macro_rules! raw_ptr_as_cell { macro_rules! raw_ptr_as_cell {
($ptr:expr) => {{ ($ptr:expr) => {{ HeapCellValue::from_arena_header_ptr($ptr) }};
HeapCellValue::from_arena_header_ptr($ptr)
}};
} }
macro_rules! untyped_arena_ptr_as_cell { macro_rules! untyped_arena_ptr_as_cell {

View File

@@ -2,10 +2,10 @@ use std::cell::UnsafeCell;
use std::sync::Arc; use std::sync::Arc;
use std::{fmt, mem, ptr}; use std::{fmt, mem, ptr};
use arcu::Rcu;
use arcu::atomic::Arcu; use arcu::atomic::Arcu;
use arcu::epoch_counters::GlobalEpochCounterPool; use arcu::epoch_counters::GlobalEpochCounterPool;
use arcu::rcu_ref::RcuRef; use arcu::rcu_ref::RcuRef;
use arcu::Rcu;
use fxhash::FxBuildHasher; use fxhash::FxBuildHasher;
use indexmap::IndexMap; use indexmap::IndexMap;
use parking_lot::{Mutex, RwLock}; use parking_lot::{Mutex, RwLock};
@@ -211,7 +211,7 @@ impl<T: RawBlockTraits> SerialOffsetTable<T> {
}) })
} }
unsafe fn build_with(&mut self, value: T) -> usize { unsafe { unsafe fn build_with(&mut self, value: T) -> usize {
let mut ptr; let mut ptr;
loop { loop {
@@ -228,17 +228,17 @@ impl<T: RawBlockTraits> SerialOffsetTable<T> {
ptr::write(ptr as *mut T, value); ptr::write(ptr as *mut T, value);
// SAFETY: `ptr` was obtained from `self.block.alloc()` // SAFETY: `ptr` was obtained from `self.block.alloc()`
self.block.get_offset(ptr) self.block.get_offset(ptr)
}} }
#[inline] #[inline]
unsafe fn lookup(&self, offset: usize) -> &T { unsafe { unsafe fn lookup(&self, offset: usize) -> &T {
&*self.block.get_unchecked(offset).cast::<T>() &*self.block.get_unchecked(offset).cast::<T>()
}} }
#[inline] #[inline]
unsafe fn lookup_mut(&mut self, offset: usize) -> &mut T { unsafe { unsafe fn lookup_mut(&mut self, offset: usize) -> &mut T {
&mut *self.block.get_unchecked(offset).cast::<T>().cast_mut() &mut *self.block.get_unchecked(offset).cast::<T>().cast_mut()
}} }
#[allow(clippy::wrong_self_convention)] #[allow(clippy::wrong_self_convention)]
fn to_concurrent(&mut self) -> ConcurrentOffsetTable<T> fn to_concurrent(&mut self) -> ConcurrentOffsetTable<T>

View File

@@ -362,11 +362,7 @@ impl OpDesc {
#[inline] #[inline]
pub fn arity(self) -> usize { pub fn arity(self) -> usize {
if !self.get_spec().is_infix() { if !self.get_spec().is_infix() { 1 } else { 2 }
1
} else {
2
}
} }
} }

View File

@@ -85,7 +85,7 @@ macro_rules! try_nt {
Ok(NumberToken::Partial($token)) Ok(NumberToken::Partial($token))
} else { } else {
Err(e) Err(e)
} };
} }
} }
}}; }};
@@ -771,7 +771,7 @@ impl<'a, R: CharRead> Lexer<'a, R> {
Err(_) => { Err(_) => {
return self return self
.vacate_with_float(token) .vacate_with_float(token)
.map(|(offset, fl)| NumberToken::Float(offset, fl)) .map(|(offset, fl)| NumberToken::Float(offset, fl));
} }
Ok(c) => c, Ok(c) => c,
}; };

View File

@@ -102,13 +102,7 @@ pub(crate) fn set_prompt(value: bool) {
#[cfg(feature = "repl")] #[cfg(feature = "repl")]
#[inline] #[inline]
fn get_prompt() -> &'static str { fn get_prompt() -> &'static str {
unsafe { unsafe { if PROMPT { "?- " } else { "" } }
if PROMPT {
"?- "
} else {
""
}
}
} }
thread_local! { thread_local! {

View File

@@ -1,4 +1,4 @@
use crossterm::event::{read, Event, KeyEventKind}; use crossterm::event::{Event, KeyEventKind, read};
pub(crate) use crossterm::event::{KeyCode, KeyEvent, KeyModifiers}; pub(crate) use crossterm::event::{KeyCode, KeyEvent, KeyModifiers};
use crossterm::terminal::{disable_raw_mode, enable_raw_mode}; use crossterm::terminal::{disable_raw_mode, enable_raw_mode};
use crossterm::tty::IsTty; use crossterm::tty::IsTty;

View File

@@ -761,9 +761,9 @@ impl UntypedArenaPtr {
pub unsafe fn as_typed_ptr<T: ?Sized + ArenaAllocated>(self) -> TypedArenaPtr<T> pub unsafe fn as_typed_ptr<T: ?Sized + ArenaAllocated>(self) -> TypedArenaPtr<T>
where where
T::Payload: Sized, T::Payload: Sized,
{ unsafe { {
T::typed_ptr(self) unsafe { T::typed_ptr(self) }
}} }
#[inline] #[inline]
pub fn get_mark_bit(self) -> bool { pub fn get_mark_bit(self) -> bool {

View File

@@ -106,9 +106,7 @@ impl VarAlloc {
pub(crate) fn set_register(&mut self, reg_num: usize) { pub(crate) fn set_register(&mut self, reg_num: usize) {
match self { match self {
VarAlloc::Perm(p, _) => *p = reg_num, VarAlloc::Perm(p, _) => *p = reg_num,
VarAlloc::Temp { VarAlloc::Temp { temp_reg, .. } => *temp_reg = reg_num,
temp_reg, ..
} => *temp_reg = reg_num,
}; };
} }
} }

View File

@@ -16,7 +16,10 @@ fn call_0() {
#[test] #[test]
#[cfg_attr(miri, ignore = "unsupported operation when isolation is enabled")] #[cfg_attr(miri, ignore = "unsupported operation when isolation is enabled")]
fn issue2588_load_html() { fn issue2588_load_html() {
load_module_test("tests-pl/issue2588.pl", "[element(html,[],[element(head,[],[element(title,[],[[H,e,l,l,o,!]])]),element(body,[],[])])]"); load_module_test(
"tests-pl/issue2588.pl",
"[element(html,[],[element(head,[],[element(title,[],[[H,e,l,l,o,!]])]),element(body,[],[])])]",
);
} }
// issue #2914 // issue #2914
@@ -38,7 +41,10 @@ fn issue3256_load_xml_returns_list() {
#[test] #[test]
#[cfg_attr(miri, ignore = "unsupported operation when isolation is enabled")] #[cfg_attr(miri, ignore = "unsupported operation when isolation is enabled")]
fn issue2949_load_html() { fn issue2949_load_html() {
load_module_test("tests-pl/issue2949.pl", "[doctype([h,t,m,l]),element(html,[],[element(head,[],[element(title,[],[[H,e,l,l,o,!]])]),element(body,[],[])])][doctype([h,t,m,l]),element(html,[],[element(head,[],[element(title,[],[[H,e,l,l,o,!]]),comment([ ,c,o,m,m,e,n,t, ])]),element(body,[],[])])][comment([]),element(html,[],[element(head,[],[]),element(body,[],[])])]"); load_module_test(
"tests-pl/issue2949.pl",
"[doctype([h,t,m,l]),element(html,[],[element(head,[],[element(title,[],[[H,e,l,l,o,!]])]),element(body,[],[])])][doctype([h,t,m,l]),element(html,[],[element(head,[],[element(title,[],[[H,e,l,l,o,!]]),comment([ ,c,o,m,m,e,n,t, ])]),element(body,[],[])])][comment([]),element(html,[],[element(head,[],[]),element(body,[],[])])]",
);
} }
// issue #2361 // issue #2361
@@ -168,7 +174,7 @@ async fn http_open_hanging() {
load_module_test_with_input( load_module_test_with_input(
"tests-pl/issue-http_open-hanging.pl", "tests-pl/issue-http_open-hanging.pl",
format!("PROLOG={:?}.", env!("CARGO_BIN_EXE_scryer-prolog")), format!("PROLOG={:?}.", env!("CARGO_BIN_EXE_scryer-prolog")),
"received response with status code:200\nreceived response with status code:200\nreceived response with status code:200\nreceived response with status code:200\nreceived response with status code:200\n" "received response with status code:200\nreceived response with status code:200\nreceived response with status code:200\nreceived response with status code:200\nreceived response with status code:200\n",
); );
} }