Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
mthom committed Feb 6, 2024
1 parent cbb422f commit 614850a
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 59 deletions.
42 changes: 21 additions & 21 deletions build/instructions_template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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![],
}
}
Expand Down
31 changes: 16 additions & 15 deletions src/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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!(),
Expand Down Expand Up @@ -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> {
Expand Down
2 changes: 1 addition & 1 deletion src/machine/lib_machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,6 @@ mod tests {
assert_eq!(
result,
Err(String::from("error existence_error procedure / non_existent_predicate 3 / non_existent_predicate 3"))
);
);
}
}
20 changes: 0 additions & 20 deletions src/machine/machine_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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))
}
}
2 changes: 1 addition & 1 deletion src/parser/char_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
Expand Down
2 changes: 1 addition & 1 deletion src/rcu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down

0 comments on commit 614850a

Please sign in to comment.