]> Repositorios git - scryer-prolog.git/commitdiff
fmt
authorMark <[email protected]>
Thu, 1 Feb 2024 16:31:04 +0000 (09:31 -0700)
committerMark <[email protected]>
Tue, 6 Feb 2024 01:34:57 +0000 (18:34 -0700)
build/instructions_template.rs
src/ffi.rs
src/machine/lib_machine.rs
src/machine/machine_errors.rs
src/parser/char_reader.rs
src/rcu.rs

index 1840341b1644ca2c1a07405b163d7c0ef98255e7..7e3f4f22d4751f25a22a3b30fa1bac9d0b9ec74b 100644 (file)
@@ -1155,27 +1155,27 @@ fn generate_instruction_preface() -> TokenStream {
         impl Instruction {
             #[inline]
             pub fn registers(&self) -> Vec<RegType> {
-                match self {
-                    &Instruction::GetConstant(_, _, r) => vec![r],
-                    &Instruction::GetList(_, r) => vec![r],
-                    &Instruction::GetPartialString(_, _, r, _) => vec![r],
-                    &Instruction::GetStructure(_, _, _, r) => vec![r],
-                    &Instruction::GetVariable(r, t) => vec![r, temp_v!(t)],
-                    &Instruction::GetValue(r, t) => vec![r, temp_v!(t)],
-                    &Instruction::UnifyLocalValue(r) => vec![r],
-                    &Instruction::UnifyVariable(r) => vec![r],
-                    &Instruction::PutConstant(_, _, r) => vec![r],
-                    &Instruction::PutList(_, r) => vec![r],
-                    &Instruction::PutPartialString(_, _, r, _) => vec![r],
-                    &Instruction::PutStructure(_, _, r) => vec![r],
-                    &Instruction::PutValue(r, t) => vec![r, temp_v!(t)],
-                    &Instruction::PutVariable(r, t) => vec![r, temp_v!(t)],
-                    &Instruction::SetLocalValue(r) => vec![r],
-                    &Instruction::SetVariable(r) => vec![r],
-                    &Instruction::SetValue(r) => vec![r],
-                    &Instruction::GetLevel(r) => vec![r],
-                    &Instruction::GetPrevLevel(r) => vec![r],
-                    &Instruction::GetCutPoint(r) => vec![r],
+                match *self {
+                    Instruction::GetConstant(_, _, r) => vec![r],
+                    Instruction::GetList(_, r) => vec![r],
+                    Instruction::GetPartialString(_, _, r, _) => vec![r],
+                    Instruction::GetStructure(_, _, _, r) => vec![r],
+                    Instruction::GetVariable(r, t) => vec![r, temp_v!(t)],
+                    Instruction::GetValue(r, t) => vec![r, temp_v!(t)],
+                    Instruction::UnifyLocalValue(r) => vec![r],
+                    Instruction::UnifyVariable(r) => vec![r],
+                    Instruction::PutConstant(_, _, r) => vec![r],
+                    Instruction::PutList(_, r) => vec![r],
+                    Instruction::PutPartialString(_, _, r, _) => vec![r],
+                    Instruction::PutStructure(_, _, r) => vec![r],
+                    Instruction::PutValue(r, t) => vec![r, temp_v!(t)],
+                    Instruction::PutVariable(r, t) => vec![r, temp_v!(t)],
+                    Instruction::SetLocalValue(r) => vec![r],
+                    Instruction::SetVariable(r) => vec![r],
+                    Instruction::SetValue(r) => vec![r],
+                    Instruction::GetLevel(r) => vec![r],
+                    Instruction::GetPrevLevel(r) => vec![r],
+                    Instruction::GetCutPoint(r) => vec![r],
                     _ => vec![],
                 }
             }
index 64879e58afc7c9a95365653f941b006af12a9b0d..a8ffd7442b7e2f769ce2fbb6aca17ac3d553c9ea 100644 (file)
@@ -27,6 +27,7 @@ use std::collections::HashMap;
 use std::convert::TryFrom;
 use std::error::Error;
 use std::ffi::{c_void, CString};
+use std::ptr::addr_of_mut;
 
 use libffi::low::type_tag::STRUCT;
 use libffi::low::{ffi_abi_FFI_DEFAULT_ABI, ffi_cif, ffi_type, prep_cif, types, CodePtr};
@@ -90,20 +91,20 @@ impl ForeignFunctionTable {
     fn map_type_ffi(&mut self, source: &Atom) -> *mut ffi_type {
         unsafe {
             match source {
-                atom!("sint64") => &mut types::sint64,
-                atom!("sint32") => &mut types::sint32,
-                atom!("sint16") => &mut types::sint16,
-                atom!("sint8") => &mut types::sint8,
-                atom!("uint64") => &mut types::uint64,
-                atom!("uint32") => &mut types::uint32,
-                atom!("uint16") => &mut types::uint16,
-                atom!("uint8") => &mut types::uint8,
-                atom!("bool") => &mut types::sint8,
-                atom!("void") => &mut types::void,
-                atom!("cstr") => &mut types::pointer,
-                atom!("ptr") => &mut types::pointer,
-                atom!("f32") => &mut types::float,
-                atom!("f64") => &mut types::double,
+                atom!("sint64") => addr_of_mut!(types::sint64),
+                atom!("sint32") => addr_of_mut!(types::sint32),
+                atom!("sint16") => addr_of_mut!(types::sint16),
+                atom!("sint8") => addr_of_mut!(types::sint8),
+                atom!("uint64") => addr_of_mut!(types::uint64),
+                atom!("uint32") => addr_of_mut!(types::uint32),
+                atom!("uint16") => addr_of_mut!(types::uint16),
+                atom!("uint8") => addr_of_mut!(types::uint8),
+                atom!("bool") => addr_of_mut!(types::sint8),
+                atom!("void") => addr_of_mut!(types::void),
+                atom!("cstr") => addr_of_mut!(types::pointer),
+                atom!("ptr") => addr_of_mut!(types::pointer),
+                atom!("f32") => addr_of_mut!(types::float),
+                atom!("f64") => addr_of_mut!(types::double),
                 struct_name => match self.structs.get_mut(&*struct_name.as_str()) {
                     Some(ref mut struct_type) => &mut struct_type.ffi_type,
                     None => unreachable!(),
@@ -161,7 +162,7 @@ impl ForeignFunctionTable {
     }
 
     fn build_pointer_args(
-        args: &mut Vec<Value>,
+        args: &mut [Value],
         type_args: &[*mut ffi_type],
         structs_table: &mut HashMap<String, StructImpl>,
     ) -> Result<PointerArgs, FFIError> {
index 9b218f51bd5ea2f13a4ccdebde50ca6dedefbd32..0bebfdc386184d83c55e52ee4c90f7270079bf60 100644 (file)
@@ -607,6 +607,6 @@ mod tests {
         assert_eq!(
             result,
             Err(String::from("error existence_error procedure / non_existent_predicate 3 / non_existent_predicate 3"))
-        );    
+        );
     }
 }
index c2cbb4053ad69f9e89165afc751c82c6585c19e9..5860fb5d75a9bba60f344f2d4c1ea9def8c3b491 100644 (file)
@@ -1022,19 +1022,6 @@ pub enum SessionError {
     QueryCannotBeDefinedAsFact,
 }
 
-#[derive(Debug)]
-pub(crate) enum EvalSession {
-    // EntrySuccess,
-    Error(SessionError),
-}
-
-impl From<SessionError> for EvalSession {
-    #[inline]
-    fn from(err: SessionError) -> Self {
-        EvalSession::Error(err)
-    }
-}
-
 impl From<std::io::Error> for SessionError {
     #[inline]
     fn from(err: std::io::Error) -> SessionError {
@@ -1055,10 +1042,3 @@ impl From<CompilationError> for SessionError {
         SessionError::CompilationError(err)
     }
 }
-
-impl From<ParserError> for EvalSession {
-    #[inline]
-    fn from(err: ParserError) -> Self {
-        EvalSession::from(SessionError::from(err))
-    }
-}
index aa1813a9d48cd8971d157d9aae5077a5fb781b8d..9febf0fddd1b373f87e369b0c3a8fbe646fb5ef5 100644 (file)
@@ -229,7 +229,7 @@ impl<R: Read> CharRead for CharReader<R> {
 
                     match self.inner.read(word_slice) {
                         Err(e) => return Some(Err(e)),
-                        Ok(nread) if nread == 0 => return Some(Err(bad_bytes_error(&self.buf))),
+                        Ok(0) => return Some(Err(bad_bytes_error(&self.buf))),
                         Ok(nread) => {
                             self.buf.extend_from_slice(&word_slice[0..nread]);
                         }
index 5c7c3201fba0822789ef2fef9d9225c7daae18c1..a3e8d2ab0ae11d8db13ed6a3f12e562ab09bff0e 100644 (file)
@@ -22,7 +22,7 @@ thread_local! {
     // odd value means the current thread is about to access the active_epoch of an Rcu
     // a thread has a single epoch counter for all Rcu it accesses,
     // as a thread can only access one Rcu at a time
-    static THREAD_EPOCH_COUNTER: OnceCell<Arc<AtomicU8>> = OnceCell::new();
+    static THREAD_EPOCH_COUNTER: OnceCell<Arc<AtomicU8>> = const { OnceCell::new() };
 }
 
 pub struct Rcu<T> {