Fix warnings
This commit is contained in:
@@ -3252,6 +3252,7 @@ pub fn generate_instructions_rs() -> TokenStream {
|
||||
)
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn is_ctrl_instr(&self) -> bool {
|
||||
matches!(self,
|
||||
Instruction::Allocate(_) |
|
||||
@@ -3262,6 +3263,7 @@ pub fn generate_instructions_rs() -> TokenStream {
|
||||
)
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn is_query_instr(&self) -> bool {
|
||||
matches!(self,
|
||||
&Instruction::GetVariable(..) |
|
||||
|
||||
@@ -894,6 +894,8 @@ const_assert!(mem::size_of::<OrderedFloat<f64>>() == 8);
|
||||
mod tests {
|
||||
use std::ops::Deref;
|
||||
|
||||
use crate::arena::*;
|
||||
use crate::atom_table::*;
|
||||
use crate::machine::mock_wam::*;
|
||||
use crate::machine::partial_string::*;
|
||||
|
||||
|
||||
@@ -124,12 +124,6 @@ impl Hash for Atom {
|
||||
}
|
||||
}
|
||||
|
||||
macro_rules! is_char {
|
||||
($s:expr) => {
|
||||
!$s.is_empty() && $s.chars().nth(1).is_none()
|
||||
};
|
||||
}
|
||||
|
||||
pub enum AtomString<'a> {
|
||||
Static(&'a str),
|
||||
Dynamic(AtomTableRef<str>),
|
||||
|
||||
11
src/forms.rs
11
src/forms.rs
@@ -159,17 +159,6 @@ impl ChunkedTermVec {
|
||||
.push_back(ChunkedTerms::Branch(Vec::with_capacity(capacity)));
|
||||
}
|
||||
|
||||
pub fn push_branch_arm(&mut self, branch: VecDeque<ChunkedTerms>) {
|
||||
match self.chunk_vec.back_mut().unwrap() {
|
||||
ChunkedTerms::Branch(branches) => {
|
||||
branches.push(branch);
|
||||
}
|
||||
ChunkedTerms::Chunk(_) => {
|
||||
self.chunk_vec.push_back(ChunkedTerms::Branch(vec![branch]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn add_chunk(&mut self) {
|
||||
self.chunk_vec
|
||||
|
||||
@@ -327,8 +327,6 @@ pub trait HCValueOutputter {
|
||||
fn new() -> Self;
|
||||
fn push_char(&mut self, c: char);
|
||||
fn append(&mut self, s: &str);
|
||||
fn begin_new_var(&mut self);
|
||||
fn insert(&mut self, index: usize, c: char);
|
||||
fn result(self) -> Self::Output;
|
||||
fn ends_with(&self, s: &str) -> bool;
|
||||
fn len(&self) -> usize;
|
||||
@@ -362,16 +360,6 @@ impl HCValueOutputter for PrinterOutputter {
|
||||
self.contents.push(c);
|
||||
}
|
||||
|
||||
fn begin_new_var(&mut self) {
|
||||
if !self.contents.is_empty() {
|
||||
self.contents += ", ";
|
||||
}
|
||||
}
|
||||
|
||||
fn insert(&mut self, idx: usize, c: char) {
|
||||
self.contents.insert(idx, c);
|
||||
}
|
||||
|
||||
fn result(self) -> Self::Output {
|
||||
self.contents
|
||||
}
|
||||
@@ -496,7 +484,6 @@ pub struct HCPrinter<'a, Outputter> {
|
||||
pub numbervars: bool,
|
||||
pub quoted: bool,
|
||||
pub ignore_ops: bool,
|
||||
pub print_strings_as_strs: bool,
|
||||
pub max_depth: usize,
|
||||
pub double_quotes: bool,
|
||||
}
|
||||
@@ -561,7 +548,6 @@ impl<'a, Outputter: HCValueOutputter> HCPrinter<'a, Outputter> {
|
||||
quoted: false,
|
||||
ignore_ops: false,
|
||||
var_names: IndexMap::new(),
|
||||
print_strings_as_strs: false,
|
||||
max_depth: 0,
|
||||
double_quotes: false,
|
||||
}
|
||||
|
||||
@@ -40,8 +40,6 @@ mod repl_helper;
|
||||
mod targets;
|
||||
pub(crate) mod types;
|
||||
|
||||
use instructions::instr;
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
|
||||
@@ -95,11 +95,6 @@ pub struct ChunkInfo {
|
||||
vars: Vec<VarInfo>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct BranchArm {
|
||||
pub arm_terms: Vec<QueryTerm>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub struct BranchInfo {
|
||||
branch_num: BranchNumber,
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#![allow(dead_code)]
|
||||
|
||||
use crate::atom_table::*;
|
||||
use crate::machine::heap::*;
|
||||
use crate::types::*;
|
||||
|
||||
@@ -572,15 +572,6 @@ impl MachineState {
|
||||
stub,
|
||||
)
|
||||
}
|
||||
SessionError::QueryCannotBeDefinedAsFact => {
|
||||
let error_atom = atom!("query_cannot_be_defined_as_fact");
|
||||
|
||||
self.permission_error(
|
||||
Permission::Create,
|
||||
atom!("static_procedure"),
|
||||
functor!(error_atom),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -710,9 +701,7 @@ impl MachineError {
|
||||
pub enum CompilationError {
|
||||
Arithmetic(ArithmeticError),
|
||||
ParserError(ParserError),
|
||||
CannotParseCyclicTerm,
|
||||
ExceededMaxArity,
|
||||
ExpectedRel,
|
||||
InadmissibleFact,
|
||||
InadmissibleQueryTerm,
|
||||
InvalidDirective(DirectiveError),
|
||||
@@ -722,7 +711,6 @@ pub enum CompilationError {
|
||||
InvalidRuleHead,
|
||||
InvalidUseModuleDecl,
|
||||
InvalidModuleResolution(Atom),
|
||||
UnreadableTerm,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
@@ -765,15 +753,9 @@ impl CompilationError {
|
||||
CompilationError::Arithmetic(..) => {
|
||||
functor!(atom!("arithmetic_error"))
|
||||
}
|
||||
CompilationError::CannotParseCyclicTerm => {
|
||||
functor!(atom!("cannot_parse_cyclic_term"))
|
||||
}
|
||||
CompilationError::ExceededMaxArity => {
|
||||
functor!(atom!("exceeded_max_arity"))
|
||||
}
|
||||
CompilationError::ExpectedRel => {
|
||||
functor!(atom!("expected_relation"))
|
||||
}
|
||||
CompilationError::InadmissibleFact => {
|
||||
// TODO: type_error(callable, _).
|
||||
functor!(atom!("inadmissible_fact"))
|
||||
@@ -806,9 +788,6 @@ impl CompilationError {
|
||||
CompilationError::ParserError(ref err) => {
|
||||
functor!(err.as_atom())
|
||||
}
|
||||
CompilationError::UnreadableTerm => {
|
||||
functor!(atom!("unreadable_term"))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1063,7 +1042,6 @@ pub enum SessionError {
|
||||
NamelessEntry,
|
||||
OpIsInfixAndPostFix(Atom),
|
||||
PredicateNotMultifileOrDiscontiguous(CompilationTarget, PredicateKey),
|
||||
QueryCannotBeDefinedAsFact,
|
||||
}
|
||||
|
||||
impl From<std::io::Error> for SessionError {
|
||||
|
||||
@@ -256,31 +256,16 @@ impl MachineState {
|
||||
unifier.unify_internal();
|
||||
}
|
||||
|
||||
pub fn unify_structure(&mut self, s1: usize, value: HeapCellValue) {
|
||||
let mut unifier = DefaultUnifier::from(self);
|
||||
unifier.unify_structure(s1, value);
|
||||
}
|
||||
|
||||
pub fn unify_atom(&mut self, atom: Atom, value: HeapCellValue) {
|
||||
let mut unifier = DefaultUnifier::from(self);
|
||||
unifier.unify_atom(atom, value);
|
||||
}
|
||||
|
||||
pub fn unify_list(&mut self, l1: usize, value: HeapCellValue) {
|
||||
let mut unifier = DefaultUnifier::from(self);
|
||||
unifier.unify_list(l1, value);
|
||||
}
|
||||
|
||||
pub fn unify_complete_string(&mut self, atom: Atom, value: HeapCellValue) {
|
||||
let mut unifier = DefaultUnifier::from(self);
|
||||
unifier.unify_complete_string(atom, value);
|
||||
}
|
||||
|
||||
pub fn unify_partial_string(&mut self, value_1: HeapCellValue, value_2: HeapCellValue) {
|
||||
let mut unifier = DefaultUnifier::from(self);
|
||||
unifier.unify_partial_string(value_1, value_2);
|
||||
}
|
||||
|
||||
pub fn unify_char(&mut self, c: char, value: HeapCellValue) {
|
||||
let mut unifier = DefaultUnifier::from(self);
|
||||
unifier.unify_char(c, value);
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
pub use crate::arena::*;
|
||||
pub use crate::atom_table::*;
|
||||
use crate::heap_print::*;
|
||||
pub use crate::machine::heap::*;
|
||||
pub use crate::machine::machine_state::*;
|
||||
pub use crate::machine::stack::*;
|
||||
pub use crate::machine::streams::*;
|
||||
pub use crate::machine::*;
|
||||
pub use crate::parser::ast::*;
|
||||
@@ -23,9 +20,10 @@ use std::ops::{Deref, DerefMut, Index, IndexMut};
|
||||
pub struct MockWAM {
|
||||
pub machine_st: MachineState,
|
||||
pub op_dir: OpDir,
|
||||
pub flags: MachineFlags,
|
||||
//pub flags: MachineFlags,
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
impl MockWAM {
|
||||
pub fn new() -> Self {
|
||||
let op_dir = default_op_dir();
|
||||
@@ -33,7 +31,7 @@ impl MockWAM {
|
||||
Self {
|
||||
machine_st: MachineState::new(),
|
||||
op_dir,
|
||||
flags: MachineFlags::default(),
|
||||
//flags: MachineFlags::default(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -271,14 +271,6 @@ impl Machine {
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
fn throw_session_error(&mut self, err: SessionError, key: PredicateKey) {
|
||||
let err = self.machine_st.session_error(err);
|
||||
let stub = functor_stub(key.0, key.1);
|
||||
let err = self.machine_st.error_form(err, stub);
|
||||
|
||||
self.machine_st.throw_exception(err);
|
||||
}
|
||||
|
||||
pub(crate) fn run_module_predicate(
|
||||
&mut self,
|
||||
module_name: Atom,
|
||||
@@ -358,15 +350,6 @@ impl Machine {
|
||||
}
|
||||
}
|
||||
|
||||
fn set_user_input(&mut self, input: String) {
|
||||
self.user_input = Stream::from_owned_string(input, &mut self.machine_st.arena);
|
||||
}
|
||||
|
||||
fn get_user_output(&self) -> String {
|
||||
let output_bytes: Vec<_> = self.user_output.bytes().map(|b| b.unwrap()).collect();
|
||||
String::from_utf8(output_bytes).unwrap()
|
||||
}
|
||||
|
||||
pub(crate) fn configure_modules(&mut self) {
|
||||
fn update_call_n_indices(
|
||||
loader: &Module,
|
||||
|
||||
@@ -103,11 +103,6 @@ impl<'a> HeapPStrIter<'a> {
|
||||
self.focus.is_string_terminator(self.heap)
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn num_steps(&self) -> usize {
|
||||
self.brent_st.num_steps()
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn chars(mut self) -> PStrCharsIter<'a> {
|
||||
let item = self.next();
|
||||
|
||||
@@ -528,11 +528,6 @@ impl From<TypedArenaPtr<ReadlineStream>> for Stream {
|
||||
}
|
||||
|
||||
impl Stream {
|
||||
#[inline]
|
||||
pub fn from_readline_stream(stream: ReadlineStream, arena: &mut Arena) -> Stream {
|
||||
Stream::Readline(arena_alloc!(StreamLayout::new(stream), arena))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn from_owned_string(string: String, arena: &mut Arena) -> Stream {
|
||||
Stream::Byte(arena_alloc!(
|
||||
|
||||
@@ -185,12 +185,6 @@ macro_rules! is_prefix {
|
||||
};
|
||||
}
|
||||
|
||||
macro_rules! is_postfix {
|
||||
($x:expr) => {
|
||||
$x as u32 & ($crate::parser::ast::XF as u32 | $crate::parser::ast::YF as u32) != 0
|
||||
};
|
||||
}
|
||||
|
||||
macro_rules! is_infix {
|
||||
($x:expr) => {
|
||||
($x as u32
|
||||
@@ -312,12 +306,6 @@ macro_rules! temp_v {
|
||||
};
|
||||
}
|
||||
|
||||
macro_rules! perm_v {
|
||||
($x:expr) => {
|
||||
$crate::parser::ast::RegType::Perm($x)
|
||||
};
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
pub enum GenContext {
|
||||
Head,
|
||||
@@ -407,10 +395,6 @@ impl DoubleQuotes {
|
||||
matches!(self, DoubleQuotes::Chars)
|
||||
}
|
||||
|
||||
pub fn is_atom(self) -> bool {
|
||||
matches!(self, DoubleQuotes::Atom)
|
||||
}
|
||||
|
||||
pub fn is_codes(self) -> bool {
|
||||
matches!(self, DoubleQuotes::Codes)
|
||||
}
|
||||
@@ -424,20 +408,6 @@ pub enum Unknown {
|
||||
Warn,
|
||||
}
|
||||
|
||||
impl Unknown {
|
||||
pub fn is_error(self) -> bool {
|
||||
matches!(self, Unknown::Error)
|
||||
}
|
||||
|
||||
pub fn is_fail(self) -> bool {
|
||||
matches!(self, Unknown::Fail)
|
||||
}
|
||||
|
||||
pub fn is_warn(self) -> bool {
|
||||
matches!(self, Unknown::Warn)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn default_op_dir() -> OpDir {
|
||||
let mut op_dir = OpDir::with_hasher(FxBuildHasher::default());
|
||||
|
||||
@@ -455,6 +425,7 @@ pub enum ArithmeticError {
|
||||
UninstantiatedVar,
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[derive(Debug)]
|
||||
pub enum ParserError {
|
||||
BackQuotedString(usize, usize),
|
||||
@@ -783,14 +754,6 @@ impl From<&str> for Var {
|
||||
}
|
||||
|
||||
impl Var {
|
||||
#[inline(always)]
|
||||
pub fn as_str(&self) -> Option<&str> {
|
||||
match self {
|
||||
Var::Named(value) => Some(value),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::inherent_to_string)]
|
||||
#[inline(always)]
|
||||
pub fn to_string(&self) -> String {
|
||||
@@ -815,13 +778,6 @@ pub enum Term {
|
||||
}
|
||||
|
||||
impl Term {
|
||||
pub fn into_literal(self) -> Option<Literal> {
|
||||
match self {
|
||||
Term::Literal(_, c) => Some(c),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn first_arg(&self) -> Option<&Term> {
|
||||
match self {
|
||||
Term::Clause(_, _, ref terms) => terms.first(),
|
||||
@@ -829,15 +785,6 @@ impl Term {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_name(&mut self, new_name: Atom) {
|
||||
match self {
|
||||
Term::Literal(_, Literal::Atom(ref mut atom)) | Term::Clause(_, ref mut atom, ..) => {
|
||||
*atom = new_name;
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn name(&self) -> Option<Atom> {
|
||||
match self {
|
||||
&Term::Literal(_, Literal::Atom(ref atom)) | &Term::Clause(_, ref atom, ..) => {
|
||||
@@ -855,15 +802,6 @@ impl Term {
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn source_arity(terms: &[Term]) -> usize {
|
||||
if let Some(Term::Literal(_, Literal::CodeIndex(_))) = terms.last() {
|
||||
return terms.len() - 1;
|
||||
}
|
||||
|
||||
terms.len()
|
||||
}
|
||||
|
||||
pub(crate) fn unfold_by_str_once(term: &mut Term, s: Atom) -> Option<(Term, Term)> {
|
||||
if let Term::Clause(_, ref name, ref mut subterms) = term {
|
||||
if let Some(Term::Literal(_, Literal::CodeIndex(_))) = subterms.last() {
|
||||
|
||||
@@ -52,11 +52,6 @@ impl<R> CharReader<R> {
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn inner(&self) -> &R {
|
||||
&self.inner
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn inner_mut(&mut self) -> &mut R {
|
||||
&mut self.inner
|
||||
@@ -100,10 +95,6 @@ impl<R> CharReader<R> {
|
||||
&self.buf[self.pos..]
|
||||
}
|
||||
|
||||
pub fn into_inner(self) -> R {
|
||||
self.inner
|
||||
}
|
||||
|
||||
pub fn reset_buffer(&mut self) {
|
||||
self.buf.clear();
|
||||
self.pos = 0;
|
||||
|
||||
@@ -180,31 +180,6 @@ pub fn get_op_desc(name: Atom, op_dir: &CompositeOpDir) -> Option<CompositeOpDes
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_clause_spec(name: Atom, arity: usize, op_dir: &CompositeOpDir) -> Option<OpDesc> {
|
||||
match arity {
|
||||
1 => {
|
||||
/* This is a clause with an operator principal functor. Prefix operators
|
||||
are supposed over post.
|
||||
*/
|
||||
if let Some(cell) = op_dir.get(name, Fixity::Pre) {
|
||||
return Some(cell);
|
||||
}
|
||||
|
||||
if let Some(cell) = op_dir.get(name, Fixity::Post) {
|
||||
return Some(cell);
|
||||
}
|
||||
}
|
||||
2 => {
|
||||
if let Some(cell) = op_dir.get(name, Fixity::In) {
|
||||
return Some(cell);
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
};
|
||||
|
||||
None
|
||||
}
|
||||
|
||||
fn affirm_xfx(priority: usize, d2: TokenDesc, d3: TokenDesc, d1: TokenDesc) -> bool {
|
||||
d2.priority <= priority
|
||||
&& is_term!(d3.spec)
|
||||
@@ -341,16 +316,6 @@ impl<'a, R: CharRead> Parser<'a, R> {
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn line_num(&self) -> usize {
|
||||
self.lexer.line_num
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn col_num(&self) -> usize {
|
||||
self.lexer.col_num
|
||||
}
|
||||
|
||||
fn get_term_name(&mut self, td: TokenDesc) -> Option<Atom> {
|
||||
match td.tt {
|
||||
TokenType::HeadTailSeparator => Some(atom!("|")),
|
||||
|
||||
Reference in New Issue
Block a user