fmt
This commit is contained in:
@@ -1155,27 +1155,27 @@ fn generate_instruction_preface() -> TokenStream {
|
|||||||
impl Instruction {
|
impl Instruction {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn registers(&self) -> Vec<RegType> {
|
pub fn registers(&self) -> Vec<RegType> {
|
||||||
match self {
|
match *self {
|
||||||
&Instruction::GetConstant(_, _, r) => vec![r],
|
Instruction::GetConstant(_, _, r) => vec![r],
|
||||||
&Instruction::GetList(_, r) => vec![r],
|
Instruction::GetList(_, r) => vec![r],
|
||||||
&Instruction::GetPartialString(_, _, r, _) => vec![r],
|
Instruction::GetPartialString(_, _, r, _) => vec![r],
|
||||||
&Instruction::GetStructure(_, _, _, r) => vec![r],
|
Instruction::GetStructure(_, _, _, r) => vec![r],
|
||||||
&Instruction::GetVariable(r, t) => vec![r, temp_v!(t)],
|
Instruction::GetVariable(r, t) => vec![r, temp_v!(t)],
|
||||||
&Instruction::GetValue(r, t) => vec![r, temp_v!(t)],
|
Instruction::GetValue(r, t) => vec![r, temp_v!(t)],
|
||||||
&Instruction::UnifyLocalValue(r) => vec![r],
|
Instruction::UnifyLocalValue(r) => vec![r],
|
||||||
&Instruction::UnifyVariable(r) => vec![r],
|
Instruction::UnifyVariable(r) => vec![r],
|
||||||
&Instruction::PutConstant(_, _, r) => vec![r],
|
Instruction::PutConstant(_, _, r) => vec![r],
|
||||||
&Instruction::PutList(_, r) => vec![r],
|
Instruction::PutList(_, r) => vec![r],
|
||||||
&Instruction::PutPartialString(_, _, r, _) => vec![r],
|
Instruction::PutPartialString(_, _, r, _) => vec![r],
|
||||||
&Instruction::PutStructure(_, _, r) => vec![r],
|
Instruction::PutStructure(_, _, r) => vec![r],
|
||||||
&Instruction::PutValue(r, t) => vec![r, temp_v!(t)],
|
Instruction::PutValue(r, t) => vec![r, temp_v!(t)],
|
||||||
&Instruction::PutVariable(r, t) => vec![r, temp_v!(t)],
|
Instruction::PutVariable(r, t) => vec![r, temp_v!(t)],
|
||||||
&Instruction::SetLocalValue(r) => vec![r],
|
Instruction::SetLocalValue(r) => vec![r],
|
||||||
&Instruction::SetVariable(r) => vec![r],
|
Instruction::SetVariable(r) => vec![r],
|
||||||
&Instruction::SetValue(r) => vec![r],
|
Instruction::SetValue(r) => vec![r],
|
||||||
&Instruction::GetLevel(r) => vec![r],
|
Instruction::GetLevel(r) => vec![r],
|
||||||
&Instruction::GetPrevLevel(r) => vec![r],
|
Instruction::GetPrevLevel(r) => vec![r],
|
||||||
&Instruction::GetCutPoint(r) => vec![r],
|
Instruction::GetCutPoint(r) => vec![r],
|
||||||
_ => vec![],
|
_ => vec![],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
31
src/ffi.rs
31
src/ffi.rs
@@ -27,6 +27,7 @@ use std::collections::HashMap;
|
|||||||
use std::convert::TryFrom;
|
use std::convert::TryFrom;
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
use std::ffi::{c_void, CString};
|
use std::ffi::{c_void, CString};
|
||||||
|
use std::ptr::addr_of_mut;
|
||||||
|
|
||||||
use libffi::low::type_tag::STRUCT;
|
use libffi::low::type_tag::STRUCT;
|
||||||
use libffi::low::{ffi_abi_FFI_DEFAULT_ABI, ffi_cif, ffi_type, prep_cif, types, CodePtr};
|
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 {
|
fn map_type_ffi(&mut self, source: &Atom) -> *mut ffi_type {
|
||||||
unsafe {
|
unsafe {
|
||||||
match source {
|
match source {
|
||||||
atom!("sint64") => &mut types::sint64,
|
atom!("sint64") => addr_of_mut!(types::sint64),
|
||||||
atom!("sint32") => &mut types::sint32,
|
atom!("sint32") => addr_of_mut!(types::sint32),
|
||||||
atom!("sint16") => &mut types::sint16,
|
atom!("sint16") => addr_of_mut!(types::sint16),
|
||||||
atom!("sint8") => &mut types::sint8,
|
atom!("sint8") => addr_of_mut!(types::sint8),
|
||||||
atom!("uint64") => &mut types::uint64,
|
atom!("uint64") => addr_of_mut!(types::uint64),
|
||||||
atom!("uint32") => &mut types::uint32,
|
atom!("uint32") => addr_of_mut!(types::uint32),
|
||||||
atom!("uint16") => &mut types::uint16,
|
atom!("uint16") => addr_of_mut!(types::uint16),
|
||||||
atom!("uint8") => &mut types::uint8,
|
atom!("uint8") => addr_of_mut!(types::uint8),
|
||||||
atom!("bool") => &mut types::sint8,
|
atom!("bool") => addr_of_mut!(types::sint8),
|
||||||
atom!("void") => &mut types::void,
|
atom!("void") => addr_of_mut!(types::void),
|
||||||
atom!("cstr") => &mut types::pointer,
|
atom!("cstr") => addr_of_mut!(types::pointer),
|
||||||
atom!("ptr") => &mut types::pointer,
|
atom!("ptr") => addr_of_mut!(types::pointer),
|
||||||
atom!("f32") => &mut types::float,
|
atom!("f32") => addr_of_mut!(types::float),
|
||||||
atom!("f64") => &mut types::double,
|
atom!("f64") => addr_of_mut!(types::double),
|
||||||
struct_name => match self.structs.get_mut(&*struct_name.as_str()) {
|
struct_name => match self.structs.get_mut(&*struct_name.as_str()) {
|
||||||
Some(ref mut struct_type) => &mut struct_type.ffi_type,
|
Some(ref mut struct_type) => &mut struct_type.ffi_type,
|
||||||
None => unreachable!(),
|
None => unreachable!(),
|
||||||
@@ -161,7 +162,7 @@ impl ForeignFunctionTable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn build_pointer_args(
|
fn build_pointer_args(
|
||||||
args: &mut Vec<Value>,
|
args: &mut [Value],
|
||||||
type_args: &[*mut ffi_type],
|
type_args: &[*mut ffi_type],
|
||||||
structs_table: &mut HashMap<String, StructImpl>,
|
structs_table: &mut HashMap<String, StructImpl>,
|
||||||
) -> Result<PointerArgs, FFIError> {
|
) -> Result<PointerArgs, FFIError> {
|
||||||
|
|||||||
@@ -607,6 +607,6 @@ mod tests {
|
|||||||
assert_eq!(
|
assert_eq!(
|
||||||
result,
|
result,
|
||||||
Err(String::from("error existence_error procedure / non_existent_predicate 3 / non_existent_predicate 3"))
|
Err(String::from("error existence_error procedure / non_existent_predicate 3 / non_existent_predicate 3"))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1022,19 +1022,6 @@ pub enum SessionError {
|
|||||||
QueryCannotBeDefinedAsFact,
|
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 {
|
impl From<std::io::Error> for SessionError {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn from(err: std::io::Error) -> SessionError {
|
fn from(err: std::io::Error) -> SessionError {
|
||||||
@@ -1055,10 +1042,3 @@ impl From<CompilationError> for SessionError {
|
|||||||
SessionError::CompilationError(err)
|
SessionError::CompilationError(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<ParserError> for EvalSession {
|
|
||||||
#[inline]
|
|
||||||
fn from(err: ParserError) -> Self {
|
|
||||||
EvalSession::from(SessionError::from(err))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -229,7 +229,7 @@ impl<R: Read> CharRead for CharReader<R> {
|
|||||||
|
|
||||||
match self.inner.read(word_slice) {
|
match self.inner.read(word_slice) {
|
||||||
Err(e) => return Some(Err(e)),
|
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) => {
|
Ok(nread) => {
|
||||||
self.buf.extend_from_slice(&word_slice[0..nread]);
|
self.buf.extend_from_slice(&word_slice[0..nread]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ thread_local! {
|
|||||||
// odd value means the current thread is about to access the active_epoch of an Rcu
|
// 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,
|
// a thread has a single epoch counter for all Rcu it accesses,
|
||||||
// as a thread can only access one Rcu at a time
|
// 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> {
|
pub struct Rcu<T> {
|
||||||
|
|||||||
Reference in New Issue
Block a user