From 73c26bed2ad9ab14991dc7217cb78ad32f700823 Mon Sep 17 00:00:00 2001 From: Skgland Date: Sat, 10 Jan 2026 17:48:07 +0100 Subject: [PATCH 1/5] extaract the static part of the instructions template directly into the instructions module This way goto source doesn't end up in a generated file for those parts and they can be edited directly. I have way too often accidentally edited the generated file. --- build/instructions_template.rs | 1410 -------------------------------- src/instructions.rs | 1406 +++++++++++++++++++++++++++++++ src/lib.rs | 6 +- 3 files changed, 1409 insertions(+), 1413 deletions(-) create mode 100644 src/instructions.rs diff --git a/build/instructions_template.rs b/build/instructions_template.rs index 29f3d715..277ce010 100644 --- a/build/instructions_template.rs +++ b/build/instructions_template.rs @@ -908,1380 +908,6 @@ where (name, arity) } -fn generate_instruction_preface() -> TokenStream { - quote! { - use crate::arena::*; - use crate::arithmetic::*; - use crate::atom_table::*; - use crate::forms::*; - use crate::functor_macro::*; - use crate::machine::heap::*; - use crate::machine::machine_errors::MachineStub; - use crate::machine::machine_indices::CodeIndex; - use crate::parser::ast::*; - use crate::types::*; - - use fxhash::FxBuildHasher; - use indexmap::IndexMap; - - use std::collections::VecDeque; - use std::rc::Rc; - - fn reg_type_into_functor(r: RegType) -> MachineStub { - match r { - RegType::Temp(r) => functor!(atom!("x"), [fixnum(r)]), - RegType::Perm(r) => functor!(atom!("y"), [fixnum(r)]), - } - } - - impl Level { - fn into_functor(self) -> MachineStub { - match self { - Level::Root => functor!(atom!("level"), [atom_as_cell((atom!("root")))]), - Level::Shallow => functor!(atom!("level"), [atom_as_cell((atom!("shallow")))]), - Level::Deep => functor!(atom!("level"), [atom_as_cell((atom!("deep")))]), - } - } - } - - impl ArithmeticTerm { - fn into_functor(self, arena: &mut Arena) -> MachineStub { - match self { - ArithmeticTerm::Reg(r) => reg_type_into_functor(r), - ArithmeticTerm::IntermReg(i) => { - functor!(atom!("x"), [fixnum(i)]) - } - ArithmeticTerm::Number(n) => { - functor!(atom!("number"), [number(n, arena)]) - } - } - } - } - - #[derive(Debug, Clone, Copy)] - pub enum NextOrFail { - Next(usize), - Fail(usize), - } - - impl Default for NextOrFail { - fn default() -> Self { - NextOrFail::Fail(0) - } - } - - impl NextOrFail { - #[inline] - pub fn is_next(&self) -> bool { - matches!(self, NextOrFail::Next(_)) - } - } - - #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] - pub enum Death { - Finite(usize), - #[default] - Infinity, - } - - #[derive(Clone, Copy, Debug)] - pub enum IndexedChoiceInstruction { - Retry(usize), - DefaultRetry(usize), - Trust(usize), - DefaultTrust(usize), - Try(usize), - } - - impl IndexedChoiceInstruction { - pub(crate) fn offset(&self) -> usize { - match *self { - IndexedChoiceInstruction::Retry(offset) => offset, - IndexedChoiceInstruction::Trust(offset) => offset, - IndexedChoiceInstruction::Try(offset) => offset, - IndexedChoiceInstruction::DefaultRetry(offset) => offset, - IndexedChoiceInstruction::DefaultTrust(offset) => offset, - } - } - - pub(crate) fn to_functor(self) -> MachineStub { - match self { - IndexedChoiceInstruction::Try(offset) => { - functor!(atom!("try"), [fixnum(offset)]) - } - IndexedChoiceInstruction::Trust(offset) => { - functor!(atom!("trust"), [fixnum(offset)]) - } - IndexedChoiceInstruction::Retry(offset) => { - functor!(atom!("retry"), [fixnum(offset)]) - } - IndexedChoiceInstruction::DefaultTrust(offset) => { - functor!(atom!("default_trust"), [fixnum(offset)]) - } - IndexedChoiceInstruction::DefaultRetry(offset) => { - functor!(atom!("default_retry"), [fixnum(offset)]) - } - } - } - } - - /// `IndexingInstruction` cf. page 110 of wambook. - #[allow(clippy::enum_variant_names)] - #[derive(Clone, Debug)] - pub enum IndexingInstruction { - // The first index is the optimal argument being indexed. - SwitchOnTerm( - usize, - IndexingCodePtr, - IndexingCodePtr, - IndexingCodePtr, - IndexingCodePtr, - ), - SwitchOnConstant(IndexMap), - SwitchOnStructure(IndexMap<(Atom, usize), IndexingCodePtr, FxBuildHasher>), - } - - #[derive(Debug, Clone, Copy)] - pub enum IndexingCodePtr { - External(usize), // the index points past the indexing instruction prelude. - DynamicExternal(usize), // an External index of a dynamic predicate, potentially invalidated by retraction. - Fail, - Internal(usize), // the index points into the indexing instruction prelude. - } - - impl IndexingCodePtr { - #[allow(dead_code)] - pub fn to_functor(self) -> MachineStub { - match self { - IndexingCodePtr::DynamicExternal(o) => functor!(atom!("dynamic_external"), [fixnum(o)]), - IndexingCodePtr::External(o) => functor!(atom!("external"), [fixnum(o)]), - IndexingCodePtr::Internal(o) => functor!(atom!("internal"), [fixnum(o)]), - IndexingCodePtr::Fail => { - functor!(atom!("fail")) - }, - } - } - - pub fn is_external(&self) -> bool { - matches!( - self, - IndexingCodePtr::External(_) | IndexingCodePtr::DynamicExternal(_) - ) - } - } - - impl IndexingInstruction { - pub fn to_functor(&self) -> MachineStub { - match self { - &IndexingInstruction::SwitchOnTerm(arg, vars, constants, lists, structures) => { - functor!( - atom!("switch_on_term"), - [ - fixnum(arg), - indexing_code_ptr(vars), - indexing_code_ptr(constants), - indexing_code_ptr(lists), - indexing_code_ptr(structures) - ] - ) - } - IndexingInstruction::SwitchOnConstant(constants) => { - variadic_functor( - atom!("switch_on_constants"), - 1, - constants.iter().map(|(c, ptr)| { - functor!( - atom!(":"), - [cell((*c)), indexing_code_ptr((*ptr))] - ) - }), - ) - } - IndexingInstruction::SwitchOnStructure(structures) => { - variadic_functor( - atom!("switch_on_structure"), - 1, - structures.iter().map(|((name, arity), ptr)| { - functor!( - atom!(":"), - [functor((atom!("/")), [atom_as_cell(name), fixnum((*arity))]), - indexing_code_ptr((*ptr))] - ) - }), - ) - } - } - } - } - - /// A `Line` is an instruction (cf. page 98 of wambook). - #[derive(Clone, Debug)] - pub enum IndexingLine { - Indexing(IndexingInstruction), - IndexedChoice(VecDeque), - DynamicIndexedChoice(VecDeque), - } - - impl From for IndexingLine { - #[inline] - fn from(instr: IndexingInstruction) -> Self { - IndexingLine::Indexing(instr) - } - } - - impl From> for IndexingLine { - #[inline] - fn from(instrs: VecDeque) -> Self { - IndexingLine::IndexedChoice(instrs.into_iter().collect()) - } - } - - fn arith_instr_unary_functor( - name: Atom, - arena: &mut Arena, - at: &ArithmeticTerm, - t: usize, - ) -> MachineStub { - let at_stub = at.into_functor(arena); - functor!(name, [functor(at_stub), fixnum(t)]) - } - - fn arith_instr_bin_functor( - name: Atom, - arena: &mut Arena, - at_1: &ArithmeticTerm, - at_2: &ArithmeticTerm, - t: usize, - ) -> MachineStub { - let at_1_stub = at_1.into_functor(arena); - let at_2_stub = at_2.into_functor(arena); - - functor!(name, [functor(at_1_stub), - functor(at_2_stub), - fixnum(t)]) - } - - pub type Code = Vec; - pub type CodeDeque = VecDeque; - - impl Instruction { - #[inline] - pub fn to_indexing_line_mut(&mut self) -> Option<&mut Vec> { - match self { - Instruction::IndexingCode(ref mut indexing_code) => Some(indexing_code), - _ => None, - } - } - - #[inline] - pub fn to_indexing_line(&self) -> Option<&Vec> { - match self { - Instruction::IndexingCode(ref indexing_code) => Some(indexing_code), - _ => None, - } - } - - pub fn enqueue_functors( - &self, - arena: &mut Arena, - functors: &mut Vec, - ) { - match self { - Instruction::IndexingCode(indexing_instrs) => { - for indexing_instr in indexing_instrs { - match indexing_instr { - IndexingLine::Indexing(indexing_instr) => { - let section = indexing_instr.to_functor(); - functors.push(section); - } - IndexingLine::IndexedChoice(indexed_choice_instrs) => { - for indexed_choice_instr in indexed_choice_instrs { - let section = indexed_choice_instr.to_functor(); - functors.push(section); - } - } - IndexingLine::DynamicIndexedChoice(indexed_choice_instrs) => { - for indexed_choice_instr in indexed_choice_instrs { - let section = functor!(atom!("dynamic"), - [fixnum((*indexed_choice_instr))]); - functors.push(section); - } - } - } - } - } - instr => functors.push(instr.to_functor(arena)), - } - } - - fn to_functor(&self, arena: &mut Arena) -> MachineStub { - match self { - &Instruction::RunVerifyAttr => { - functor!(atom!("run_verify_attr")) - } - &Instruction::DynamicElse(birth, death, next_or_fail) => { - match (death, next_or_fail) { - (Death::Infinity, NextOrFail::Next(i)) => { - functor!( - atom!("dynamic_else"), - [fixnum(birth), atom_as_cell((atom!("inf"))), fixnum(i)] - ) - } - (Death::Infinity, NextOrFail::Fail(i)) => { - functor!( - atom!("dynamic_else"), - [fixnum(birth), - atom_as_cell((atom!("inf"))), - functor((atom!("fail")), [fixnum(i)])] - ) - } - (Death::Finite(d), NextOrFail::Fail(i)) => { - functor!( - atom!("dynamic_else"), - [fixnum(birth), - fixnum(d), - functor((atom!("fail")), [fixnum(i)])] - ) - } - (Death::Finite(d), NextOrFail::Next(i)) => { - functor!(atom!("dynamic_else"), [fixnum(birth), fixnum(d), fixnum(i)]) - } - } - } - &Instruction::DynamicInternalElse(birth, death, next_or_fail) => { - match (death, next_or_fail) { - (Death::Infinity, NextOrFail::Next(i)) => { - functor!( - atom!("dynamic_internal_else"), - [fixnum(birth), atom_as_cell((atom!("inf"))), fixnum(i)] - ) - } - (Death::Infinity, NextOrFail::Fail(i)) => { - functor!( - atom!("dynamic_internal_else"), - [fixnum(birth), - atom_as_cell((atom!("inf"))), - functor((atom!("fail")), [fixnum(i)])] - ) - } - (Death::Finite(d), NextOrFail::Fail(i)) => { - functor!( - atom!("dynamic_internal_else"), - [fixnum(birth), - fixnum(d), - functor((atom!("fail")), [fixnum(i)])] - ) - } - (Death::Finite(d), NextOrFail::Next(i)) => { - functor!( - atom!("dynamic_internal_else"), - [fixnum(birth), fixnum(d), fixnum(i)] - ) - } - } - } - &Instruction::TryMeElse(offset) => { - functor!(atom!("try_me_else"), [fixnum(offset)]) - } - &Instruction::RetryMeElse(offset) => { - functor!(atom!("retry_me_else"), [fixnum(offset)]) - } - &Instruction::TrustMe(offset) => { - functor!(atom!("trust_me"), [fixnum(offset)]) - } - &Instruction::DefaultRetryMeElse(offset) => { - functor!(atom!("default_retry_me_else"), [fixnum(offset)]) - } - &Instruction::DefaultTrustMe(offset) => { - functor!(atom!("default_trust_me"), [fixnum(offset)]) - } - &Instruction::Cut(r) => { - let rt_stub = reg_type_into_functor(r); - functor!(atom!("cut"), [functor(rt_stub)]) - } - &Instruction::CutPrev(r) => { - let rt_stub = reg_type_into_functor(r); - functor!(atom!("cut_prev"), [functor(rt_stub)]) - } - &Instruction::GetLevel(r) => { - let rt_stub = reg_type_into_functor(r); - functor!(atom!("get_level"), [functor(rt_stub)]) - } - &Instruction::GetPrevLevel(r) => { - let rt_stub = reg_type_into_functor(r); - functor!(atom!("get_prev_level"), [functor(rt_stub)]) - } - &Instruction::GetCutPoint(r) => { - let rt_stub = reg_type_into_functor(r); - functor!(atom!("get_cut_point"), [functor(rt_stub)]) - } - &Instruction::NeckCut => { - functor!(atom!("neck_cut")) - } - &Instruction::Add(ref at_1, ref at_2, t) => { - arith_instr_bin_functor(atom!("add"), arena, at_1, at_2, t) - } - &Instruction::Sub(ref at_1, ref at_2, t) => { - arith_instr_bin_functor(atom!("sub"), arena, at_1, at_2, t) - } - &Instruction::Mul(ref at_1, ref at_2, t) => { - arith_instr_bin_functor(atom!("mul"), arena, at_1, at_2, t) - } - &Instruction::IntPow(ref at_1, ref at_2, t) => { - arith_instr_bin_functor(atom!("int_pow"), arena, at_1, at_2, t) - } - &Instruction::Pow(ref at_1, ref at_2, t) => { - arith_instr_bin_functor(atom!("pow"), arena, at_1, at_2, t) - } - &Instruction::IDiv(ref at_1, ref at_2, t) => { - arith_instr_bin_functor(atom!("idiv"), arena, at_1, at_2, t) - } - &Instruction::Max(ref at_1, ref at_2, t) => { - arith_instr_bin_functor(atom!("max"), arena, at_1, at_2, t) - } - &Instruction::Min(ref at_1, ref at_2, t) => { - arith_instr_bin_functor(atom!("min"), arena, at_1, at_2, t) - } - &Instruction::IntFloorDiv(ref at_1, ref at_2, t) => { - arith_instr_bin_functor(atom!("int_floor_div"), arena, at_1, at_2, t) - } - &Instruction::RDiv(ref at_1, ref at_2, t) => { - arith_instr_bin_functor(atom!("rdiv"), arena, at_1, at_2, t) - } - &Instruction::Div(ref at_1, ref at_2, t) => { - arith_instr_bin_functor(atom!("div"), arena, at_1, at_2, t) - } - &Instruction::Shl(ref at_1, ref at_2, t) => { - arith_instr_bin_functor(atom!("shl"), arena, at_1, at_2, t) - } - &Instruction::Shr(ref at_1, ref at_2, t) => { - arith_instr_bin_functor(atom!("shr"), arena, at_1, at_2, t) - } - &Instruction::Xor(ref at_1, ref at_2, t) => { - arith_instr_bin_functor(atom!("xor"), arena, at_1, at_2, t) - } - &Instruction::And(ref at_1, ref at_2, t) => { - arith_instr_bin_functor(atom!("and"), arena, at_1, at_2, t) - } - &Instruction::Or(ref at_1, ref at_2, t) => { - arith_instr_bin_functor(atom!("or"), arena, at_1, at_2, t) - } - &Instruction::Mod(ref at_1, ref at_2, t) => { - arith_instr_bin_functor(atom!("mod"), arena, at_1, at_2, t) - } - &Instruction::Rem(ref at_1, ref at_2, t) => { - arith_instr_bin_functor(atom!("rem"), arena, at_1, at_2, t) - } - &Instruction::ATan2(ref at_1, ref at_2, t) => { - arith_instr_bin_functor(atom!("rem"), arena, at_1, at_2, t) - } - &Instruction::Gcd(ref at_1, ref at_2, t) => { - arith_instr_bin_functor(atom!("gcd"), arena, at_1, at_2, t) - } - &Instruction::Sign(ref at, t) => { - arith_instr_unary_functor(atom!("sign"), arena, at, t) - } - &Instruction::Cos(ref at, t) => { - arith_instr_unary_functor(atom!("cos"), arena, at, t) - } - &Instruction::Sin(ref at, t) => { - arith_instr_unary_functor(atom!("sin"), arena, at, t) - } - &Instruction::Tan(ref at, t) => { - arith_instr_unary_functor(atom!("tan"), arena, at, t) - } - &Instruction::Log(ref at, t) => { - arith_instr_unary_functor(atom!("log"), arena, at, t) - } - &Instruction::Exp(ref at, t) => { - arith_instr_unary_functor(atom!("exp"), arena, at, t) - } - &Instruction::ACos(ref at, t) => { - arith_instr_unary_functor(atom!("acos"), arena, at, t) - } - &Instruction::ASin(ref at, t) => { - arith_instr_unary_functor(atom!("asin"), arena, at, t) - } - &Instruction::ATan(ref at, t) => { - arith_instr_unary_functor(atom!("atan"), arena, at, t) - } - &Instruction::Sqrt(ref at, t) => { - arith_instr_unary_functor(atom!("sqrt"), arena, at, t) - } - &Instruction::Abs(ref at, t) => { - arith_instr_unary_functor(atom!("abs"), arena, at, t) - } - &Instruction::Float(ref at, t) => { - arith_instr_unary_functor(atom!("float"), arena, at, t) - } - &Instruction::Truncate(ref at, t) => { - arith_instr_unary_functor(atom!("truncate"), arena, at, t) - } - &Instruction::Round(ref at, t) => { - arith_instr_unary_functor(atom!("round"), arena, at, t) - } - &Instruction::Ceiling(ref at, t) => { - arith_instr_unary_functor(atom!("ceiling"), arena, at, t) - } - &Instruction::Floor(ref at, t) => { - arith_instr_unary_functor(atom!("floor"), arena, at, t) - } - &Instruction::FloatFractionalPart(ref at, t) => { - arith_instr_unary_functor(atom!("float_fractional_part"), arena, at, t) - } - &Instruction::FloatIntegerPart(ref at, t) => { - arith_instr_unary_functor(atom!("float_integer_part"), arena, at, t) - } - &Instruction::Neg(ref at, t) => arith_instr_unary_functor( - atom!("-"), - arena, - at, - t, - ), - &Instruction::Plus(ref at, t) => arith_instr_unary_functor( - atom!("+"), - arena, - at, - t, - ), - &Instruction::BitwiseComplement(ref at, t) => arith_instr_unary_functor( - atom!("\\"), - arena, - at, - t, - ), - &Instruction::IndexingCode(_) => { - // this case is covered in enqueue_functors, which - // should be called instead (to_functor is a private - // function for this reason). - vec![] - } - &Instruction::Allocate(num_frames) => { - functor!(atom!("allocate"), [fixnum(num_frames)]) - } - &Instruction::CallNamed(arity, name, ..) => { - functor!(atom!("call"), [atom_as_cell(name), fixnum(arity)]) - } - &Instruction::ExecuteNamed(arity, name, ..) => { - functor!(atom!("execute"), [atom_as_cell(name), fixnum(arity)]) - } - &Instruction::DefaultCallNamed(arity, name, ..) => { - functor!(atom!("call_default"), [atom_as_cell(name), fixnum(arity)]) - } - &Instruction::DefaultExecuteNamed(arity, name, ..) => { - functor!(atom!("execute_default"), [atom_as_cell(name), fixnum(arity)]) - } - &Instruction::CallN(arity) => { - functor!(atom!("call_n"), [fixnum(arity)]) - } - &Instruction::ExecuteN(arity) => { - functor!(atom!("execute_n"), [fixnum(arity)]) - } - &Instruction::DefaultCallN(arity) => { - functor!(atom!("call_default_n"), [fixnum(arity)]) - } - &Instruction::DefaultExecuteN(arity) => { - functor!(atom!("execute_default_n"), [fixnum(arity)]) - } - &Instruction::CallFastCallN(arity) => { - functor!(atom!("call_fast_call_n"), [fixnum(arity)]) - } - &Instruction::ExecuteFastCallN(arity) => { - functor!(atom!("execute_fast_call_n"), [fixnum(arity)]) - } - &Instruction::CallTermGreaterThan | - &Instruction::CallTermLessThan | - &Instruction::CallTermGreaterThanOrEqual | - &Instruction::CallTermLessThanOrEqual | - &Instruction::CallTermEqual | - &Instruction::CallTermNotEqual | - &Instruction::CallNumberGreaterThan(..) | - &Instruction::CallNumberLessThan(..) | - &Instruction::CallNumberGreaterThanOrEqual(..) | - &Instruction::CallNumberLessThanOrEqual(..) | - &Instruction::CallNumberEqual(..) | - &Instruction::CallNumberNotEqual(..) | - &Instruction::CallIs(..) | - &Instruction::CallAcyclicTerm | - &Instruction::CallArg | - &Instruction::CallCompare | - &Instruction::CallCopyTerm | - &Instruction::CallFunctor | - &Instruction::CallGround | - &Instruction::CallKeySort | - &Instruction::CallSort | - &Instruction::CallGetNumber(_) => { - let (name, arity) = self.to_name_and_arity(); - functor!(atom!("call"), [atom_as_cell(name), fixnum(arity)]) - } - // - &Instruction::ExecuteTermGreaterThan | - &Instruction::ExecuteTermLessThan | - &Instruction::ExecuteTermGreaterThanOrEqual | - &Instruction::ExecuteTermLessThanOrEqual | - &Instruction::ExecuteTermEqual | - &Instruction::ExecuteTermNotEqual | - &Instruction::ExecuteNumberGreaterThan(..) | - &Instruction::ExecuteNumberLessThan(..) | - &Instruction::ExecuteNumberGreaterThanOrEqual(..) | - &Instruction::ExecuteNumberLessThanOrEqual(..) | - &Instruction::ExecuteNumberEqual(..) | - &Instruction::ExecuteNumberNotEqual(..) | - &Instruction::ExecuteAcyclicTerm | - &Instruction::ExecuteArg | - &Instruction::ExecuteCompare | - &Instruction::ExecuteCopyTerm | - &Instruction::ExecuteFunctor | - &Instruction::ExecuteGround | - &Instruction::ExecuteIs(..) | - &Instruction::ExecuteKeySort | - &Instruction::ExecuteSort | - &Instruction::ExecuteGetNumber(_) => { - let (name, arity) = self.to_name_and_arity(); - functor!(atom!("execute"), [atom_as_cell(name), fixnum(arity)]) - } - // - &Instruction::DefaultCallTermGreaterThan | - &Instruction::DefaultCallTermLessThan | - &Instruction::DefaultCallTermGreaterThanOrEqual | - &Instruction::DefaultCallTermLessThanOrEqual | - &Instruction::DefaultCallTermEqual | - &Instruction::DefaultCallTermNotEqual | - &Instruction::DefaultCallNumberGreaterThan(..) | - &Instruction::DefaultCallNumberLessThan(..) | - &Instruction::DefaultCallNumberGreaterThanOrEqual(..) | - &Instruction::DefaultCallNumberLessThanOrEqual(..) | - &Instruction::DefaultCallNumberEqual(..) | - &Instruction::DefaultCallNumberNotEqual(..) | - &Instruction::DefaultCallAcyclicTerm | - &Instruction::DefaultCallArg | - &Instruction::DefaultCallCompare | - &Instruction::DefaultCallCopyTerm | - &Instruction::DefaultCallFunctor | - &Instruction::DefaultCallGround | - &Instruction::DefaultCallIs(..) | - &Instruction::DefaultCallKeySort | - &Instruction::DefaultCallSort | - &Instruction::DefaultCallGetNumber(_) => { - let (name, arity) = self.to_name_and_arity(); - functor!(atom!("call_default"), [atom_as_cell(name), fixnum(arity)]) - } - // - &Instruction::DefaultExecuteTermGreaterThan | - &Instruction::DefaultExecuteTermLessThan | - &Instruction::DefaultExecuteTermGreaterThanOrEqual | - &Instruction::DefaultExecuteTermLessThanOrEqual | - &Instruction::DefaultExecuteTermEqual | - &Instruction::DefaultExecuteTermNotEqual | - &Instruction::DefaultExecuteNumberGreaterThan(..) | - &Instruction::DefaultExecuteNumberLessThan(..) | - &Instruction::DefaultExecuteNumberGreaterThanOrEqual(..) | - &Instruction::DefaultExecuteNumberLessThanOrEqual(..) | - &Instruction::DefaultExecuteNumberEqual(..) | - &Instruction::DefaultExecuteNumberNotEqual(..) | - &Instruction::DefaultExecuteAcyclicTerm | - &Instruction::DefaultExecuteArg | - &Instruction::DefaultExecuteCompare | - &Instruction::DefaultExecuteCopyTerm | - &Instruction::DefaultExecuteFunctor | - &Instruction::DefaultExecuteGround | - &Instruction::DefaultExecuteIs(..) | - &Instruction::DefaultExecuteKeySort | - &Instruction::DefaultExecuteSort | - &Instruction::DefaultExecuteGetNumber(_) => { - let (name, arity) = self.to_name_and_arity(); - functor!(atom!("execute_default"), [atom_as_cell(name), fixnum(arity)]) - } - &Instruction::CallIsAtom(r) | - &Instruction::CallIsAtomic(r) | - &Instruction::CallIsCompound(r) | - &Instruction::CallIsInteger(r) | - &Instruction::CallIsNumber(r) | - &Instruction::CallIsRational(r) | - &Instruction::CallIsFloat(r) | - &Instruction::CallIsNonVar(r) | - &Instruction::CallIsVar(r) => { - let (name, arity) = self.to_name_and_arity(); - let rt_stub = reg_type_into_functor(r); - - functor!(atom!("call"), [atom_as_cell(name), fixnum(arity), functor(rt_stub)]) - } - &Instruction::ExecuteIsAtom(r) | - &Instruction::ExecuteIsAtomic(r) | - &Instruction::ExecuteIsCompound(r) | - &Instruction::ExecuteIsInteger(r) | - &Instruction::ExecuteIsNumber(r) | - &Instruction::ExecuteIsRational(r) | - &Instruction::ExecuteIsFloat(r) | - &Instruction::ExecuteIsNonVar(r) | - &Instruction::ExecuteIsVar(r) => { - let (name, arity) = self.to_name_and_arity(); - let rt_stub = reg_type_into_functor(r); - - functor!(atom!("execute"), [atom_as_cell(name), fixnum(arity), functor(rt_stub)]) - } - // - &Instruction::CallAtomChars | - &Instruction::CallAtomCodes | - &Instruction::CallAtomLength | - &Instruction::CallBindFromRegister | - &Instruction::CallContinuation | - &Instruction::CallCharCode | - &Instruction::CallCharType | - &Instruction::CallCharsToNumber | - &Instruction::CallCodesToNumber | - &Instruction::CallCopyTermWithoutAttrVars | - &Instruction::CallCheckCutPoint | - &Instruction::CallClose | - &Instruction::CallCopyToLiftedHeap | - &Instruction::CallCreatePartialString | - &Instruction::CallCurrentHostname | - &Instruction::CallCurrentInput | - &Instruction::CallCurrentOutput | - &Instruction::CallDirectoryFiles | - &Instruction::CallFileSize | - &Instruction::CallFileExists | - &Instruction::CallDirectoryExists | - &Instruction::CallDirectorySeparator | - &Instruction::CallMakeDirectory | - &Instruction::CallMakeDirectoryPath | - &Instruction::CallDeleteFile | - &Instruction::CallRenameFile | - &Instruction::CallFileCopy | - &Instruction::CallWorkingDirectory | - &Instruction::CallDeleteDirectory | - &Instruction::CallPathCanonical | - &Instruction::CallFileTime | - &Instruction::CallDynamicModuleResolution(..) | - &Instruction::CallPrepareCallClause(..) | - &Instruction::CallCompileInlineOrExpandedGoal | - &Instruction::CallIsExpandedOrInlined | - &Instruction::CallGetClauseP | - &Instruction::CallInvokeClauseAtP | - &Instruction::CallGetFromAttributedVarList | - &Instruction::CallPutToAttributedVarList | - &Instruction::CallDeleteFromAttributedVarList | - &Instruction::CallDeleteAllAttributesFromVar | - &Instruction::CallUnattributedVar | - &Instruction::CallGetDBRefs | - &Instruction::CallKeySortWithConstantVarOrdering | - &Instruction::CallInferenceLimitExceeded | - &Instruction::CallFetchGlobalVar | - &Instruction::CallFirstStream | - &Instruction::CallFlushOutput | - &Instruction::CallGetByte | - &Instruction::CallGetChar | - &Instruction::CallGetNChars | - &Instruction::CallGetCode | - &Instruction::CallGetSingleChar | - &Instruction::CallTruncateIfNoLiftedHeapGrowthDiff | - &Instruction::CallTruncateIfNoLiftedHeapGrowth | - &Instruction::CallGetAttributedVariableList | - &Instruction::CallGetAttrVarQueueDelimiter | - &Instruction::CallGetAttrVarQueueBeyond | - &Instruction::CallGetBValue | - &Instruction::CallGetContinuationChunk | - &Instruction::CallGetNextOpDBRef | - &Instruction::CallLookupDBRef | - &Instruction::CallIsPartialString | - &Instruction::CallHalt | - &Instruction::CallGetLiftedHeapFromOffset | - &Instruction::CallGetLiftedHeapFromOffsetDiff | - &Instruction::CallGetSCCCleaner | - &Instruction::CallHeadIsDynamic | - &Instruction::CallInstallSCCCleaner | - &Instruction::CallInstallInferenceCounter | - &Instruction::CallInferenceCount | - &Instruction::CallLiftedHeapLength | - &Instruction::CallLoadLibraryAsStream | - &Instruction::CallModuleExists | - &Instruction::CallNextEP | - &Instruction::CallNoSuchPredicate | - &Instruction::CallNumberToChars | - &Instruction::CallNumberToCodes | - &Instruction::CallOpDeclaration | - &Instruction::CallOpen | - &Instruction::CallSetStreamOptions | - &Instruction::CallNextStream | - &Instruction::CallPartialStringTail | - &Instruction::CallPeekByte | - &Instruction::CallPeekChar | - &Instruction::CallPeekCode | - &Instruction::CallPointsToContinuationResetMarker | - &Instruction::CallPutByte | - &Instruction::CallPutChar | - &Instruction::CallPutChars | - &Instruction::CallPutCode | - &Instruction::CallReadQueryTerm | - &Instruction::CallReadTerm | - &Instruction::CallRedoAttrVarBinding | - &Instruction::CallRemoveCallPolicyCheck | - &Instruction::CallRemoveInferenceCounter | - &Instruction::CallResetContinuationMarker | - &Instruction::CallRestoreCutPolicy | - &Instruction::CallSetCutPoint(..) | - &Instruction::CallSetInput | - &Instruction::CallSetOutput | - &Instruction::CallStoreBacktrackableGlobalVar | - &Instruction::CallStoreGlobalVar | - &Instruction::CallStreamProperty | - &Instruction::CallSetStreamPosition | - &Instruction::CallInferenceLevel | - &Instruction::CallCleanUpBlock | - &Instruction::CallFail | - &Instruction::CallGetBall | - &Instruction::CallGetCurrentBlock | - &Instruction::CallGetCurrentSCCBlock | - &Instruction::CallGetCutPoint | - &Instruction::CallGetDoubleQuotes | - &Instruction::CallGetUnknown | - &Instruction::CallInstallNewBlock | - &Instruction::CallRandomInteger | - &Instruction::CallMaybe | - &Instruction::CallCpuNow | - &Instruction::CallDeterministicLengthRundown | - &Instruction::CallHttpOpen | - &Instruction::CallHttpListen | - &Instruction::CallHttpAccept | - &Instruction::CallHttpAnswer | - &Instruction::CallLoadForeignLib | - &Instruction::CallForeignCall | - &Instruction::CallDefineForeignStruct | - &Instruction::CallFfiAllocate | - &Instruction::CallFfiReadPtr | - &Instruction::CallFfiDeallocate | - &Instruction::CallJsEval | - &Instruction::CallPredicateDefined | - &Instruction::CallStripModule | - &Instruction::CallCurrentTime | - &Instruction::CallQuotedToken | - &Instruction::CallReadFromChars | - &Instruction::CallReadTermFromChars | - &Instruction::CallResetBlock | - &Instruction::CallResetSCCBlock | - &Instruction::CallReturnFromVerifyAttr | - &Instruction::CallSetBall | - &Instruction::CallPushBallStack | - &Instruction::CallPopBallStack | - &Instruction::CallPopFromBallStack | - &Instruction::CallSetCutPointByDefault(..) | - &Instruction::CallSetDoubleQuotes | - &Instruction::CallSetUnknown | - &Instruction::CallSetSeed | - &Instruction::CallSkipMaxList | - &Instruction::CallSleep | - &Instruction::CallSocketClientOpen | - &Instruction::CallSocketServerOpen | - &Instruction::CallSocketServerAccept | - &Instruction::CallSocketServerClose | - &Instruction::CallTLSAcceptClient | - &Instruction::CallTLSClientConnect | - &Instruction::CallSucceed | - &Instruction::CallTermAttributedVariables | - &Instruction::CallTermVariables | - &Instruction::CallTermVariablesUnderMaxDepth | - &Instruction::CallTruncateLiftedHeapTo | - &Instruction::CallUnifyWithOccursCheck | - &Instruction::CallUnwindEnvironments | - &Instruction::CallUnwindStack | - &Instruction::CallWAMInstructions | - &Instruction::CallInlinedInstructions | - &Instruction::CallWriteTerm | - &Instruction::CallWriteTermToChars | - &Instruction::CallScryerPrologVersion | - &Instruction::CallCryptoRandomByte | - &Instruction::CallCryptoDataHash | - &Instruction::CallCryptoHMAC | - &Instruction::CallCryptoDataHKDF | - &Instruction::CallCryptoPasswordHash | - &Instruction::CallCryptoCurveScalarMult | - &Instruction::CallCurve25519ScalarMult | - &Instruction::CallFirstNonOctet | - &Instruction::CallLoadHTML | - &Instruction::CallLoadXML | - &Instruction::CallGetEnv | - &Instruction::CallSetEnv | - &Instruction::CallUnsetEnv | - &Instruction::CallShell | - &Instruction::CallProcessCreate | - &Instruction::CallProcessId | - &Instruction::CallProcessWait | - &Instruction::CallProcessKill | - &Instruction::CallProcessRelease | - &Instruction::CallPid | - &Instruction::CallCharsBase64 | - &Instruction::CallDevourWhitespace | - &Instruction::CallIsSTOEnabled | - &Instruction::CallSetSTOAsUnify | - &Instruction::CallSetNSTOAsUnify | - &Instruction::CallSetSTOWithErrorAsUnify | - &Instruction::CallHomeDirectory | - &Instruction::CallDebugHook | - &Instruction::CallAddDiscontiguousPredicate | - &Instruction::CallAddDynamicPredicate | - &Instruction::CallAddMultifilePredicate | - &Instruction::CallAddGoalExpansionClause | - &Instruction::CallAddTermExpansionClause | - &Instruction::CallAddInSituFilenameModule | - &Instruction::CallClauseToEvacuable | - &Instruction::CallScopedClauseToEvacuable | - &Instruction::CallConcludeLoad | - &Instruction::CallDeclareModule | - &Instruction::CallLoadCompiledLibrary | - &Instruction::CallLoadContextSource | - &Instruction::CallLoadContextFile | - &Instruction::CallLoadContextDirectory | - &Instruction::CallLoadContextModule | - &Instruction::CallLoadContextStream | - &Instruction::CallPopLoadContext | - &Instruction::CallPopLoadStatePayload | - &Instruction::CallPushLoadContext | - &Instruction::CallPushLoadStatePayload | - &Instruction::CallUseModule | - &Instruction::CallBuiltInProperty | - &Instruction::CallMetaPredicateProperty | - &Instruction::CallMultifileProperty | - &Instruction::CallDiscontiguousProperty | - &Instruction::CallDynamicProperty | - &Instruction::CallAbolishClause | - &Instruction::CallAsserta | - &Instruction::CallAssertz | - &Instruction::CallRetract | - &Instruction::CallIsConsistentWithTermQueue | - &Instruction::CallFlushTermQueue | - &Instruction::CallRemoveModuleExports | - &Instruction::CallAddNonCountedBacktracking | - &Instruction::CallPopCount | - &Instruction::CallArgv | - &Instruction::CallEd25519SignRaw | - &Instruction::CallEd25519VerifyRaw | - &Instruction::CallEd25519SeedToPublicKey => { - let (name, arity) = self.to_name_and_arity(); - functor!(atom!("call"), [atom_as_cell(name), fixnum(arity)]) - } - // - #[cfg(feature = "crypto-full")] - &Instruction::CallCryptoDataEncrypt | - &Instruction::CallCryptoDataDecrypt => { - let (name, arity) = self.to_name_and_arity(); - functor!(atom!("call"), [atom_as_cell(name), fixnum(arity)]) - } - // - &Instruction::CallBeta | - &Instruction::CallBetaI | - &Instruction::CallInvBetaI | - &Instruction::CallGamma | - &Instruction::CallGammP | - &Instruction::CallGammQ | - &Instruction::CallInvGammP | - &Instruction::CallLnGamma | - &Instruction::CallErf | - &Instruction::CallErfc | - &Instruction::CallInvErf | - &Instruction::CallInvErfc => { - let (name, arity) = self.to_name_and_arity(); - functor!(atom!("call"), [atom_as_cell(name), fixnum(arity)]) - } - &Instruction::ExecuteAtomChars | - &Instruction::ExecuteAtomCodes | - &Instruction::ExecuteAtomLength | - &Instruction::ExecuteBindFromRegister | - &Instruction::ExecuteContinuation | - &Instruction::ExecuteCharCode | - &Instruction::ExecuteCharType | - &Instruction::ExecuteCharsToNumber | - &Instruction::ExecuteCodesToNumber | - &Instruction::ExecuteCopyTermWithoutAttrVars | - &Instruction::ExecuteCheckCutPoint | - &Instruction::ExecuteClose | - &Instruction::ExecuteCopyToLiftedHeap | - &Instruction::ExecuteCreatePartialString | - &Instruction::ExecuteCurrentHostname | - &Instruction::ExecuteCurrentInput | - &Instruction::ExecuteCurrentOutput | - &Instruction::ExecuteDirectoryFiles | - &Instruction::ExecuteFileSize | - &Instruction::ExecuteFileExists | - &Instruction::ExecuteDirectoryExists | - &Instruction::ExecuteDirectorySeparator | - &Instruction::ExecuteMakeDirectory | - &Instruction::ExecuteMakeDirectoryPath | - &Instruction::ExecuteDeleteFile | - &Instruction::ExecuteRenameFile | - &Instruction::ExecuteFileCopy | - &Instruction::ExecuteWorkingDirectory | - &Instruction::ExecuteDeleteDirectory | - &Instruction::ExecutePathCanonical | - &Instruction::ExecuteFileTime | - &Instruction::ExecuteDynamicModuleResolution(..) | - &Instruction::ExecutePrepareCallClause(..) | - &Instruction::ExecuteCompileInlineOrExpandedGoal | - &Instruction::ExecuteIsExpandedOrInlined | - &Instruction::ExecuteGetClauseP | - &Instruction::ExecuteInvokeClauseAtP | - &Instruction::ExecuteGetFromAttributedVarList | - &Instruction::ExecutePutToAttributedVarList | - &Instruction::ExecuteDeleteFromAttributedVarList | - &Instruction::ExecuteDeleteAllAttributesFromVar | - &Instruction::ExecuteUnattributedVar | - &Instruction::ExecuteGetDBRefs | - &Instruction::ExecuteKeySortWithConstantVarOrdering | - &Instruction::ExecuteInferenceLimitExceeded | - &Instruction::ExecuteFetchGlobalVar | - &Instruction::ExecuteFirstStream | - &Instruction::ExecuteFlushOutput | - &Instruction::ExecuteGetByte | - &Instruction::ExecuteGetChar | - &Instruction::ExecuteGetNChars | - &Instruction::ExecuteGetCode | - &Instruction::ExecuteGetSingleChar | - &Instruction::ExecuteTruncateIfNoLiftedHeapGrowthDiff | - &Instruction::ExecuteTruncateIfNoLiftedHeapGrowth | - &Instruction::ExecuteGetAttributedVariableList | - &Instruction::ExecuteGetAttrVarQueueDelimiter | - &Instruction::ExecuteGetAttrVarQueueBeyond | - &Instruction::ExecuteGetBValue | - &Instruction::ExecuteGetContinuationChunk | - &Instruction::ExecuteGetNextOpDBRef | - &Instruction::ExecuteLookupDBRef | - &Instruction::ExecuteIsPartialString | - &Instruction::ExecuteHalt | - &Instruction::ExecuteGetLiftedHeapFromOffset | - &Instruction::ExecuteGetLiftedHeapFromOffsetDiff | - &Instruction::ExecuteGetSCCCleaner | - &Instruction::ExecuteHeadIsDynamic | - &Instruction::ExecuteInstallSCCCleaner | - &Instruction::ExecuteInstallInferenceCounter | - &Instruction::ExecuteInferenceCount | - &Instruction::ExecuteLiftedHeapLength | - &Instruction::ExecuteLoadLibraryAsStream | - &Instruction::ExecuteModuleExists | - &Instruction::ExecuteNextEP | - &Instruction::ExecuteNoSuchPredicate | - &Instruction::ExecuteNumberToChars | - &Instruction::ExecuteNumberToCodes | - &Instruction::ExecuteOpDeclaration | - &Instruction::ExecuteOpen | - &Instruction::ExecuteSetStreamOptions | - &Instruction::ExecuteNextStream | - &Instruction::ExecutePartialStringTail | - &Instruction::ExecutePeekByte | - &Instruction::ExecutePeekChar | - &Instruction::ExecutePeekCode | - &Instruction::ExecutePointsToContinuationResetMarker | - &Instruction::ExecutePutByte | - &Instruction::ExecutePutChar | - &Instruction::ExecutePutChars | - &Instruction::ExecutePutCode | - &Instruction::ExecuteReadQueryTerm | - &Instruction::ExecuteReadTerm | - &Instruction::ExecuteRedoAttrVarBinding | - &Instruction::ExecuteRemoveCallPolicyCheck | - &Instruction::ExecuteRemoveInferenceCounter | - &Instruction::ExecuteResetContinuationMarker | - &Instruction::ExecuteRestoreCutPolicy | - &Instruction::ExecuteSetCutPoint(_) | - &Instruction::ExecuteSetInput | - &Instruction::ExecuteSetOutput | - &Instruction::ExecuteStoreBacktrackableGlobalVar | - &Instruction::ExecuteStoreGlobalVar | - &Instruction::ExecuteStreamProperty | - &Instruction::ExecuteSetStreamPosition | - &Instruction::ExecuteInferenceLevel | - &Instruction::ExecuteCleanUpBlock | - &Instruction::ExecuteFail | - &Instruction::ExecuteGetBall | - &Instruction::ExecuteGetCurrentBlock | - &Instruction::ExecuteGetCurrentSCCBlock | - &Instruction::ExecuteGetCutPoint | - &Instruction::ExecuteGetDoubleQuotes | - &Instruction::ExecuteGetUnknown | - &Instruction::ExecuteInstallNewBlock | - &Instruction::ExecuteRandomInteger | - &Instruction::ExecuteMaybe | - &Instruction::ExecuteCpuNow | - &Instruction::ExecuteDeterministicLengthRundown | - &Instruction::ExecuteHttpOpen | - &Instruction::ExecuteHttpListen | - &Instruction::ExecuteHttpAccept | - &Instruction::ExecuteHttpAnswer | - &Instruction::ExecuteLoadForeignLib | - &Instruction::ExecuteForeignCall | - &Instruction::ExecuteDefineForeignStruct | - &Instruction::ExecuteFfiAllocate | - &Instruction::ExecuteFfiReadPtr | - &Instruction::ExecuteFfiDeallocate | - &Instruction::ExecuteJsEval | - &Instruction::ExecutePredicateDefined | - &Instruction::ExecuteStripModule | - &Instruction::ExecuteCurrentTime | - &Instruction::ExecuteQuotedToken | - &Instruction::ExecuteReadFromChars | - &Instruction::ExecuteReadTermFromChars | - &Instruction::ExecuteResetBlock | - &Instruction::ExecuteResetSCCBlock | - &Instruction::ExecuteReturnFromVerifyAttr | - &Instruction::ExecuteSetBall | - &Instruction::ExecutePushBallStack | - &Instruction::ExecutePopBallStack | - &Instruction::ExecutePopFromBallStack | - &Instruction::ExecuteSetCutPointByDefault(_) | - &Instruction::ExecuteSetDoubleQuotes | - &Instruction::ExecuteSetUnknown | - &Instruction::ExecuteSetSeed | - &Instruction::ExecuteSkipMaxList | - &Instruction::ExecuteSleep | - &Instruction::ExecuteSocketClientOpen | - &Instruction::ExecuteSocketServerOpen | - &Instruction::ExecuteSocketServerAccept | - &Instruction::ExecuteSocketServerClose | - &Instruction::ExecuteTLSAcceptClient | - &Instruction::ExecuteTLSClientConnect | - &Instruction::ExecuteSucceed | - &Instruction::ExecuteTermAttributedVariables | - &Instruction::ExecuteTermVariables | - &Instruction::ExecuteTermVariablesUnderMaxDepth | - &Instruction::ExecuteTruncateLiftedHeapTo | - &Instruction::ExecuteUnifyWithOccursCheck | - &Instruction::ExecuteUnwindEnvironments | - &Instruction::ExecuteUnwindStack | - &Instruction::ExecuteWAMInstructions | - &Instruction::ExecuteInlinedInstructions | - &Instruction::ExecuteWriteTerm | - &Instruction::ExecuteWriteTermToChars | - &Instruction::ExecuteScryerPrologVersion | - &Instruction::ExecuteCryptoRandomByte | - &Instruction::ExecuteCryptoDataHash | - &Instruction::ExecuteCryptoHMAC | - &Instruction::ExecuteCryptoDataHKDF | - &Instruction::ExecuteCryptoPasswordHash | - &Instruction::ExecuteCryptoCurveScalarMult | - &Instruction::ExecuteCurve25519ScalarMult | - &Instruction::ExecuteFirstNonOctet | - &Instruction::ExecuteLoadHTML | - &Instruction::ExecuteLoadXML | - &Instruction::ExecuteGetEnv | - &Instruction::ExecuteSetEnv | - &Instruction::ExecuteUnsetEnv | - &Instruction::ExecuteShell | - &Instruction::ExecuteProcessCreate | - &Instruction::ExecuteProcessId | - &Instruction::ExecuteProcessWait | - &Instruction::ExecuteProcessKill | - &Instruction::ExecuteProcessRelease | - &Instruction::ExecutePid | - &Instruction::ExecuteCharsBase64 | - &Instruction::ExecuteDevourWhitespace | - &Instruction::ExecuteIsSTOEnabled | - &Instruction::ExecuteSetSTOAsUnify | - &Instruction::ExecuteSetNSTOAsUnify | - &Instruction::ExecuteSetSTOWithErrorAsUnify | - &Instruction::ExecuteHomeDirectory | - &Instruction::ExecuteDebugHook | - &Instruction::ExecuteAddDiscontiguousPredicate | - &Instruction::ExecuteAddDynamicPredicate | - &Instruction::ExecuteAddMultifilePredicate | - &Instruction::ExecuteAddGoalExpansionClause | - &Instruction::ExecuteAddTermExpansionClause | - &Instruction::ExecuteAddInSituFilenameModule | - &Instruction::ExecuteClauseToEvacuable | - &Instruction::ExecuteScopedClauseToEvacuable | - &Instruction::ExecuteConcludeLoad | - &Instruction::ExecuteDeclareModule | - &Instruction::ExecuteLoadCompiledLibrary | - &Instruction::ExecuteLoadContextSource | - &Instruction::ExecuteLoadContextFile | - &Instruction::ExecuteLoadContextDirectory | - &Instruction::ExecuteLoadContextModule | - &Instruction::ExecuteLoadContextStream | - &Instruction::ExecutePopLoadContext | - &Instruction::ExecutePopLoadStatePayload | - &Instruction::ExecutePushLoadContext | - &Instruction::ExecutePushLoadStatePayload | - &Instruction::ExecuteUseModule | - &Instruction::ExecuteBuiltInProperty | - &Instruction::ExecuteMetaPredicateProperty | - &Instruction::ExecuteMultifileProperty | - &Instruction::ExecuteDiscontiguousProperty | - &Instruction::ExecuteDynamicProperty | - &Instruction::ExecuteAbolishClause | - &Instruction::ExecuteAsserta | - &Instruction::ExecuteAssertz | - &Instruction::ExecuteRetract | - &Instruction::ExecuteIsConsistentWithTermQueue | - &Instruction::ExecuteFlushTermQueue | - &Instruction::ExecuteRemoveModuleExports | - &Instruction::ExecuteAddNonCountedBacktracking | - &Instruction::ExecutePopCount | - &Instruction::ExecuteArgv | - &Instruction::ExecuteEd25519SignRaw | - &Instruction::ExecuteEd25519VerifyRaw | - &Instruction::ExecuteEd25519SeedToPublicKey => { - let (name, arity) = self.to_name_and_arity(); - functor!(atom!("execute"), [atom_as_cell(name), fixnum(arity)]) - } - // - #[cfg(feature = "crypto-full")] - &Instruction::ExecuteCryptoDataEncrypt | - &Instruction::ExecuteCryptoDataDecrypt => { - let (name, arity) = self.to_name_and_arity(); - functor!(atom!("execute"), [atom_as_cell(name), fixnum(arity)]) - } - // - &Instruction::ExecuteBeta | - &Instruction::ExecuteBetaI | - &Instruction::ExecuteInvBetaI | - &Instruction::ExecuteGamma | - &Instruction::ExecuteGammP | - &Instruction::ExecuteGammQ | - &Instruction::ExecuteInvGammP | - &Instruction::ExecuteLnGamma | - &Instruction::ExecuteErf | - &Instruction::ExecuteErfc | - &Instruction::ExecuteInvErf | - &Instruction::ExecuteInvErfc => { - let (name, arity) = self.to_name_and_arity(); - functor!(atom!("execute"), [atom_as_cell(name), fixnum(arity)]) - } - &Instruction::Deallocate => { - functor!(atom!("deallocate")) - } - &Instruction::JmpByCall(offset) => { - functor!(atom!("jmp_by_call"), [fixnum(offset)]) - } - &Instruction::RevJmpBy(offset) => { - functor!(atom!("rev_jmp_by"), [fixnum(offset)]) - } - &Instruction::Proceed => { - functor!(atom!("proceed")) - } - &Instruction::GetConstant(lvl, lit, r) => { - let lvl_stub = lvl.into_functor(); - let rt_stub = reg_type_into_functor(r); - - functor!(atom!("get_constant"), [functor(lvl_stub), - cell(lit), - functor(rt_stub)]) - } - &Instruction::GetList(lvl, r) => { - let lvl_stub = lvl.into_functor(); - let rt_stub = reg_type_into_functor(r); - - functor!(atom!("get_list"), [functor(lvl_stub), functor(rt_stub)]) - } - &Instruction::GetPartialString(lvl, ref s, r) => { - let lvl_stub = lvl.into_functor(); - let rt_stub = reg_type_into_functor(r); - - functor!(atom!("get_partial_string"), [functor(lvl_stub), - string((s.to_string())), - functor(rt_stub)]) - } - &Instruction::GetStructure(lvl, name, arity, r) => { - let lvl_stub = lvl.into_functor(); - let rt_stub = reg_type_into_functor(r); - - functor!(atom!("get_structure"), [functor(lvl_stub), - atom_as_cell(name), - fixnum(arity), - functor(rt_stub)]) - } - &Instruction::GetValue(r, arg) => { - let rt_stub = reg_type_into_functor(r); - functor!(atom!("get_value"), [functor(rt_stub), - fixnum(arg)]) - } - &Instruction::GetVariable(r, arg) => { - let rt_stub = reg_type_into_functor(r); - functor!(atom!("get_variable"), [functor(rt_stub), fixnum(arg)]) - } - &Instruction::UnifyConstant(c) => { - functor!(atom!("unify_constant"), [cell(c)]) - } - &Instruction::UnifyLocalValue(r) => { - let rt_stub = reg_type_into_functor(r); - functor!(atom!("unify_local_value"), [functor(rt_stub)]) - } - &Instruction::UnifyVariable(r) => { - let rt_stub = reg_type_into_functor(r); - functor!(atom!("unify_variable"), [functor(rt_stub)]) - } - &Instruction::UnifyValue(r) => { - let rt_stub = reg_type_into_functor(r); - functor!(atom!("unify_value"), [functor(rt_stub)]) - } - &Instruction::UnifyVoid(vars) => { - functor!(atom!("unify_void"), [fixnum(vars)]) - } - &Instruction::PutUnsafeValue(norm, arg) => { - functor!(atom!("put_unsafe_value"), [fixnum(norm), fixnum(arg)]) - } - &Instruction::PutConstant(lvl, c, r) => { - let lvl_stub = lvl.into_functor(); - let rt_stub = reg_type_into_functor(r); - - functor!(atom!("put_constant"), [functor(rt_stub), cell(c), functor(lvl_stub)]) - } - &Instruction::PutList(lvl, r) => { - let lvl_stub = lvl.into_functor(); - let rt_stub = reg_type_into_functor(r); - - functor!(atom!("put_list"), [functor(lvl_stub), functor(rt_stub)]) - } - &Instruction::PutPartialString(lvl, ref s, r) => { - let lvl_stub = lvl.into_functor(); - let rt_stub = reg_type_into_functor(r); - - functor!(atom!("put_partial_string"), [functor(lvl_stub), - string((s.to_string())), - functor(rt_stub)]) - } - &Instruction::PutStructure(name, arity, r) => { - let rt_stub = reg_type_into_functor(r); - - functor!(atom!("put_structure"), [atom_as_cell(name), - fixnum(arity), - functor(rt_stub)]) - } - &Instruction::PutValue(r, arg) => { - let rt_stub = reg_type_into_functor(r); - - functor!(atom!("put_value"), [functor(rt_stub), - fixnum(arg)]) - } - &Instruction::PutVariable(r, arg) => { - let rt_stub = reg_type_into_functor(r); - - functor!(atom!("put_variable"), [functor(rt_stub), - fixnum(arg)]) - } - &Instruction::SetConstant(c) => { - functor!(atom!("set_constant"), [cell(c)]) - } - &Instruction::SetLocalValue(r) => { - let rt_stub = reg_type_into_functor(r); - functor!(atom!("set_local_value"), [functor(rt_stub)]) - } - &Instruction::SetVariable(r) => { - let rt_stub = reg_type_into_functor(r); - functor!(atom!("set_variable"), [functor(rt_stub)]) - } - &Instruction::SetValue(r) => { - let rt_stub = reg_type_into_functor(r); - functor!(atom!("set_value"), [functor(rt_stub)]) - } - &Instruction::SetVoid(vars) => { - functor!(atom!("set_void"), [fixnum(vars)]) - } - &Instruction::BreakFromDispatchLoop => { - functor!(atom!("$break_from_dispatch_loop")) - } - } - } - } - } -} - pub fn generate_instructions_rs() -> TokenStream { let input = InstructionTemplate::to_derive_input(); let mut instr_data = InstructionData::new(); @@ -3058,11 +1684,8 @@ pub fn generate_instructions_rs() -> TokenStream { }) .collect(); - let preface_tokens = generate_instruction_preface(); quote! { - #preface_tokens - #[allow(clippy::enum_variant_names)] #[derive(Clone, Debug)] pub enum CompareTerm { @@ -3079,21 +1702,6 @@ pub fn generate_instructions_rs() -> TokenStream { )* } - impl CompareNumber { - pub fn set_terms(&mut self, l_at_1: ArithmeticTerm, l_at_2: ArithmeticTerm) { - match self { - CompareNumber::NumberGreaterThan(ref mut at_1, ref mut at_2) | - CompareNumber::NumberLessThan(ref mut at_1, ref mut at_2) | - CompareNumber::NumberGreaterThanOrEqual(ref mut at_1, ref mut at_2) | - CompareNumber::NumberLessThanOrEqual(ref mut at_1, ref mut at_2) | - CompareNumber::NumberNotEqual(ref mut at_1, ref mut at_2) | - CompareNumber::NumberEqual(ref mut at_1, ref mut at_2) => { - *at_1 = l_at_1; - *at_2 = l_at_2; - } - } - } - } #[derive(Clone, Debug)] pub enum BuiltInClauseType { @@ -3219,24 +1827,6 @@ pub fn generate_instructions_rs() -> TokenStream { ) } - #[allow(dead_code)] - pub fn is_query_instr(&self) -> bool { - matches!(self, - &Instruction::GetVariable(..) | - &Instruction::PutConstant(..) | - &Instruction::PutList(..) | - &Instruction::PutPartialString(..) | - &Instruction::PutStructure(..) | - &Instruction::PutUnsafeValue(..) | - &Instruction::PutValue(..) | - &Instruction::PutVariable(..) | - &Instruction::SetConstant(..) | - &Instruction::SetLocalValue(..) | - &Instruction::SetVariable(..) | - &Instruction::SetValue(..) | - &Instruction::SetVoid(..) - ) - } } macro_rules! _instr { diff --git a/src/instructions.rs b/src/instructions.rs new file mode 100644 index 00000000..0467fecc --- /dev/null +++ b/src/instructions.rs @@ -0,0 +1,1406 @@ +use crate::arena::*; +use crate::arithmetic::*; +use crate::atom_table::*; +use crate::forms::*; +use crate::functor_macro::*; +use crate::machine::heap::*; +use crate::machine::machine_errors::MachineStub; +use crate::machine::machine_indices::CodeIndex; +use crate::parser::ast::*; +use crate::types::*; + +use fxhash::FxBuildHasher; +use indexmap::IndexMap; + +use std::collections::VecDeque; +use std::rc::Rc; + +include!(concat!(env!("OUT_DIR"), "/instructions.rs")); + +fn reg_type_into_functor(r: RegType) -> MachineStub { + match r { + RegType::Temp(r) => functor!(atom!("x"), [fixnum(r)]), + RegType::Perm(r) => functor!(atom!("y"), [fixnum(r)]), + } +} + +impl Level { + fn into_functor(self) -> MachineStub { + match self { + Level::Root => functor!(atom!("level"), [atom_as_cell((atom!("root")))]), + Level::Shallow => functor!(atom!("level"), [atom_as_cell((atom!("shallow")))]), + Level::Deep => functor!(atom!("level"), [atom_as_cell((atom!("deep")))]), + } + } +} + +impl ArithmeticTerm { + fn into_functor(self, arena: &mut Arena) -> MachineStub { + match self { + ArithmeticTerm::Reg(r) => reg_type_into_functor(r), + ArithmeticTerm::IntermReg(i) => { + functor!(atom!("x"), [fixnum(i)]) + } + ArithmeticTerm::Number(n) => { + functor!(atom!("number"), [number(n, arena)]) + } + } + } +} + +#[derive(Debug, Clone, Copy)] +pub enum NextOrFail { + Next(usize), + Fail(usize), +} + +impl Default for NextOrFail { + fn default() -> Self { + NextOrFail::Fail(0) + } +} + +impl NextOrFail { + #[inline] + pub fn is_next(&self) -> bool { + matches!(self, NextOrFail::Next(_)) + } +} + +#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] +pub enum Death { + Finite(usize), + #[default] + Infinity, +} + +#[derive(Clone, Copy, Debug)] +pub enum IndexedChoiceInstruction { + Retry(usize), + DefaultRetry(usize), + Trust(usize), + DefaultTrust(usize), + Try(usize), +} + +impl IndexedChoiceInstruction { + pub(crate) fn offset(&self) -> usize { + match *self { + IndexedChoiceInstruction::Retry(offset) => offset, + IndexedChoiceInstruction::Trust(offset) => offset, + IndexedChoiceInstruction::Try(offset) => offset, + IndexedChoiceInstruction::DefaultRetry(offset) => offset, + IndexedChoiceInstruction::DefaultTrust(offset) => offset, + } + } + + pub(crate) fn to_functor(self) -> MachineStub { + match self { + IndexedChoiceInstruction::Try(offset) => { + functor!(atom!("try"), [fixnum(offset)]) + } + IndexedChoiceInstruction::Trust(offset) => { + functor!(atom!("trust"), [fixnum(offset)]) + } + IndexedChoiceInstruction::Retry(offset) => { + functor!(atom!("retry"), [fixnum(offset)]) + } + IndexedChoiceInstruction::DefaultTrust(offset) => { + functor!(atom!("default_trust"), [fixnum(offset)]) + } + IndexedChoiceInstruction::DefaultRetry(offset) => { + functor!(atom!("default_retry"), [fixnum(offset)]) + } + } + } +} + +/// `IndexingInstruction` cf. page 110 of wambook. +#[allow(clippy::enum_variant_names)] +#[derive(Clone, Debug)] +pub enum IndexingInstruction { + // The first index is the optimal argument being indexed. + SwitchOnTerm( + usize, + IndexingCodePtr, + IndexingCodePtr, + IndexingCodePtr, + IndexingCodePtr, + ), + SwitchOnConstant(IndexMap), + SwitchOnStructure(IndexMap<(Atom, usize), IndexingCodePtr, FxBuildHasher>), +} + +#[derive(Debug, Clone, Copy)] +pub enum IndexingCodePtr { + External(usize), // the index points past the indexing instruction prelude. + DynamicExternal(usize), // an External index of a dynamic predicate, potentially invalidated by retraction. + Fail, + Internal(usize), // the index points into the indexing instruction prelude. +} + +impl IndexingCodePtr { + #[allow(dead_code)] + pub fn to_functor(self) -> MachineStub { + match self { + IndexingCodePtr::DynamicExternal(o) => functor!(atom!("dynamic_external"), [fixnum(o)]), + IndexingCodePtr::External(o) => functor!(atom!("external"), [fixnum(o)]), + IndexingCodePtr::Internal(o) => functor!(atom!("internal"), [fixnum(o)]), + IndexingCodePtr::Fail => { + functor!(atom!("fail")) + }, + } + } + + pub fn is_external(&self) -> bool { + matches!( + self, + IndexingCodePtr::External(_) | IndexingCodePtr::DynamicExternal(_) + ) + } +} + +impl IndexingInstruction { + pub fn to_functor(&self) -> MachineStub { + match self { + &IndexingInstruction::SwitchOnTerm(arg, vars, constants, lists, structures) => { + functor!( + atom!("switch_on_term"), + [ + fixnum(arg), + indexing_code_ptr(vars), + indexing_code_ptr(constants), + indexing_code_ptr(lists), + indexing_code_ptr(structures) + ] + ) + } + IndexingInstruction::SwitchOnConstant(constants) => { + variadic_functor( + atom!("switch_on_constants"), + 1, + constants.iter().map(|(c, ptr)| { + functor!( + atom!(":"), + [cell((*c)), indexing_code_ptr((*ptr))] + ) + }), + ) + } + IndexingInstruction::SwitchOnStructure(structures) => { + variadic_functor( + atom!("switch_on_structure"), + 1, + structures.iter().map(|((name, arity), ptr)| { + functor!( + atom!(":"), + [functor((atom!("/")), [atom_as_cell(name), fixnum((*arity))]), + indexing_code_ptr((*ptr))] + ) + }), + ) + } + } + } +} + +/// A `Line` is an instruction (cf. page 98 of wambook). +#[derive(Clone, Debug)] +pub enum IndexingLine { + Indexing(IndexingInstruction), + IndexedChoice(VecDeque), + DynamicIndexedChoice(VecDeque), +} + +impl From for IndexingLine { + #[inline] + fn from(instr: IndexingInstruction) -> Self { + IndexingLine::Indexing(instr) + } +} + +impl From> for IndexingLine { + #[inline] + fn from(instrs: VecDeque) -> Self { + IndexingLine::IndexedChoice(instrs.into_iter().collect()) + } +} + +fn arith_instr_unary_functor( + name: Atom, + arena: &mut Arena, + at: &ArithmeticTerm, + t: usize, +) -> MachineStub { + let at_stub = at.into_functor(arena); + functor!(name, [functor(at_stub), fixnum(t)]) +} + +fn arith_instr_bin_functor( + name: Atom, + arena: &mut Arena, + at_1: &ArithmeticTerm, + at_2: &ArithmeticTerm, + t: usize, +) -> MachineStub { + let at_1_stub = at_1.into_functor(arena); + let at_2_stub = at_2.into_functor(arena); + + functor!(name, [functor(at_1_stub), + functor(at_2_stub), + fixnum(t)]) +} + +pub type Code = Vec; +pub type CodeDeque = VecDeque; + +impl Instruction { + #[inline] + pub fn to_indexing_line_mut(&mut self) -> Option<&mut Vec> { + match self { + Instruction::IndexingCode(ref mut indexing_code) => Some(indexing_code), + _ => None, + } + } + + #[inline] + pub fn to_indexing_line(&self) -> Option<&Vec> { + match self { + Instruction::IndexingCode(ref indexing_code) => Some(indexing_code), + _ => None, + } + } + + pub fn enqueue_functors( + &self, + arena: &mut Arena, + functors: &mut Vec, + ) { + match self { + Instruction::IndexingCode(indexing_instrs) => { + for indexing_instr in indexing_instrs { + match indexing_instr { + IndexingLine::Indexing(indexing_instr) => { + let section = indexing_instr.to_functor(); + functors.push(section); + } + IndexingLine::IndexedChoice(indexed_choice_instrs) => { + for indexed_choice_instr in indexed_choice_instrs { + let section = indexed_choice_instr.to_functor(); + functors.push(section); + } + } + IndexingLine::DynamicIndexedChoice(indexed_choice_instrs) => { + for indexed_choice_instr in indexed_choice_instrs { + let section = functor!(atom!("dynamic"), + [fixnum((*indexed_choice_instr))]); + functors.push(section); + } + } + } + } + } + instr => functors.push(instr.to_functor(arena)), + } + } + + fn to_functor(&self, arena: &mut Arena) -> MachineStub { + match self { + &Instruction::RunVerifyAttr => { + functor!(atom!("run_verify_attr")) + } + &Instruction::DynamicElse(birth, death, next_or_fail) => { + match (death, next_or_fail) { + (Death::Infinity, NextOrFail::Next(i)) => { + functor!( + atom!("dynamic_else"), + [fixnum(birth), atom_as_cell((atom!("inf"))), fixnum(i)] + ) + } + (Death::Infinity, NextOrFail::Fail(i)) => { + functor!( + atom!("dynamic_else"), + [fixnum(birth), + atom_as_cell((atom!("inf"))), + functor((atom!("fail")), [fixnum(i)])] + ) + } + (Death::Finite(d), NextOrFail::Fail(i)) => { + functor!( + atom!("dynamic_else"), + [fixnum(birth), + fixnum(d), + functor((atom!("fail")), [fixnum(i)])] + ) + } + (Death::Finite(d), NextOrFail::Next(i)) => { + functor!(atom!("dynamic_else"), [fixnum(birth), fixnum(d), fixnum(i)]) + } + } + } + &Instruction::DynamicInternalElse(birth, death, next_or_fail) => { + match (death, next_or_fail) { + (Death::Infinity, NextOrFail::Next(i)) => { + functor!( + atom!("dynamic_internal_else"), + [fixnum(birth), atom_as_cell((atom!("inf"))), fixnum(i)] + ) + } + (Death::Infinity, NextOrFail::Fail(i)) => { + functor!( + atom!("dynamic_internal_else"), + [fixnum(birth), + atom_as_cell((atom!("inf"))), + functor((atom!("fail")), [fixnum(i)])] + ) + } + (Death::Finite(d), NextOrFail::Fail(i)) => { + functor!( + atom!("dynamic_internal_else"), + [fixnum(birth), + fixnum(d), + functor((atom!("fail")), [fixnum(i)])] + ) + } + (Death::Finite(d), NextOrFail::Next(i)) => { + functor!( + atom!("dynamic_internal_else"), + [fixnum(birth), fixnum(d), fixnum(i)] + ) + } + } + } + &Instruction::TryMeElse(offset) => { + functor!(atom!("try_me_else"), [fixnum(offset)]) + } + &Instruction::RetryMeElse(offset) => { + functor!(atom!("retry_me_else"), [fixnum(offset)]) + } + &Instruction::TrustMe(offset) => { + functor!(atom!("trust_me"), [fixnum(offset)]) + } + &Instruction::DefaultRetryMeElse(offset) => { + functor!(atom!("default_retry_me_else"), [fixnum(offset)]) + } + &Instruction::DefaultTrustMe(offset) => { + functor!(atom!("default_trust_me"), [fixnum(offset)]) + } + &Instruction::Cut(r) => { + let rt_stub = reg_type_into_functor(r); + functor!(atom!("cut"), [functor(rt_stub)]) + } + &Instruction::CutPrev(r) => { + let rt_stub = reg_type_into_functor(r); + functor!(atom!("cut_prev"), [functor(rt_stub)]) + } + &Instruction::GetLevel(r) => { + let rt_stub = reg_type_into_functor(r); + functor!(atom!("get_level"), [functor(rt_stub)]) + } + &Instruction::GetPrevLevel(r) => { + let rt_stub = reg_type_into_functor(r); + functor!(atom!("get_prev_level"), [functor(rt_stub)]) + } + &Instruction::GetCutPoint(r) => { + let rt_stub = reg_type_into_functor(r); + functor!(atom!("get_cut_point"), [functor(rt_stub)]) + } + &Instruction::NeckCut => { + functor!(atom!("neck_cut")) + } + &Instruction::Add(ref at_1, ref at_2, t) => { + arith_instr_bin_functor(atom!("add"), arena, at_1, at_2, t) + } + &Instruction::Sub(ref at_1, ref at_2, t) => { + arith_instr_bin_functor(atom!("sub"), arena, at_1, at_2, t) + } + &Instruction::Mul(ref at_1, ref at_2, t) => { + arith_instr_bin_functor(atom!("mul"), arena, at_1, at_2, t) + } + &Instruction::IntPow(ref at_1, ref at_2, t) => { + arith_instr_bin_functor(atom!("int_pow"), arena, at_1, at_2, t) + } + &Instruction::Pow(ref at_1, ref at_2, t) => { + arith_instr_bin_functor(atom!("pow"), arena, at_1, at_2, t) + } + &Instruction::IDiv(ref at_1, ref at_2, t) => { + arith_instr_bin_functor(atom!("idiv"), arena, at_1, at_2, t) + } + &Instruction::Max(ref at_1, ref at_2, t) => { + arith_instr_bin_functor(atom!("max"), arena, at_1, at_2, t) + } + &Instruction::Min(ref at_1, ref at_2, t) => { + arith_instr_bin_functor(atom!("min"), arena, at_1, at_2, t) + } + &Instruction::IntFloorDiv(ref at_1, ref at_2, t) => { + arith_instr_bin_functor(atom!("int_floor_div"), arena, at_1, at_2, t) + } + &Instruction::RDiv(ref at_1, ref at_2, t) => { + arith_instr_bin_functor(atom!("rdiv"), arena, at_1, at_2, t) + } + &Instruction::Div(ref at_1, ref at_2, t) => { + arith_instr_bin_functor(atom!("div"), arena, at_1, at_2, t) + } + &Instruction::Shl(ref at_1, ref at_2, t) => { + arith_instr_bin_functor(atom!("shl"), arena, at_1, at_2, t) + } + &Instruction::Shr(ref at_1, ref at_2, t) => { + arith_instr_bin_functor(atom!("shr"), arena, at_1, at_2, t) + } + &Instruction::Xor(ref at_1, ref at_2, t) => { + arith_instr_bin_functor(atom!("xor"), arena, at_1, at_2, t) + } + &Instruction::And(ref at_1, ref at_2, t) => { + arith_instr_bin_functor(atom!("and"), arena, at_1, at_2, t) + } + &Instruction::Or(ref at_1, ref at_2, t) => { + arith_instr_bin_functor(atom!("or"), arena, at_1, at_2, t) + } + &Instruction::Mod(ref at_1, ref at_2, t) => { + arith_instr_bin_functor(atom!("mod"), arena, at_1, at_2, t) + } + &Instruction::Rem(ref at_1, ref at_2, t) => { + arith_instr_bin_functor(atom!("rem"), arena, at_1, at_2, t) + } + &Instruction::ATan2(ref at_1, ref at_2, t) => { + arith_instr_bin_functor(atom!("rem"), arena, at_1, at_2, t) + } + &Instruction::Gcd(ref at_1, ref at_2, t) => { + arith_instr_bin_functor(atom!("gcd"), arena, at_1, at_2, t) + } + &Instruction::Sign(ref at, t) => { + arith_instr_unary_functor(atom!("sign"), arena, at, t) + } + &Instruction::Cos(ref at, t) => { + arith_instr_unary_functor(atom!("cos"), arena, at, t) + } + &Instruction::Sin(ref at, t) => { + arith_instr_unary_functor(atom!("sin"), arena, at, t) + } + &Instruction::Tan(ref at, t) => { + arith_instr_unary_functor(atom!("tan"), arena, at, t) + } + &Instruction::Log(ref at, t) => { + arith_instr_unary_functor(atom!("log"), arena, at, t) + } + &Instruction::Exp(ref at, t) => { + arith_instr_unary_functor(atom!("exp"), arena, at, t) + } + &Instruction::ACos(ref at, t) => { + arith_instr_unary_functor(atom!("acos"), arena, at, t) + } + &Instruction::ASin(ref at, t) => { + arith_instr_unary_functor(atom!("asin"), arena, at, t) + } + &Instruction::ATan(ref at, t) => { + arith_instr_unary_functor(atom!("atan"), arena, at, t) + } + &Instruction::Sqrt(ref at, t) => { + arith_instr_unary_functor(atom!("sqrt"), arena, at, t) + } + &Instruction::Abs(ref at, t) => { + arith_instr_unary_functor(atom!("abs"), arena, at, t) + } + &Instruction::Float(ref at, t) => { + arith_instr_unary_functor(atom!("float"), arena, at, t) + } + &Instruction::Truncate(ref at, t) => { + arith_instr_unary_functor(atom!("truncate"), arena, at, t) + } + &Instruction::Round(ref at, t) => { + arith_instr_unary_functor(atom!("round"), arena, at, t) + } + &Instruction::Ceiling(ref at, t) => { + arith_instr_unary_functor(atom!("ceiling"), arena, at, t) + } + &Instruction::Floor(ref at, t) => { + arith_instr_unary_functor(atom!("floor"), arena, at, t) + } + &Instruction::FloatFractionalPart(ref at, t) => { + arith_instr_unary_functor(atom!("float_fractional_part"), arena, at, t) + } + &Instruction::FloatIntegerPart(ref at, t) => { + arith_instr_unary_functor(atom!("float_integer_part"), arena, at, t) + } + &Instruction::Neg(ref at, t) => arith_instr_unary_functor( + atom!("-"), + arena, + at, + t, + ), + &Instruction::Plus(ref at, t) => arith_instr_unary_functor( + atom!("+"), + arena, + at, + t, + ), + &Instruction::BitwiseComplement(ref at, t) => arith_instr_unary_functor( + atom!("\\"), + arena, + at, + t, + ), + &Instruction::IndexingCode(_) => { + // this case is covered in enqueue_functors, which + // should be called instead (to_functor is a private + // function for this reason). + vec![] + } + &Instruction::Allocate(num_frames) => { + functor!(atom!("allocate"), [fixnum(num_frames)]) + } + &Instruction::CallNamed(arity, name, ..) => { + functor!(atom!("call"), [atom_as_cell(name), fixnum(arity)]) + } + &Instruction::ExecuteNamed(arity, name, ..) => { + functor!(atom!("execute"), [atom_as_cell(name), fixnum(arity)]) + } + &Instruction::DefaultCallNamed(arity, name, ..) => { + functor!(atom!("call_default"), [atom_as_cell(name), fixnum(arity)]) + } + &Instruction::DefaultExecuteNamed(arity, name, ..) => { + functor!(atom!("execute_default"), [atom_as_cell(name), fixnum(arity)]) + } + &Instruction::CallN(arity) => { + functor!(atom!("call_n"), [fixnum(arity)]) + } + &Instruction::ExecuteN(arity) => { + functor!(atom!("execute_n"), [fixnum(arity)]) + } + &Instruction::DefaultCallN(arity) => { + functor!(atom!("call_default_n"), [fixnum(arity)]) + } + &Instruction::DefaultExecuteN(arity) => { + functor!(atom!("execute_default_n"), [fixnum(arity)]) + } + &Instruction::CallFastCallN(arity) => { + functor!(atom!("call_fast_call_n"), [fixnum(arity)]) + } + &Instruction::ExecuteFastCallN(arity) => { + functor!(atom!("execute_fast_call_n"), [fixnum(arity)]) + } + &Instruction::CallTermGreaterThan | + &Instruction::CallTermLessThan | + &Instruction::CallTermGreaterThanOrEqual | + &Instruction::CallTermLessThanOrEqual | + &Instruction::CallTermEqual | + &Instruction::CallTermNotEqual | + &Instruction::CallNumberGreaterThan(..) | + &Instruction::CallNumberLessThan(..) | + &Instruction::CallNumberGreaterThanOrEqual(..) | + &Instruction::CallNumberLessThanOrEqual(..) | + &Instruction::CallNumberEqual(..) | + &Instruction::CallNumberNotEqual(..) | + &Instruction::CallIs(..) | + &Instruction::CallAcyclicTerm | + &Instruction::CallArg | + &Instruction::CallCompare | + &Instruction::CallCopyTerm | + &Instruction::CallFunctor | + &Instruction::CallGround | + &Instruction::CallKeySort | + &Instruction::CallSort | + &Instruction::CallGetNumber(_) => { + let (name, arity) = self.to_name_and_arity(); + functor!(atom!("call"), [atom_as_cell(name), fixnum(arity)]) + } + // + &Instruction::ExecuteTermGreaterThan | + &Instruction::ExecuteTermLessThan | + &Instruction::ExecuteTermGreaterThanOrEqual | + &Instruction::ExecuteTermLessThanOrEqual | + &Instruction::ExecuteTermEqual | + &Instruction::ExecuteTermNotEqual | + &Instruction::ExecuteNumberGreaterThan(..) | + &Instruction::ExecuteNumberLessThan(..) | + &Instruction::ExecuteNumberGreaterThanOrEqual(..) | + &Instruction::ExecuteNumberLessThanOrEqual(..) | + &Instruction::ExecuteNumberEqual(..) | + &Instruction::ExecuteNumberNotEqual(..) | + &Instruction::ExecuteAcyclicTerm | + &Instruction::ExecuteArg | + &Instruction::ExecuteCompare | + &Instruction::ExecuteCopyTerm | + &Instruction::ExecuteFunctor | + &Instruction::ExecuteGround | + &Instruction::ExecuteIs(..) | + &Instruction::ExecuteKeySort | + &Instruction::ExecuteSort | + &Instruction::ExecuteGetNumber(_) => { + let (name, arity) = self.to_name_and_arity(); + functor!(atom!("execute"), [atom_as_cell(name), fixnum(arity)]) + } + // + &Instruction::DefaultCallTermGreaterThan | + &Instruction::DefaultCallTermLessThan | + &Instruction::DefaultCallTermGreaterThanOrEqual | + &Instruction::DefaultCallTermLessThanOrEqual | + &Instruction::DefaultCallTermEqual | + &Instruction::DefaultCallTermNotEqual | + &Instruction::DefaultCallNumberGreaterThan(..) | + &Instruction::DefaultCallNumberLessThan(..) | + &Instruction::DefaultCallNumberGreaterThanOrEqual(..) | + &Instruction::DefaultCallNumberLessThanOrEqual(..) | + &Instruction::DefaultCallNumberEqual(..) | + &Instruction::DefaultCallNumberNotEqual(..) | + &Instruction::DefaultCallAcyclicTerm | + &Instruction::DefaultCallArg | + &Instruction::DefaultCallCompare | + &Instruction::DefaultCallCopyTerm | + &Instruction::DefaultCallFunctor | + &Instruction::DefaultCallGround | + &Instruction::DefaultCallIs(..) | + &Instruction::DefaultCallKeySort | + &Instruction::DefaultCallSort | + &Instruction::DefaultCallGetNumber(_) => { + let (name, arity) = self.to_name_and_arity(); + functor!(atom!("call_default"), [atom_as_cell(name), fixnum(arity)]) + } + // + &Instruction::DefaultExecuteTermGreaterThan | + &Instruction::DefaultExecuteTermLessThan | + &Instruction::DefaultExecuteTermGreaterThanOrEqual | + &Instruction::DefaultExecuteTermLessThanOrEqual | + &Instruction::DefaultExecuteTermEqual | + &Instruction::DefaultExecuteTermNotEqual | + &Instruction::DefaultExecuteNumberGreaterThan(..) | + &Instruction::DefaultExecuteNumberLessThan(..) | + &Instruction::DefaultExecuteNumberGreaterThanOrEqual(..) | + &Instruction::DefaultExecuteNumberLessThanOrEqual(..) | + &Instruction::DefaultExecuteNumberEqual(..) | + &Instruction::DefaultExecuteNumberNotEqual(..) | + &Instruction::DefaultExecuteAcyclicTerm | + &Instruction::DefaultExecuteArg | + &Instruction::DefaultExecuteCompare | + &Instruction::DefaultExecuteCopyTerm | + &Instruction::DefaultExecuteFunctor | + &Instruction::DefaultExecuteGround | + &Instruction::DefaultExecuteIs(..) | + &Instruction::DefaultExecuteKeySort | + &Instruction::DefaultExecuteSort | + &Instruction::DefaultExecuteGetNumber(_) => { + let (name, arity) = self.to_name_and_arity(); + functor!(atom!("execute_default"), [atom_as_cell(name), fixnum(arity)]) + } + &Instruction::CallIsAtom(r) | + &Instruction::CallIsAtomic(r) | + &Instruction::CallIsCompound(r) | + &Instruction::CallIsInteger(r) | + &Instruction::CallIsNumber(r) | + &Instruction::CallIsRational(r) | + &Instruction::CallIsFloat(r) | + &Instruction::CallIsNonVar(r) | + &Instruction::CallIsVar(r) => { + let (name, arity) = self.to_name_and_arity(); + let rt_stub = reg_type_into_functor(r); + + functor!(atom!("call"), [atom_as_cell(name), fixnum(arity), functor(rt_stub)]) + } + &Instruction::ExecuteIsAtom(r) | + &Instruction::ExecuteIsAtomic(r) | + &Instruction::ExecuteIsCompound(r) | + &Instruction::ExecuteIsInteger(r) | + &Instruction::ExecuteIsNumber(r) | + &Instruction::ExecuteIsRational(r) | + &Instruction::ExecuteIsFloat(r) | + &Instruction::ExecuteIsNonVar(r) | + &Instruction::ExecuteIsVar(r) => { + let (name, arity) = self.to_name_and_arity(); + let rt_stub = reg_type_into_functor(r); + + functor!(atom!("execute"), [atom_as_cell(name), fixnum(arity), functor(rt_stub)]) + } + // + &Instruction::CallAtomChars | + &Instruction::CallAtomCodes | + &Instruction::CallAtomLength | + &Instruction::CallBindFromRegister | + &Instruction::CallContinuation | + &Instruction::CallCharCode | + &Instruction::CallCharType | + &Instruction::CallCharsToNumber | + &Instruction::CallCodesToNumber | + &Instruction::CallCopyTermWithoutAttrVars | + &Instruction::CallCheckCutPoint | + &Instruction::CallClose | + &Instruction::CallCopyToLiftedHeap | + &Instruction::CallCreatePartialString | + &Instruction::CallCurrentHostname | + &Instruction::CallCurrentInput | + &Instruction::CallCurrentOutput | + &Instruction::CallDirectoryFiles | + &Instruction::CallFileSize | + &Instruction::CallFileExists | + &Instruction::CallDirectoryExists | + &Instruction::CallDirectorySeparator | + &Instruction::CallMakeDirectory | + &Instruction::CallMakeDirectoryPath | + &Instruction::CallDeleteFile | + &Instruction::CallRenameFile | + &Instruction::CallFileCopy | + &Instruction::CallWorkingDirectory | + &Instruction::CallDeleteDirectory | + &Instruction::CallPathCanonical | + &Instruction::CallFileTime | + &Instruction::CallDynamicModuleResolution(..) | + &Instruction::CallPrepareCallClause(..) | + &Instruction::CallCompileInlineOrExpandedGoal | + &Instruction::CallIsExpandedOrInlined | + &Instruction::CallGetClauseP | + &Instruction::CallInvokeClauseAtP | + &Instruction::CallGetFromAttributedVarList | + &Instruction::CallPutToAttributedVarList | + &Instruction::CallDeleteFromAttributedVarList | + &Instruction::CallDeleteAllAttributesFromVar | + &Instruction::CallUnattributedVar | + &Instruction::CallGetDBRefs | + &Instruction::CallKeySortWithConstantVarOrdering | + &Instruction::CallInferenceLimitExceeded | + &Instruction::CallFetchGlobalVar | + &Instruction::CallFirstStream | + &Instruction::CallFlushOutput | + &Instruction::CallGetByte | + &Instruction::CallGetChar | + &Instruction::CallGetNChars | + &Instruction::CallGetCode | + &Instruction::CallGetSingleChar | + &Instruction::CallTruncateIfNoLiftedHeapGrowthDiff | + &Instruction::CallTruncateIfNoLiftedHeapGrowth | + &Instruction::CallGetAttributedVariableList | + &Instruction::CallGetAttrVarQueueDelimiter | + &Instruction::CallGetAttrVarQueueBeyond | + &Instruction::CallGetBValue | + &Instruction::CallGetContinuationChunk | + &Instruction::CallGetNextOpDBRef | + &Instruction::CallLookupDBRef | + &Instruction::CallIsPartialString | + &Instruction::CallHalt | + &Instruction::CallGetLiftedHeapFromOffset | + &Instruction::CallGetLiftedHeapFromOffsetDiff | + &Instruction::CallGetSCCCleaner | + &Instruction::CallHeadIsDynamic | + &Instruction::CallInstallSCCCleaner | + &Instruction::CallInstallInferenceCounter | + &Instruction::CallInferenceCount | + &Instruction::CallLiftedHeapLength | + &Instruction::CallLoadLibraryAsStream | + &Instruction::CallModuleExists | + &Instruction::CallNextEP | + &Instruction::CallNoSuchPredicate | + &Instruction::CallNumberToChars | + &Instruction::CallNumberToCodes | + &Instruction::CallOpDeclaration | + &Instruction::CallOpen | + &Instruction::CallSetStreamOptions | + &Instruction::CallNextStream | + &Instruction::CallPartialStringTail | + &Instruction::CallPeekByte | + &Instruction::CallPeekChar | + &Instruction::CallPeekCode | + &Instruction::CallPointsToContinuationResetMarker | + &Instruction::CallPutByte | + &Instruction::CallPutChar | + &Instruction::CallPutChars | + &Instruction::CallPutCode | + &Instruction::CallReadQueryTerm | + &Instruction::CallReadTerm | + &Instruction::CallRedoAttrVarBinding | + &Instruction::CallRemoveCallPolicyCheck | + &Instruction::CallRemoveInferenceCounter | + &Instruction::CallResetContinuationMarker | + &Instruction::CallRestoreCutPolicy | + &Instruction::CallSetCutPoint(..) | + &Instruction::CallSetInput | + &Instruction::CallSetOutput | + &Instruction::CallStoreBacktrackableGlobalVar | + &Instruction::CallStoreGlobalVar | + &Instruction::CallStreamProperty | + &Instruction::CallSetStreamPosition | + &Instruction::CallInferenceLevel | + &Instruction::CallCleanUpBlock | + &Instruction::CallFail | + &Instruction::CallGetBall | + &Instruction::CallGetCurrentBlock | + &Instruction::CallGetCurrentSCCBlock | + &Instruction::CallGetCutPoint | + &Instruction::CallGetDoubleQuotes | + &Instruction::CallGetUnknown | + &Instruction::CallInstallNewBlock | + &Instruction::CallRandomInteger | + &Instruction::CallMaybe | + &Instruction::CallCpuNow | + &Instruction::CallDeterministicLengthRundown | + &Instruction::CallHttpOpen | + &Instruction::CallHttpListen | + &Instruction::CallHttpAccept | + &Instruction::CallHttpAnswer | + &Instruction::CallLoadForeignLib | + &Instruction::CallForeignCall | + &Instruction::CallDefineForeignStruct | + &Instruction::CallFfiAllocate | + &Instruction::CallFfiReadPtr | + &Instruction::CallFfiDeallocate | + &Instruction::CallJsEval | + &Instruction::CallPredicateDefined | + &Instruction::CallStripModule | + &Instruction::CallCurrentTime | + &Instruction::CallQuotedToken | + &Instruction::CallReadFromChars | + &Instruction::CallReadTermFromChars | + &Instruction::CallResetBlock | + &Instruction::CallResetSCCBlock | + &Instruction::CallReturnFromVerifyAttr | + &Instruction::CallSetBall | + &Instruction::CallPushBallStack | + &Instruction::CallPopBallStack | + &Instruction::CallPopFromBallStack | + &Instruction::CallSetCutPointByDefault(..) | + &Instruction::CallSetDoubleQuotes | + &Instruction::CallSetUnknown | + &Instruction::CallSetSeed | + &Instruction::CallSkipMaxList | + &Instruction::CallSleep | + &Instruction::CallSocketClientOpen | + &Instruction::CallSocketServerOpen | + &Instruction::CallSocketServerAccept | + &Instruction::CallSocketServerClose | + &Instruction::CallTLSAcceptClient | + &Instruction::CallTLSClientConnect | + &Instruction::CallSucceed | + &Instruction::CallTermAttributedVariables | + &Instruction::CallTermVariables | + &Instruction::CallTermVariablesUnderMaxDepth | + &Instruction::CallTruncateLiftedHeapTo | + &Instruction::CallUnifyWithOccursCheck | + &Instruction::CallUnwindEnvironments | + &Instruction::CallUnwindStack | + &Instruction::CallWAMInstructions | + &Instruction::CallInlinedInstructions | + &Instruction::CallWriteTerm | + &Instruction::CallWriteTermToChars | + &Instruction::CallScryerPrologVersion | + &Instruction::CallCryptoRandomByte | + &Instruction::CallCryptoDataHash | + &Instruction::CallCryptoHMAC | + &Instruction::CallCryptoDataHKDF | + &Instruction::CallCryptoPasswordHash | + &Instruction::CallCryptoCurveScalarMult | + &Instruction::CallCurve25519ScalarMult | + &Instruction::CallFirstNonOctet | + &Instruction::CallLoadHTML | + &Instruction::CallLoadXML | + &Instruction::CallGetEnv | + &Instruction::CallSetEnv | + &Instruction::CallUnsetEnv | + &Instruction::CallShell | + &Instruction::CallProcessCreate | + &Instruction::CallProcessId | + &Instruction::CallProcessWait | + &Instruction::CallProcessKill | + &Instruction::CallProcessRelease | + &Instruction::CallPid | + &Instruction::CallCharsBase64 | + &Instruction::CallDevourWhitespace | + &Instruction::CallIsSTOEnabled | + &Instruction::CallSetSTOAsUnify | + &Instruction::CallSetNSTOAsUnify | + &Instruction::CallSetSTOWithErrorAsUnify | + &Instruction::CallHomeDirectory | + &Instruction::CallDebugHook | + &Instruction::CallAddDiscontiguousPredicate | + &Instruction::CallAddDynamicPredicate | + &Instruction::CallAddMultifilePredicate | + &Instruction::CallAddGoalExpansionClause | + &Instruction::CallAddTermExpansionClause | + &Instruction::CallAddInSituFilenameModule | + &Instruction::CallClauseToEvacuable | + &Instruction::CallScopedClauseToEvacuable | + &Instruction::CallConcludeLoad | + &Instruction::CallDeclareModule | + &Instruction::CallLoadCompiledLibrary | + &Instruction::CallLoadContextSource | + &Instruction::CallLoadContextFile | + &Instruction::CallLoadContextDirectory | + &Instruction::CallLoadContextModule | + &Instruction::CallLoadContextStream | + &Instruction::CallPopLoadContext | + &Instruction::CallPopLoadStatePayload | + &Instruction::CallPushLoadContext | + &Instruction::CallPushLoadStatePayload | + &Instruction::CallUseModule | + &Instruction::CallBuiltInProperty | + &Instruction::CallMetaPredicateProperty | + &Instruction::CallMultifileProperty | + &Instruction::CallDiscontiguousProperty | + &Instruction::CallDynamicProperty | + &Instruction::CallAbolishClause | + &Instruction::CallAsserta | + &Instruction::CallAssertz | + &Instruction::CallRetract | + &Instruction::CallIsConsistentWithTermQueue | + &Instruction::CallFlushTermQueue | + &Instruction::CallRemoveModuleExports | + &Instruction::CallAddNonCountedBacktracking | + &Instruction::CallPopCount | + &Instruction::CallArgv | + &Instruction::CallEd25519SignRaw | + &Instruction::CallEd25519VerifyRaw | + &Instruction::CallEd25519SeedToPublicKey => { + let (name, arity) = self.to_name_and_arity(); + functor!(atom!("call"), [atom_as_cell(name), fixnum(arity)]) + } + // + #[cfg(feature = "crypto-full")] + &Instruction::CallCryptoDataEncrypt | + &Instruction::CallCryptoDataDecrypt => { + let (name, arity) = self.to_name_and_arity(); + functor!(atom!("call"), [atom_as_cell(name), fixnum(arity)]) + } + // + &Instruction::CallBeta | + &Instruction::CallBetaI | + &Instruction::CallInvBetaI | + &Instruction::CallGamma | + &Instruction::CallGammP | + &Instruction::CallGammQ | + &Instruction::CallInvGammP | + &Instruction::CallLnGamma | + &Instruction::CallErf | + &Instruction::CallErfc | + &Instruction::CallInvErf | + &Instruction::CallInvErfc => { + let (name, arity) = self.to_name_and_arity(); + functor!(atom!("call"), [atom_as_cell(name), fixnum(arity)]) + } + &Instruction::ExecuteAtomChars | + &Instruction::ExecuteAtomCodes | + &Instruction::ExecuteAtomLength | + &Instruction::ExecuteBindFromRegister | + &Instruction::ExecuteContinuation | + &Instruction::ExecuteCharCode | + &Instruction::ExecuteCharType | + &Instruction::ExecuteCharsToNumber | + &Instruction::ExecuteCodesToNumber | + &Instruction::ExecuteCopyTermWithoutAttrVars | + &Instruction::ExecuteCheckCutPoint | + &Instruction::ExecuteClose | + &Instruction::ExecuteCopyToLiftedHeap | + &Instruction::ExecuteCreatePartialString | + &Instruction::ExecuteCurrentHostname | + &Instruction::ExecuteCurrentInput | + &Instruction::ExecuteCurrentOutput | + &Instruction::ExecuteDirectoryFiles | + &Instruction::ExecuteFileSize | + &Instruction::ExecuteFileExists | + &Instruction::ExecuteDirectoryExists | + &Instruction::ExecuteDirectorySeparator | + &Instruction::ExecuteMakeDirectory | + &Instruction::ExecuteMakeDirectoryPath | + &Instruction::ExecuteDeleteFile | + &Instruction::ExecuteRenameFile | + &Instruction::ExecuteFileCopy | + &Instruction::ExecuteWorkingDirectory | + &Instruction::ExecuteDeleteDirectory | + &Instruction::ExecutePathCanonical | + &Instruction::ExecuteFileTime | + &Instruction::ExecuteDynamicModuleResolution(..) | + &Instruction::ExecutePrepareCallClause(..) | + &Instruction::ExecuteCompileInlineOrExpandedGoal | + &Instruction::ExecuteIsExpandedOrInlined | + &Instruction::ExecuteGetClauseP | + &Instruction::ExecuteInvokeClauseAtP | + &Instruction::ExecuteGetFromAttributedVarList | + &Instruction::ExecutePutToAttributedVarList | + &Instruction::ExecuteDeleteFromAttributedVarList | + &Instruction::ExecuteDeleteAllAttributesFromVar | + &Instruction::ExecuteUnattributedVar | + &Instruction::ExecuteGetDBRefs | + &Instruction::ExecuteKeySortWithConstantVarOrdering | + &Instruction::ExecuteInferenceLimitExceeded | + &Instruction::ExecuteFetchGlobalVar | + &Instruction::ExecuteFirstStream | + &Instruction::ExecuteFlushOutput | + &Instruction::ExecuteGetByte | + &Instruction::ExecuteGetChar | + &Instruction::ExecuteGetNChars | + &Instruction::ExecuteGetCode | + &Instruction::ExecuteGetSingleChar | + &Instruction::ExecuteTruncateIfNoLiftedHeapGrowthDiff | + &Instruction::ExecuteTruncateIfNoLiftedHeapGrowth | + &Instruction::ExecuteGetAttributedVariableList | + &Instruction::ExecuteGetAttrVarQueueDelimiter | + &Instruction::ExecuteGetAttrVarQueueBeyond | + &Instruction::ExecuteGetBValue | + &Instruction::ExecuteGetContinuationChunk | + &Instruction::ExecuteGetNextOpDBRef | + &Instruction::ExecuteLookupDBRef | + &Instruction::ExecuteIsPartialString | + &Instruction::ExecuteHalt | + &Instruction::ExecuteGetLiftedHeapFromOffset | + &Instruction::ExecuteGetLiftedHeapFromOffsetDiff | + &Instruction::ExecuteGetSCCCleaner | + &Instruction::ExecuteHeadIsDynamic | + &Instruction::ExecuteInstallSCCCleaner | + &Instruction::ExecuteInstallInferenceCounter | + &Instruction::ExecuteInferenceCount | + &Instruction::ExecuteLiftedHeapLength | + &Instruction::ExecuteLoadLibraryAsStream | + &Instruction::ExecuteModuleExists | + &Instruction::ExecuteNextEP | + &Instruction::ExecuteNoSuchPredicate | + &Instruction::ExecuteNumberToChars | + &Instruction::ExecuteNumberToCodes | + &Instruction::ExecuteOpDeclaration | + &Instruction::ExecuteOpen | + &Instruction::ExecuteSetStreamOptions | + &Instruction::ExecuteNextStream | + &Instruction::ExecutePartialStringTail | + &Instruction::ExecutePeekByte | + &Instruction::ExecutePeekChar | + &Instruction::ExecutePeekCode | + &Instruction::ExecutePointsToContinuationResetMarker | + &Instruction::ExecutePutByte | + &Instruction::ExecutePutChar | + &Instruction::ExecutePutChars | + &Instruction::ExecutePutCode | + &Instruction::ExecuteReadQueryTerm | + &Instruction::ExecuteReadTerm | + &Instruction::ExecuteRedoAttrVarBinding | + &Instruction::ExecuteRemoveCallPolicyCheck | + &Instruction::ExecuteRemoveInferenceCounter | + &Instruction::ExecuteResetContinuationMarker | + &Instruction::ExecuteRestoreCutPolicy | + &Instruction::ExecuteSetCutPoint(_) | + &Instruction::ExecuteSetInput | + &Instruction::ExecuteSetOutput | + &Instruction::ExecuteStoreBacktrackableGlobalVar | + &Instruction::ExecuteStoreGlobalVar | + &Instruction::ExecuteStreamProperty | + &Instruction::ExecuteSetStreamPosition | + &Instruction::ExecuteInferenceLevel | + &Instruction::ExecuteCleanUpBlock | + &Instruction::ExecuteFail | + &Instruction::ExecuteGetBall | + &Instruction::ExecuteGetCurrentBlock | + &Instruction::ExecuteGetCurrentSCCBlock | + &Instruction::ExecuteGetCutPoint | + &Instruction::ExecuteGetDoubleQuotes | + &Instruction::ExecuteGetUnknown | + &Instruction::ExecuteInstallNewBlock | + &Instruction::ExecuteRandomInteger | + &Instruction::ExecuteMaybe | + &Instruction::ExecuteCpuNow | + &Instruction::ExecuteDeterministicLengthRundown | + &Instruction::ExecuteHttpOpen | + &Instruction::ExecuteHttpListen | + &Instruction::ExecuteHttpAccept | + &Instruction::ExecuteHttpAnswer | + &Instruction::ExecuteLoadForeignLib | + &Instruction::ExecuteForeignCall | + &Instruction::ExecuteDefineForeignStruct | + &Instruction::ExecuteFfiAllocate | + &Instruction::ExecuteFfiReadPtr | + &Instruction::ExecuteFfiDeallocate | + &Instruction::ExecuteJsEval | + &Instruction::ExecutePredicateDefined | + &Instruction::ExecuteStripModule | + &Instruction::ExecuteCurrentTime | + &Instruction::ExecuteQuotedToken | + &Instruction::ExecuteReadFromChars | + &Instruction::ExecuteReadTermFromChars | + &Instruction::ExecuteResetBlock | + &Instruction::ExecuteResetSCCBlock | + &Instruction::ExecuteReturnFromVerifyAttr | + &Instruction::ExecuteSetBall | + &Instruction::ExecutePushBallStack | + &Instruction::ExecutePopBallStack | + &Instruction::ExecutePopFromBallStack | + &Instruction::ExecuteSetCutPointByDefault(_) | + &Instruction::ExecuteSetDoubleQuotes | + &Instruction::ExecuteSetUnknown | + &Instruction::ExecuteSetSeed | + &Instruction::ExecuteSkipMaxList | + &Instruction::ExecuteSleep | + &Instruction::ExecuteSocketClientOpen | + &Instruction::ExecuteSocketServerOpen | + &Instruction::ExecuteSocketServerAccept | + &Instruction::ExecuteSocketServerClose | + &Instruction::ExecuteTLSAcceptClient | + &Instruction::ExecuteTLSClientConnect | + &Instruction::ExecuteSucceed | + &Instruction::ExecuteTermAttributedVariables | + &Instruction::ExecuteTermVariables | + &Instruction::ExecuteTermVariablesUnderMaxDepth | + &Instruction::ExecuteTruncateLiftedHeapTo | + &Instruction::ExecuteUnifyWithOccursCheck | + &Instruction::ExecuteUnwindEnvironments | + &Instruction::ExecuteUnwindStack | + &Instruction::ExecuteWAMInstructions | + &Instruction::ExecuteInlinedInstructions | + &Instruction::ExecuteWriteTerm | + &Instruction::ExecuteWriteTermToChars | + &Instruction::ExecuteScryerPrologVersion | + &Instruction::ExecuteCryptoRandomByte | + &Instruction::ExecuteCryptoDataHash | + &Instruction::ExecuteCryptoHMAC | + &Instruction::ExecuteCryptoDataHKDF | + &Instruction::ExecuteCryptoPasswordHash | + &Instruction::ExecuteCryptoCurveScalarMult | + &Instruction::ExecuteCurve25519ScalarMult | + &Instruction::ExecuteFirstNonOctet | + &Instruction::ExecuteLoadHTML | + &Instruction::ExecuteLoadXML | + &Instruction::ExecuteGetEnv | + &Instruction::ExecuteSetEnv | + &Instruction::ExecuteUnsetEnv | + &Instruction::ExecuteShell | + &Instruction::ExecuteProcessCreate | + &Instruction::ExecuteProcessId | + &Instruction::ExecuteProcessWait | + &Instruction::ExecuteProcessKill | + &Instruction::ExecuteProcessRelease | + &Instruction::ExecutePid | + &Instruction::ExecuteCharsBase64 | + &Instruction::ExecuteDevourWhitespace | + &Instruction::ExecuteIsSTOEnabled | + &Instruction::ExecuteSetSTOAsUnify | + &Instruction::ExecuteSetNSTOAsUnify | + &Instruction::ExecuteSetSTOWithErrorAsUnify | + &Instruction::ExecuteHomeDirectory | + &Instruction::ExecuteDebugHook | + &Instruction::ExecuteAddDiscontiguousPredicate | + &Instruction::ExecuteAddDynamicPredicate | + &Instruction::ExecuteAddMultifilePredicate | + &Instruction::ExecuteAddGoalExpansionClause | + &Instruction::ExecuteAddTermExpansionClause | + &Instruction::ExecuteAddInSituFilenameModule | + &Instruction::ExecuteClauseToEvacuable | + &Instruction::ExecuteScopedClauseToEvacuable | + &Instruction::ExecuteConcludeLoad | + &Instruction::ExecuteDeclareModule | + &Instruction::ExecuteLoadCompiledLibrary | + &Instruction::ExecuteLoadContextSource | + &Instruction::ExecuteLoadContextFile | + &Instruction::ExecuteLoadContextDirectory | + &Instruction::ExecuteLoadContextModule | + &Instruction::ExecuteLoadContextStream | + &Instruction::ExecutePopLoadContext | + &Instruction::ExecutePopLoadStatePayload | + &Instruction::ExecutePushLoadContext | + &Instruction::ExecutePushLoadStatePayload | + &Instruction::ExecuteUseModule | + &Instruction::ExecuteBuiltInProperty | + &Instruction::ExecuteMetaPredicateProperty | + &Instruction::ExecuteMultifileProperty | + &Instruction::ExecuteDiscontiguousProperty | + &Instruction::ExecuteDynamicProperty | + &Instruction::ExecuteAbolishClause | + &Instruction::ExecuteAsserta | + &Instruction::ExecuteAssertz | + &Instruction::ExecuteRetract | + &Instruction::ExecuteIsConsistentWithTermQueue | + &Instruction::ExecuteFlushTermQueue | + &Instruction::ExecuteRemoveModuleExports | + &Instruction::ExecuteAddNonCountedBacktracking | + &Instruction::ExecutePopCount | + &Instruction::ExecuteArgv | + &Instruction::ExecuteEd25519SignRaw | + &Instruction::ExecuteEd25519VerifyRaw | + &Instruction::ExecuteEd25519SeedToPublicKey => { + let (name, arity) = self.to_name_and_arity(); + functor!(atom!("execute"), [atom_as_cell(name), fixnum(arity)]) + } + // + #[cfg(feature = "crypto-full")] + &Instruction::ExecuteCryptoDataEncrypt | + &Instruction::ExecuteCryptoDataDecrypt => { + let (name, arity) = self.to_name_and_arity(); + functor!(atom!("execute"), [atom_as_cell(name), fixnum(arity)]) + } + // + &Instruction::ExecuteBeta | + &Instruction::ExecuteBetaI | + &Instruction::ExecuteInvBetaI | + &Instruction::ExecuteGamma | + &Instruction::ExecuteGammP | + &Instruction::ExecuteGammQ | + &Instruction::ExecuteInvGammP | + &Instruction::ExecuteLnGamma | + &Instruction::ExecuteErf | + &Instruction::ExecuteErfc | + &Instruction::ExecuteInvErf | + &Instruction::ExecuteInvErfc => { + let (name, arity) = self.to_name_and_arity(); + functor!(atom!("execute"), [atom_as_cell(name), fixnum(arity)]) + } + &Instruction::Deallocate => { + functor!(atom!("deallocate")) + } + &Instruction::JmpByCall(offset) => { + functor!(atom!("jmp_by_call"), [fixnum(offset)]) + } + &Instruction::RevJmpBy(offset) => { + functor!(atom!("rev_jmp_by"), [fixnum(offset)]) + } + &Instruction::Proceed => { + functor!(atom!("proceed")) + } + &Instruction::GetConstant(lvl, lit, r) => { + let lvl_stub = lvl.into_functor(); + let rt_stub = reg_type_into_functor(r); + + functor!(atom!("get_constant"), [functor(lvl_stub), + cell(lit), + functor(rt_stub)]) + } + &Instruction::GetList(lvl, r) => { + let lvl_stub = lvl.into_functor(); + let rt_stub = reg_type_into_functor(r); + + functor!(atom!("get_list"), [functor(lvl_stub), functor(rt_stub)]) + } + &Instruction::GetPartialString(lvl, ref s, r) => { + let lvl_stub = lvl.into_functor(); + let rt_stub = reg_type_into_functor(r); + + functor!(atom!("get_partial_string"), [functor(lvl_stub), + string((s.to_string())), + functor(rt_stub)]) + } + &Instruction::GetStructure(lvl, name, arity, r) => { + let lvl_stub = lvl.into_functor(); + let rt_stub = reg_type_into_functor(r); + + functor!(atom!("get_structure"), [functor(lvl_stub), + atom_as_cell(name), + fixnum(arity), + functor(rt_stub)]) + } + &Instruction::GetValue(r, arg) => { + let rt_stub = reg_type_into_functor(r); + functor!(atom!("get_value"), [functor(rt_stub), + fixnum(arg)]) + } + &Instruction::GetVariable(r, arg) => { + let rt_stub = reg_type_into_functor(r); + functor!(atom!("get_variable"), [functor(rt_stub), fixnum(arg)]) + } + &Instruction::UnifyConstant(c) => { + functor!(atom!("unify_constant"), [cell(c)]) + } + &Instruction::UnifyLocalValue(r) => { + let rt_stub = reg_type_into_functor(r); + functor!(atom!("unify_local_value"), [functor(rt_stub)]) + } + &Instruction::UnifyVariable(r) => { + let rt_stub = reg_type_into_functor(r); + functor!(atom!("unify_variable"), [functor(rt_stub)]) + } + &Instruction::UnifyValue(r) => { + let rt_stub = reg_type_into_functor(r); + functor!(atom!("unify_value"), [functor(rt_stub)]) + } + &Instruction::UnifyVoid(vars) => { + functor!(atom!("unify_void"), [fixnum(vars)]) + } + &Instruction::PutUnsafeValue(norm, arg) => { + functor!(atom!("put_unsafe_value"), [fixnum(norm), fixnum(arg)]) + } + &Instruction::PutConstant(lvl, c, r) => { + let lvl_stub = lvl.into_functor(); + let rt_stub = reg_type_into_functor(r); + + functor!(atom!("put_constant"), [functor(rt_stub), cell(c), functor(lvl_stub)]) + } + &Instruction::PutList(lvl, r) => { + let lvl_stub = lvl.into_functor(); + let rt_stub = reg_type_into_functor(r); + + functor!(atom!("put_list"), [functor(lvl_stub), functor(rt_stub)]) + } + &Instruction::PutPartialString(lvl, ref s, r) => { + let lvl_stub = lvl.into_functor(); + let rt_stub = reg_type_into_functor(r); + + functor!(atom!("put_partial_string"), [functor(lvl_stub), + string((s.to_string())), + functor(rt_stub)]) + } + &Instruction::PutStructure(name, arity, r) => { + let rt_stub = reg_type_into_functor(r); + + functor!(atom!("put_structure"), [atom_as_cell(name), + fixnum(arity), + functor(rt_stub)]) + } + &Instruction::PutValue(r, arg) => { + let rt_stub = reg_type_into_functor(r); + + functor!(atom!("put_value"), [functor(rt_stub), + fixnum(arg)]) + } + &Instruction::PutVariable(r, arg) => { + let rt_stub = reg_type_into_functor(r); + + functor!(atom!("put_variable"), [functor(rt_stub), + fixnum(arg)]) + } + &Instruction::SetConstant(c) => { + functor!(atom!("set_constant"), [cell(c)]) + } + &Instruction::SetLocalValue(r) => { + let rt_stub = reg_type_into_functor(r); + functor!(atom!("set_local_value"), [functor(rt_stub)]) + } + &Instruction::SetVariable(r) => { + let rt_stub = reg_type_into_functor(r); + functor!(atom!("set_variable"), [functor(rt_stub)]) + } + &Instruction::SetValue(r) => { + let rt_stub = reg_type_into_functor(r); + functor!(atom!("set_value"), [functor(rt_stub)]) + } + &Instruction::SetVoid(vars) => { + functor!(atom!("set_void"), [fixnum(vars)]) + } + &Instruction::BreakFromDispatchLoop => { + functor!(atom!("$break_from_dispatch_loop")) + } + } + } + + #[allow(dead_code)] + pub fn is_query_instr(&self) -> bool { + matches!(self, + &Instruction::GetVariable(..) | + &Instruction::PutConstant(..) | + &Instruction::PutList(..) | + &Instruction::PutPartialString(..) | + &Instruction::PutStructure(..) | + &Instruction::PutUnsafeValue(..) | + &Instruction::PutValue(..) | + &Instruction::PutVariable(..) | + &Instruction::SetConstant(..) | + &Instruction::SetLocalValue(..) | + &Instruction::SetVariable(..) | + &Instruction::SetValue(..) | + &Instruction::SetVoid(..) + ) + } +} + +impl CompareNumber { + pub fn set_terms(&mut self, l_at_1: ArithmeticTerm, l_at_2: ArithmeticTerm) { + match self { + CompareNumber::NumberGreaterThan(ref mut at_1, ref mut at_2) | + CompareNumber::NumberLessThan(ref mut at_1, ref mut at_2) | + CompareNumber::NumberGreaterThanOrEqual(ref mut at_1, ref mut at_2) | + CompareNumber::NumberLessThanOrEqual(ref mut at_1, ref mut at_2) | + CompareNumber::NumberNotEqual(ref mut at_1, ref mut at_2) | + CompareNumber::NumberEqual(ref mut at_1, ref mut at_2) => { + *at_1 = l_at_1; + *at_2 = l_at_2; + } + } + } +} \ No newline at end of file diff --git a/src/lib.rs b/src/lib.rs index 598110ad..4ad5a83b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -29,10 +29,10 @@ pub(crate) mod heap_print; mod http; mod indexing; mod variable_records; + #[macro_use] -pub(crate) mod instructions { - include!(concat!(env!("OUT_DIR"), "/instructions.rs")); -} +pub(crate) mod instructions; + mod iterators; pub(crate) mod machine; mod raw_block; From eca4262be6a9d5d2e1c836a5157c3f6343050208 Mon Sep 17 00:00:00 2001 From: Skgland Date: Sat, 10 Jan 2026 17:52:34 +0100 Subject: [PATCH 2/5] fix clippy lints --- build/instructions_template.rs | 5 ++- src/codegen.rs | 2 +- src/ffi.rs | 2 ++ src/machine/dispatch.rs | 66 +++++++++++++++++----------------- src/offset_table.rs | 1 + src/parser/ast.rs | 1 + 6 files changed, 40 insertions(+), 37 deletions(-) diff --git a/build/instructions_template.rs b/build/instructions_template.rs index 277ce010..06f71edb 100644 --- a/build/instructions_template.rs +++ b/build/instructions_template.rs @@ -1570,12 +1570,11 @@ pub fn generate_instructions_rs() -> TokenStream { let instr_macro_arms: Vec<_> = instr_data .instr_variants .iter() - .rev() // produce default, execute & default & execute cases first. - .cloned() + .rev() .map(|(name, arity, _, variant)| { let variant_ident = variant.ident.clone(); let variant_string = variant.ident.to_string(); - let arity = match arity { + let arity = match *arity { Arity::Static(arity) => arity, _ => 1, }; diff --git a/src/codegen.rs b/src/codegen.rs index 902f5b9f..c5a0c857 100644 --- a/src/codegen.rs +++ b/src/codegen.rs @@ -859,7 +859,7 @@ impl CodeGenerator { let v = HeapCellValue::from(c); self.marker - .mark_non_var::(Level::Shallow, term_loc, &cell, code); + .mark_non_var::(Level::Shallow, term_loc, cell, code); code.push_back(instr!("put_constant", Level::Shallow, v, temp_v!(1))); compile_expr!(self, &terms[1], term_loc, code) diff --git a/src/ffi.rs b/src/ffi.rs index 0d3521b8..5545b397 100644 --- a/src/ffi.rs +++ b/src/ffi.rs @@ -975,6 +975,8 @@ pub enum FfiError { ArgCountMismatch { name: Atom, // ffi function or struct kind: ArgCountMismatchKind, + + #[allow(dead_code, reason = "will be used by PR 3173")] expected: usize, got: usize, }, diff --git a/src/machine/dispatch.rs b/src/machine/dispatch.rs index 8306c6e8..cbf7d941 100644 --- a/src/machine/dispatch.rs +++ b/src/machine/dispatch.rs @@ -847,11 +847,11 @@ impl MachineState { } #[inline(always)] - fn get_partial_string_instr(&mut self, string: &String, r: RegType) { + fn get_partial_string_instr(&mut self, string: &str, r: RegType) { self.heap[0] = self[r]; let mut h = 0; - let mut string_cursor = string.as_str(); + let mut string_cursor = string; if self.heap[0].is_stack_var() { let cell = self.store(self.deref(self.heap[0])); @@ -1548,63 +1548,63 @@ impl Machine { fn verify_attr_dispatch_loop(&mut self) -> Option { 'outer: loop { for _ in 0..INSTRUCTIONS_PER_INTERRUPT_POLL { - match &self.code[self.machine_st.p] { - &Instruction::BreakFromDispatchLoop => { + match self.code[self.machine_st.p] { + Instruction::BreakFromDispatchLoop => { break 'outer; } - &Instruction::GetLevel(r) => self.machine_st.get_level_instr(r), - &Instruction::GetPrevLevel(r) => self.machine_st.get_prev_level_instr(r), - &Instruction::GetCutPoint(r) => self.machine_st.get_cut_point_instr(r), - &Instruction::Deallocate => self.machine_st.deallocate(), - &Instruction::JmpByCall(offset) => { + Instruction::GetLevel(r) => self.machine_st.get_level_instr(r), + Instruction::GetPrevLevel(r) => self.machine_st.get_prev_level_instr(r), + Instruction::GetCutPoint(r) => self.machine_st.get_cut_point_instr(r), + Instruction::Deallocate => self.machine_st.deallocate(), + Instruction::JmpByCall(offset) => { self.machine_st.p += offset; } - &Instruction::RevJmpBy(offset) => { + Instruction::RevJmpBy(offset) => { self.machine_st.p -= offset; } - &Instruction::GetConstant(_, c, reg) => { + Instruction::GetConstant(_, c, reg) => { self.machine_st.get_constant_instr(c, reg) } - &Instruction::GetList(_, reg) => self.machine_st.get_list_instr(reg), - &Instruction::GetPartialString(_, ref string, reg) => { + Instruction::GetList(_, reg) => self.machine_st.get_list_instr(reg), + Instruction::GetPartialString(_, ref string, reg) => { self.machine_st.get_partial_string_instr(string, reg) } - &Instruction::GetStructure(_lvl, name, arity, reg) => { + Instruction::GetStructure(_lvl, name, arity, reg) => { self.machine_st.get_structure_instr(name, arity, reg) } - &Instruction::GetVariable(norm, arg) => { + Instruction::GetVariable(norm, arg) => { self.machine_st.get_variable_instr(norm, arg) } - &Instruction::GetValue(norm, arg) => self.machine_st.get_value_instr(norm, arg), - &Instruction::UnifyConstant(v) => self.machine_st.unify_constant_instr(v), - &Instruction::UnifyLocalValue(reg) => { + Instruction::GetValue(norm, arg) => self.machine_st.get_value_instr(norm, arg), + Instruction::UnifyConstant(v) => self.machine_st.unify_constant_instr(v), + Instruction::UnifyLocalValue(reg) => { self.machine_st.unify_local_value_instr(reg) } - &Instruction::UnifyVariable(reg) => self.machine_st.unify_variable_instr(reg), - &Instruction::UnifyValue(reg) => self.machine_st.unify_value_instr(reg), - &Instruction::UnifyVoid(n) => self.machine_st.unify_void_instr(n), - &Instruction::PutConstant(_, cell, reg) => { + Instruction::UnifyVariable(reg) => self.machine_st.unify_variable_instr(reg), + Instruction::UnifyValue(reg) => self.machine_st.unify_value_instr(reg), + Instruction::UnifyVoid(n) => self.machine_st.unify_void_instr(n), + Instruction::PutConstant(_, cell, reg) => { self.machine_st.put_constant_instr(cell, reg) } - &Instruction::PutList(_, reg) => self.machine_st.put_list_instr(reg), - &Instruction::PutPartialString(_, ref string, reg) => { + Instruction::PutList(_, reg) => self.machine_st.put_list_instr(reg), + Instruction::PutPartialString(_, ref string, reg) => { self.machine_st.put_partial_string_instr(string, reg) } - &Instruction::PutStructure(name, arity, reg) => { + Instruction::PutStructure(name, arity, reg) => { self.machine_st.put_structure_instr(name, arity, reg) } - &Instruction::PutUnsafeValue(perm_slot, arg) => { + Instruction::PutUnsafeValue(perm_slot, arg) => { self.machine_st.put_unsafe_value_instr(perm_slot, arg) } - &Instruction::PutValue(norm, arg) => self.machine_st.put_value_instr(norm, arg), - &Instruction::PutVariable(norm, arg) => { + Instruction::PutValue(norm, arg) => self.machine_st.put_value_instr(norm, arg), + Instruction::PutVariable(norm, arg) => { self.machine_st.put_variable_instr(norm, arg) } - &Instruction::SetConstant(c) => self.machine_st.set_constant_instr(c), - &Instruction::SetLocalValue(reg) => self.machine_st.set_local_value_instr(reg), - &Instruction::SetVariable(reg) => self.machine_st.set_variable_instr(reg), - &Instruction::SetValue(reg) => self.machine_st.set_value_instr(reg), - &Instruction::SetVoid(n) => self.machine_st.set_void_instr(n), + Instruction::SetConstant(c) => self.machine_st.set_constant_instr(c), + Instruction::SetLocalValue(reg) => self.machine_st.set_local_value_instr(reg), + Instruction::SetVariable(reg) => self.machine_st.set_variable_instr(reg), + Instruction::SetValue(reg) => self.machine_st.set_value_instr(reg), + Instruction::SetVoid(n) => self.machine_st.set_void_instr(n), _ => return None, } } diff --git a/src/offset_table.rs b/src/offset_table.rs index ec3f6031..c6fee00d 100644 --- a/src/offset_table.rs +++ b/src/offset_table.rs @@ -238,6 +238,7 @@ impl SerialOffsetTable { &mut *self.block.base.add(offset).cast::().cast_mut() } + #[allow(clippy::wrong_self_convention)] fn to_concurrent(&mut self) -> ConcurrentOffsetTable where T: fmt::Debug, diff --git a/src/parser/ast.rs b/src/parser/ast.rs index 3728da75..9fc54c70 100644 --- a/src/parser/ast.rs +++ b/src/parser/ast.rs @@ -250,6 +250,7 @@ pub enum GInteger { impl GInteger { #[inline] + #[allow(clippy::wrong_self_convention)] pub fn to_literal(self) -> Literal { match self { GInteger::Integer(integer) => Literal::Integer(integer), From 5064760b1e7c9957ed40c4733bd37edf449f6a4d Mon Sep 17 00:00:00 2001 From: Skgland Date: Sat, 10 Jan 2026 17:53:19 +0100 Subject: [PATCH 3/5] fix spelling --- README.md | 4 +-- _typos.toml | 31 +++++++++++++++++++ benches/README.md | 4 +-- build/instructions_template.rs | 2 +- clippy.toml | 2 +- learn/lets-play-brisca.dj | 6 ++-- src/arena.rs | 2 +- src/atom_table.rs | 2 +- src/ffi.rs | 2 +- src/machine/dispatch.rs | 2 +- src/machine/heap.rs | 2 +- src/machine/lib_machine/mod.rs | 2 +- src/machine/lib_machine/tests.rs | 2 +- src/machine/stack.rs | 4 +-- src/machine/system_calls.rs | 4 +-- src/parser/ast.rs | 2 +- src/repl_helper.rs | 8 ++--- src/types.rs | 2 +- .../scryer/cli/src_tests/directive_errors.md | 2 +- tests/scryer/ffi.rs | 3 +- tests/scryer/src_tests.rs | 2 ++ wambook/errata.txt | 4 +-- 22 files changed, 63 insertions(+), 31 deletions(-) create mode 100644 _typos.toml diff --git a/README.md b/README.md index 9132e80c..92fbae24 100644 --- a/README.md +++ b/README.md @@ -159,9 +159,9 @@ during the installation of the rust toolchain. #### From Crates.io [![Crates.io Version](https://img.shields.io/crates/v/scryer-prolog)](https://crates.io/crates/scryer-prolog) ![Crates.io MSRV](https://img.shields.io/crates/msrv/scryer-prolog) > [!NOTE] -> The lates crates.io release can be significantly behind the version available in the git repository +> The latest crates.io release can be significantly behind the version available in the git repository > The crates.io badge in this sections title is a link to the crates.io page. -> The msrv badge in the section title referece to the minimum rust toolchain version required to compile the latest crates.io release +> The msrv badge in the section title references the minimum rust toolchain version required to compile the latest crates.io release `scryer-prolog` is also release on crates.io and can be installed with diff --git a/_typos.toml b/_typos.toml new file mode 100644 index 00000000..dc829cd3 --- /dev/null +++ b/_typos.toml @@ -0,0 +1,31 @@ +# config for https://github.com/crate-ci/typos + +[default] +# example from https://github.com/crate-ci/typos/blob/master/docs/reference.md#example-configurations +extend-ignore-re = [ + "(#|//)\\s*spellchecker:ignore-next-line\\n.*" +] + +# correct word key to value +# can be used to ignore a typo by adding an entry = "" +[default.extend-words] + +# correct identifier key to value +# can be used to ignore a typo by adding an entry = "" +[default.extend-identifiers] +interm = "interm" +IntermReg = "IntermReg" + + + +[type.prolog] +extend-glob = ["*.pl"] +check-file = false + +[type.stdout] +extend-glob = ["*.stdout"] +check-file = false + + +[files] +extend-exclude = ["lib_integration_test_commands.txt"] \ No newline at end of file diff --git a/benches/README.md b/benches/README.md index 1dbf90aa..fa274a37 100644 --- a/benches/README.md +++ b/benches/README.md @@ -49,7 +49,7 @@ once. ## Adding benchmarks -This design is meant to suppoort defining lots of benchmarks. +This design is meant to support defining lots of benchmarks. To add a new benchmark: @@ -77,7 +77,7 @@ Some tips: cumbersome to run. * Consider that the library runtime actually parses the text output of the top level. So don't use custom outputs or it will fail to parse. Also keep the - output small so it doesn't just benchmark the ouput parsing code. + output small so it doesn't just benchmark the output parsing code. * DO test the output of the benchmark run, we don't want to count broken benchmarks. diff --git a/build/instructions_template.rs b/build/instructions_template.rs index 06f71edb..954c35c7 100644 --- a/build/instructions_template.rs +++ b/build/instructions_template.rs @@ -13,7 +13,7 @@ use to_syn_value_derive::ToDeriveInput; * This crate exists to generate the Instruction enum in * src/instructions.rs and its adjoining impl functions. The types * defined in it are empty and serve only as schema for the generation - * of Instruction. They mimick most of the structure of the previous + * of Instruction. They mimic most of the structure of the previous * Line instruction type. The strum crate is used to provide reflection * on each of the node types to the tree walker. */ diff --git a/clippy.toml b/clippy.toml index 523192fe..1f7b664b 100644 --- a/clippy.toml +++ b/clippy.toml @@ -9,7 +9,7 @@ disallowed-macros = [ disallowed-methods = [ # https://rust-lang.github.io/rust-clippy/master/#disallowed_method - # list of methods that may panic on allocation failue + # list of methods that may panic on allocation failure # though not including things that can be used correctly by reversing ahead of time (i.e. std::vec::Vec::try_reserve + std::iter::Extend::extend ). # "std::iter::Iter::collect", diff --git a/learn/lets-play-brisca.dj b/learn/lets-play-brisca.dj index 43873286..a2422f6a 100644 --- a/learn/lets-play-brisca.dj +++ b/learn/lets-play-brisca.dj @@ -23,7 +23,7 @@ The rules for knowing which players takes the round are the following: First, we need to decide a representation of our cards. Coming from another languages we can think that a good representation might be a class or a struct, with two fields, one for the number and the other for the suite, but Prolog doesn't have objects. We can use a list with two elements. But lists are better when we're dealing with variable length data. We could also use a compound term. This is the right choice if our fields are fixed. -A compound term is defined by an atom, followed by the data itself enclosed by parenthesis and separated by comma. Like this: `card(oros, 4)`. Yes, very similar to predicates. In fact the only difference is how we use them, because they're the same. If we pass a compund term in the first level of a query, or inside a call/N, Prolog will treat it as code instead of data. This is one the the examples of Prolog being a homoiconic language. +A compound term is defined by an atom, followed by the data itself enclosed by parenthesis and separated by comma. Like this: `card(oros, 4)`. Yes, very similar to predicates. In fact the only difference is how we use them, because they're the same. If we pass a compound term in the first level of a query, or inside a call/N, Prolog will treat it as code instead of data. This is one the the examples of Prolog being a homoiconic language. We can go further, Prolog is very flexible and we can define custom operators easily if we want. Those are also compound terms, but with a different syntax. There's an operator already defined that is very useful for us: the dash. We can just join two pieces of data with a dash, and they'll be together in the same structure. This is usually called "pair". @@ -98,7 +98,7 @@ cards_score_(X) --> cards_score_(X1). ``` -In DCGs, to match an item of the sequence, we use brackets. We use braces to introduce normal Prolog code. Calling other DCGs (in this case, the same, as it's a recursive one), it's just calling it again. Notice in this code that we are doing the addition of X0 and X1 when we still don't know the value of X1. This would be an error in the traditional arithmethic system of Prolog, but it's valid with clpz. clpz allows us to have a more declarative arithmethic, at least with integers. +In DCGs, to match an item of the sequence, we use brackets. We use braces to introduce normal Prolog code. Calling other DCGs (in this case, the same, as it's a recursive one), it's just calling it again. Notice in this code that we are doing the addition of X0 and X1 when we still don't know the value of X1. This would be an error in the traditional arithmetic system of Prolog, but it's valid with clpz. clpz allows us to have a more declarative arithmetic, at least with integers. Now we can try this code using `phrase/2` which is needed to jump to a DCG. @@ -276,7 +276,7 @@ Let's ask ourselves what is a procedure. It's a sequence. And we have already se The basic idea however is having _explicit_ states. The predicates that we're going to write will take an state (a view of the world at a certain point) and will give us the next state. -Let's define the state first. In a game of Brisca we have players. Each player has the three cards he can choose to put (less if we're running out of cards) and the cards he has got from winning rounds. Aditionally we have a stock, a trump suite and the order to play, which is usually from the player who won the last round and going to the right. We could store the data in a list, with different compound terms: +Let's define the state first. In a game of Brisca we have players. Each player has the three cards he can choose to put (less if we're running out of cards) and the cards he has got from winning rounds. Additionally we have a stock, a trump suite and the order to play, which is usually from the player who won the last round and going to the right. We could store the data in a list, with different compound terms: ``` [players([player(Name, PlayableCards, WonCards), player(Name, PlayableCards, WonCards), ...]), stock(Cards), trump(Trump)] diff --git a/src/arena.rs b/src/arena.rs index c27ed5f4..ab108e02 100644 --- a/src/arena.rs +++ b/src/arena.rs @@ -445,7 +445,7 @@ impl TypedAllocSlab { pub fn to_untyped(self: Box) -> (TypedArenaPtr, UntypedArenaSlab) { let raw_box = Box::into_raw(self); - // safety: the pointer from Box::into_raw fullfills addr_of_mut's saftey requirements + // safety: the pointer from Box::into_raw fulfills addr_of_mut's safety requirements let payload_ptr = unsafe { addr_of_mut!((*raw_box).payload) }; ( diff --git a/src/atom_table.rs b/src/atom_table.rs index d9e970db..7a0a818e 100644 --- a/src/atom_table.rs +++ b/src/atom_table.rs @@ -540,7 +540,7 @@ impl AtomTable { table.insert(atom); block_epoch.table.replace(table); - // expicit drop to ensure we don't accidentally drop it early + // explicit drop to ensure we don't accidentally drop it early drop(update_guard); return atom; diff --git a/src/ffi.rs b/src/ffi.rs index 5545b397..e2e996f2 100644 --- a/src/ffi.rs +++ b/src/ffi.rs @@ -981,7 +981,7 @@ pub enum FfiError { got: usize, }, AllocationFailed, - // LayoutError should never occour + // LayoutError should never occur LayoutError, UnsupportedTypedef, UnsupportedAbi, diff --git a/src/machine/dispatch.rs b/src/machine/dispatch.rs index cbf7d941..f67b0df2 100644 --- a/src/machine/dispatch.rs +++ b/src/machine/dispatch.rs @@ -310,7 +310,7 @@ impl MachineState { self.throw_interrupt_exception(); self.backtrack(); - // We have extracted controll over the Tokio runtime to the calling context for enabling library use case + // We have extracted control over the Tokio runtime to the calling context for enabling library use case // (see https://github.com/mthom/scryer-prolog/pull/1880) // So we only have access to a runtime handle in here and can't shut it down. // Since I'm not aware of the consequences of deactivating this new code which came in while PR 1880 diff --git a/src/machine/heap.rs b/src/machine/heap.rs index d8c52ac8..70ef0ba3 100644 --- a/src/machine/heap.rs +++ b/src/machine/heap.rs @@ -445,7 +445,7 @@ impl Index for ReservedHeapSection { /// Computes the number of bytes required to pad a string of length `chunk_len` /// with zeroes, such that `chunk_len + pstr_sentinel_length(chunk_len)` is a -/// multiple of `Heap::heap_cell_alignement()`. +/// multiple of `Heap::heap_cell_alignment()`. fn pstr_sentinel_length(chunk_len: usize) -> usize { let res = chunk_len.next_multiple_of(ALIGN) - chunk_len; diff --git a/src/machine/lib_machine/mod.rs b/src/machine/lib_machine/mod.rs index b4409aa5..75aeffc6 100644 --- a/src/machine/lib_machine/mod.rs +++ b/src/machine/lib_machine/mod.rs @@ -415,7 +415,7 @@ pub struct QueryState<'a> { impl Drop for QueryState<'_> { fn drop(&mut self) { - // FIXME: This may be wrong if the iterator is not fully consumend, but from testing it + // FIXME: This may be wrong if the iterator is not fully consumed, but from testing it // seems fine. Is this really ok? self.machine.trust_me(); } diff --git a/src/machine/lib_machine/tests.rs b/src/machine/lib_machine/tests.rs index 5b89d67d..a83901a4 100644 --- a/src/machine/lib_machine/tests.rs +++ b/src/machine/lib_machine/tests.rs @@ -3,7 +3,7 @@ use crate::MachineBuilder; #[test] #[cfg_attr(miri, ignore = "it takes too long to run")] -fn programatic_query() { +fn programmatic_query() { let mut machine = MachineBuilder::default().build(); machine.load_module_string( diff --git a/src/machine/stack.rs b/src/machine/stack.rs index 98e1dab8..ad9b4755 100644 --- a/src/machine/stack.rs +++ b/src/machine/stack.rs @@ -191,7 +191,7 @@ impl Stack { let cell_ptr = new_ptr.add(offset).cast::(); ptr::write(cell_ptr.as_ptr(), stack_loc_as_cell!(AndFrame, e, idx + 1)); - // Because in the Index and IndexMut inplementations we need to get this from + // Because in the Index and IndexMut implementations we need to get this from // exposed provenance, we need to expose the provenance here, even though we don't // actually use the value for anything. This is a reminder that `expose_provenance` // isn't just a cast from a pointer to an integer but has actual side effects. @@ -224,7 +224,7 @@ impl Stack { let cell_ptr = new_ptr.byte_add(offset).cast::(); ptr::write(cell_ptr.as_ptr(), stack_loc_as_cell!(OrFrame, b, idx)); - // Because in the Index and IndexMut inplementations we need to get this from + // Because in the Index and IndexMut implementations we need to get this from // exposed provenance, we need to expose the provenance here, even though we don't // actually use the value for anything. This is a reminder that `expose_provenance` // isn't just a cast from a pointer to an integer but has actual side effects. diff --git a/src/machine/system_calls.rs b/src/machine/system_calls.rs index ac13c2e5..d2db935e 100644 --- a/src/machine/system_calls.rs +++ b/src/machine/system_calls.rs @@ -4292,7 +4292,7 @@ impl Machine { } let value = self.rng.gen_range(lower..upper); // Safety: - // - lower and uper bounds are Fixnum values + // - lower and upper bounds are Fixnum values // - value is inbetween lower and upper // - fixnums value range has no gaps // so value is also a valid Fixnum value @@ -4812,7 +4812,7 @@ impl Machine { if interruption { self.machine_st.throw_interrupt_exception(); self.machine_st.backtrack(); - // We have extracted controll over the Tokio runtime to the calling context for enabling library use case + // We have extracted control over the Tokio runtime to the calling context for enabling library use case // (see https://github.com/mthom/scryer-prolog/pull/1880) // So we only have access to a runtime handle in here and can't shut it down. // Since I'm not aware of the consequences of deactivating this new code which came in while PR 1880 diff --git a/src/parser/ast.rs b/src/parser/ast.rs index 9fc54c70..ba18d36e 100644 --- a/src/parser/ast.rs +++ b/src/parser/ast.rs @@ -361,7 +361,7 @@ impl OpDesc { #[inline] pub fn get_spec(self) -> OpDeclSpec { - OpDeclSpec::try_from(self.spec()).expect("OpDecl always contains a valud OpDeclSpec") + OpDeclSpec::try_from(self.spec()).expect("OpDecl always contains a valid OpDeclSpec") } #[inline] diff --git a/src/repl_helper.rs b/src/repl_helper.rs index afec4fd2..cbf75f6b 100644 --- a/src/repl_helper.rs +++ b/src/repl_helper.rs @@ -10,14 +10,14 @@ use crate::atom_table::{AtomString, AtomTable, STATIC_ATOMS_MAP}; // TODO: Maybe add validation to the helper pub struct Helper { - highligher: MatchingBracketHighlighter, + highlighter: MatchingBracketHighlighter, pub atoms: Weak, } impl Helper { pub fn new() -> Self { Self { - highligher: MatchingBracketHighlighter::new(), + highlighter: MatchingBracketHighlighter::new(), atoms: Weak::new(), } } @@ -90,11 +90,11 @@ impl Completer for Helper { impl Highlighter for Helper { fn highlight<'l>(&self, line: &'l str, pos: usize) -> std::borrow::Cow<'l, str> { - self.highligher.highlight(line, pos) + self.highlighter.highlight(line, pos) } fn highlight_char(&self, line: &str, pos: usize, forced: bool) -> bool { - self.highligher.highlight_char(line, pos, forced) + self.highlighter.highlight_char(line, pos, forced) } } diff --git a/src/types.rs b/src/types.rs index 4549c3ea..7cc843bc 100644 --- a/src/types.rs +++ b/src/types.rs @@ -782,7 +782,7 @@ impl UntypedArenaPtr { } /// # Safety - /// - this UntypedArenaPtr actuall pointee type is T + /// - this UntypedArenaPtr actual pointee type is T /// - the pointer must be non-null #[inline] pub unsafe fn as_typed_ptr(self) -> TypedArenaPtr diff --git a/tests/scryer/cli/src_tests/directive_errors.md b/tests/scryer/cli/src_tests/directive_errors.md index 4b6c8b43..666180ee 100644 --- a/tests/scryer/cli/src_tests/directive_errors.md +++ b/tests/scryer/cli/src_tests/directive_errors.md @@ -59,7 +59,7 @@ $ scryer-prolog -f --no-add-history tests-pl/invalid_decl10.pl -g halt ``` -FIXME I belive the following test should result in a `error(instantiation_error,load/1)` error instead of the current error. +FIXME I believe the following test should result in a `error(instantiation_error,load/1)` error instead of the current error. ```trycmd $ scryer-prolog -f --no-add-history tests-pl/invalid_decl11.pl -g halt diff --git a/tests/scryer/ffi.rs b/tests/scryer/ffi.rs index c76162a2..abe5c9b7 100644 --- a/tests/scryer/ffi.rs +++ b/tests/scryer/ffi.rs @@ -13,7 +13,7 @@ const TMP_DIR: &str = env!("CARGO_TARGET_TMPDIR"); // each test is building its own library so that they can easier run in parallel, // i.e. don't need to wait for a large dynamic library to compile, -// also rusts test infra currently has no functionallity for a setup/befor step +// also rusts test infra currently has no functionality for a setup/befor step fn build_dynamic_library(name: &str, src: &str) -> PathBuf { let tmp_dir: &Path = TMP_DIR.as_ref(); @@ -79,7 +79,6 @@ fn ffi_f64_minus_zero() { "##, ); - // note: ouput is currently wrong correct would be 1.0,1.0 load_module_test_with_input( "tests-pl/ffi_f64_minus_zero.pl", format!("LIB={dynlib_path:?}."), diff --git a/tests/scryer/src_tests.rs b/tests/scryer/src_tests.rs index f0edd5d8..03049462 100644 --- a/tests/scryer/src_tests.rs +++ b/tests/scryer/src_tests.rs @@ -57,8 +57,10 @@ fn rules() { #[test] #[cfg_attr(miri, ignore = "it takes too long to run")] fn setup_call_cleanup_load() { + load_module_test( "src/tests/setup_call_cleanup.pl", + // spellchecker:ignore-next-line "1+21+31+2>A+B1+G1+2>41+2>B1+2>31+2>31+2>4ba", ); } diff --git a/wambook/errata.txt b/wambook/errata.txt index 43ec62d0..1ad15265 100644 --- a/wambook/errata.txt +++ b/wambook/errata.txt @@ -129,7 +129,7 @@ last argument. Easy fix... %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% When allocating a new choice or environment frame on the stack, one -should use CP (the continuation pointer) insteads of E+1 (the stored +should use CP (the continuation pointer) instead of E+1 (the stored continuation pointer) to find out the number of Y variables to preserve in the previous environment frame. This is because the continuation pointer is stored on the stack only if an ALLOCATE instruction is used @@ -158,7 +158,7 @@ re-loaded. The correct code is: There is a more subtle related bug that usually doesn't matter very much: both cut and neck_cut should also reset HB. If they do not, -some uneccessary trailing will occur. This normally doesnt matter +some unnecessary trailing will occur. This normally doesnt matter too much (aside from a small performance penalty), but it does turn out to be a problem if you try to implement Older and Rummel's incremental garbage collection algorithm, because you end up with dangling trail From 87f89545bb989b3955a8b42b114059014342b1b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bennet=20Ble=C3=9Fmann?= <3877590+Skgland@users.noreply.github.com> Date: Sat, 10 Jan 2026 18:30:09 +0100 Subject: [PATCH 4/5] restore accidentally removed comment --- build/instructions_template.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/instructions_template.rs b/build/instructions_template.rs index 954c35c7..a2878bfe 100644 --- a/build/instructions_template.rs +++ b/build/instructions_template.rs @@ -1570,7 +1570,7 @@ pub fn generate_instructions_rs() -> TokenStream { let instr_macro_arms: Vec<_> = instr_data .instr_variants .iter() - .rev() + .rev() // produce default, execute & default & execute cases first. .map(|(name, arity, _, variant)| { let variant_ident = variant.ident.clone(); let variant_string = variant.ident.to_string(); From b14e363d5e8ffd296ff13f31e4c21612e8dd0f09 Mon Sep 17 00:00:00 2001 From: Skgland Date: Sat, 10 Jan 2026 18:31:40 +0100 Subject: [PATCH 5/5] run rustfmt to fix formatting --- build/instructions_template.rs | 1 - src/ffi.rs | 2 +- src/instructions.rs | 1522 ++++++++++++++++---------------- tests/scryer/src_tests.rs | 1 - 4 files changed, 752 insertions(+), 774 deletions(-) diff --git a/build/instructions_template.rs b/build/instructions_template.rs index a2878bfe..16f37bcb 100644 --- a/build/instructions_template.rs +++ b/build/instructions_template.rs @@ -1683,7 +1683,6 @@ pub fn generate_instructions_rs() -> TokenStream { }) .collect(); - quote! { #[allow(clippy::enum_variant_names)] #[derive(Clone, Debug)] diff --git a/src/ffi.rs b/src/ffi.rs index e2e996f2..c1762fb6 100644 --- a/src/ffi.rs +++ b/src/ffi.rs @@ -975,7 +975,7 @@ pub enum FfiError { ArgCountMismatch { name: Atom, // ffi function or struct kind: ArgCountMismatchKind, - + #[allow(dead_code, reason = "will be used by PR 3173")] expected: usize, got: usize, diff --git a/src/instructions.rs b/src/instructions.rs index 0467fecc..076c2672 100644 --- a/src/instructions.rs +++ b/src/instructions.rs @@ -148,7 +148,7 @@ impl IndexingCodePtr { IndexingCodePtr::Internal(o) => functor!(atom!("internal"), [fixnum(o)]), IndexingCodePtr::Fail => { functor!(atom!("fail")) - }, + } } } @@ -175,31 +175,26 @@ impl IndexingInstruction { ] ) } - IndexingInstruction::SwitchOnConstant(constants) => { - variadic_functor( - atom!("switch_on_constants"), - 1, - constants.iter().map(|(c, ptr)| { - functor!( - atom!(":"), - [cell((*c)), indexing_code_ptr((*ptr))] - ) - }), - ) - } - IndexingInstruction::SwitchOnStructure(structures) => { - variadic_functor( - atom!("switch_on_structure"), - 1, - structures.iter().map(|((name, arity), ptr)| { - functor!( - atom!(":"), - [functor((atom!("/")), [atom_as_cell(name), fixnum((*arity))]), - indexing_code_ptr((*ptr))] - ) - }), - ) - } + IndexingInstruction::SwitchOnConstant(constants) => variadic_functor( + atom!("switch_on_constants"), + 1, + constants + .iter() + .map(|(c, ptr)| functor!(atom!(":"), [cell((*c)), indexing_code_ptr((*ptr))])), + ), + IndexingInstruction::SwitchOnStructure(structures) => variadic_functor( + atom!("switch_on_structure"), + 1, + structures.iter().map(|((name, arity), ptr)| { + functor!( + atom!(":"), + [ + functor((atom!("/")), [atom_as_cell(name), fixnum((*arity))]), + indexing_code_ptr((*ptr)) + ] + ) + }), + ), } } } @@ -246,9 +241,7 @@ fn arith_instr_bin_functor( let at_1_stub = at_1.into_functor(arena); let at_2_stub = at_2.into_functor(arena); - functor!(name, [functor(at_1_stub), - functor(at_2_stub), - fixnum(t)]) + functor!(name, [functor(at_1_stub), functor(at_2_stub), fixnum(t)]) } pub type Code = Vec; @@ -271,11 +264,7 @@ impl Instruction { } } - pub fn enqueue_functors( - &self, - arena: &mut Arena, - functors: &mut Vec, - ) { + pub fn enqueue_functors(&self, arena: &mut Arena, functors: &mut Vec) { match self { Instruction::IndexingCode(indexing_instrs) => { for indexing_instr in indexing_instrs { @@ -292,8 +281,8 @@ impl Instruction { } IndexingLine::DynamicIndexedChoice(indexed_choice_instrs) => { for indexed_choice_instr in indexed_choice_instrs { - let section = functor!(atom!("dynamic"), - [fixnum((*indexed_choice_instr))]); + let section = + functor!(atom!("dynamic"), [fixnum((*indexed_choice_instr))]); functors.push(section); } } @@ -309,35 +298,37 @@ impl Instruction { &Instruction::RunVerifyAttr => { functor!(atom!("run_verify_attr")) } - &Instruction::DynamicElse(birth, death, next_or_fail) => { - match (death, next_or_fail) { - (Death::Infinity, NextOrFail::Next(i)) => { - functor!( - atom!("dynamic_else"), - [fixnum(birth), atom_as_cell((atom!("inf"))), fixnum(i)] - ) - } - (Death::Infinity, NextOrFail::Fail(i)) => { - functor!( - atom!("dynamic_else"), - [fixnum(birth), - atom_as_cell((atom!("inf"))), - functor((atom!("fail")), [fixnum(i)])] - ) - } - (Death::Finite(d), NextOrFail::Fail(i)) => { - functor!( - atom!("dynamic_else"), - [fixnum(birth), - fixnum(d), - functor((atom!("fail")), [fixnum(i)])] - ) - } - (Death::Finite(d), NextOrFail::Next(i)) => { - functor!(atom!("dynamic_else"), [fixnum(birth), fixnum(d), fixnum(i)]) - } + &Instruction::DynamicElse(birth, death, next_or_fail) => match (death, next_or_fail) { + (Death::Infinity, NextOrFail::Next(i)) => { + functor!( + atom!("dynamic_else"), + [fixnum(birth), atom_as_cell((atom!("inf"))), fixnum(i)] + ) } - } + (Death::Infinity, NextOrFail::Fail(i)) => { + functor!( + atom!("dynamic_else"), + [ + fixnum(birth), + atom_as_cell((atom!("inf"))), + functor((atom!("fail")), [fixnum(i)]) + ] + ) + } + (Death::Finite(d), NextOrFail::Fail(i)) => { + functor!( + atom!("dynamic_else"), + [ + fixnum(birth), + fixnum(d), + functor((atom!("fail")), [fixnum(i)]) + ] + ) + } + (Death::Finite(d), NextOrFail::Next(i)) => { + functor!(atom!("dynamic_else"), [fixnum(birth), fixnum(d), fixnum(i)]) + } + }, &Instruction::DynamicInternalElse(birth, death, next_or_fail) => { match (death, next_or_fail) { (Death::Infinity, NextOrFail::Next(i)) => { @@ -349,17 +340,21 @@ impl Instruction { (Death::Infinity, NextOrFail::Fail(i)) => { functor!( atom!("dynamic_internal_else"), - [fixnum(birth), + [ + fixnum(birth), atom_as_cell((atom!("inf"))), - functor((atom!("fail")), [fixnum(i)])] + functor((atom!("fail")), [fixnum(i)]) + ] ) } (Death::Finite(d), NextOrFail::Fail(i)) => { functor!( atom!("dynamic_internal_else"), - [fixnum(birth), + [ + fixnum(birth), fixnum(d), - functor((atom!("fail")), [fixnum(i)])] + functor((atom!("fail")), [fixnum(i)]) + ] ) } (Death::Finite(d), NextOrFail::Next(i)) => { @@ -468,39 +463,17 @@ impl Instruction { &Instruction::Gcd(ref at_1, ref at_2, t) => { arith_instr_bin_functor(atom!("gcd"), arena, at_1, at_2, t) } - &Instruction::Sign(ref at, t) => { - arith_instr_unary_functor(atom!("sign"), arena, at, t) - } - &Instruction::Cos(ref at, t) => { - arith_instr_unary_functor(atom!("cos"), arena, at, t) - } - &Instruction::Sin(ref at, t) => { - arith_instr_unary_functor(atom!("sin"), arena, at, t) - } - &Instruction::Tan(ref at, t) => { - arith_instr_unary_functor(atom!("tan"), arena, at, t) - } - &Instruction::Log(ref at, t) => { - arith_instr_unary_functor(atom!("log"), arena, at, t) - } - &Instruction::Exp(ref at, t) => { - arith_instr_unary_functor(atom!("exp"), arena, at, t) - } - &Instruction::ACos(ref at, t) => { - arith_instr_unary_functor(atom!("acos"), arena, at, t) - } - &Instruction::ASin(ref at, t) => { - arith_instr_unary_functor(atom!("asin"), arena, at, t) - } - &Instruction::ATan(ref at, t) => { - arith_instr_unary_functor(atom!("atan"), arena, at, t) - } - &Instruction::Sqrt(ref at, t) => { - arith_instr_unary_functor(atom!("sqrt"), arena, at, t) - } - &Instruction::Abs(ref at, t) => { - arith_instr_unary_functor(atom!("abs"), arena, at, t) - } + &Instruction::Sign(ref at, t) => arith_instr_unary_functor(atom!("sign"), arena, at, t), + &Instruction::Cos(ref at, t) => arith_instr_unary_functor(atom!("cos"), arena, at, t), + &Instruction::Sin(ref at, t) => arith_instr_unary_functor(atom!("sin"), arena, at, t), + &Instruction::Tan(ref at, t) => arith_instr_unary_functor(atom!("tan"), arena, at, t), + &Instruction::Log(ref at, t) => arith_instr_unary_functor(atom!("log"), arena, at, t), + &Instruction::Exp(ref at, t) => arith_instr_unary_functor(atom!("exp"), arena, at, t), + &Instruction::ACos(ref at, t) => arith_instr_unary_functor(atom!("acos"), arena, at, t), + &Instruction::ASin(ref at, t) => arith_instr_unary_functor(atom!("asin"), arena, at, t), + &Instruction::ATan(ref at, t) => arith_instr_unary_functor(atom!("atan"), arena, at, t), + &Instruction::Sqrt(ref at, t) => arith_instr_unary_functor(atom!("sqrt"), arena, at, t), + &Instruction::Abs(ref at, t) => arith_instr_unary_functor(atom!("abs"), arena, at, t), &Instruction::Float(ref at, t) => { arith_instr_unary_functor(atom!("float"), arena, at, t) } @@ -522,24 +495,11 @@ impl Instruction { &Instruction::FloatIntegerPart(ref at, t) => { arith_instr_unary_functor(atom!("float_integer_part"), arena, at, t) } - &Instruction::Neg(ref at, t) => arith_instr_unary_functor( - atom!("-"), - arena, - at, - t, - ), - &Instruction::Plus(ref at, t) => arith_instr_unary_functor( - atom!("+"), - arena, - at, - t, - ), - &Instruction::BitwiseComplement(ref at, t) => arith_instr_unary_functor( - atom!("\\"), - arena, - at, - t, - ), + &Instruction::Neg(ref at, t) => arith_instr_unary_functor(atom!("-"), arena, at, t), + &Instruction::Plus(ref at, t) => arith_instr_unary_functor(atom!("+"), arena, at, t), + &Instruction::BitwiseComplement(ref at, t) => { + arith_instr_unary_functor(atom!("\\"), arena, at, t) + } &Instruction::IndexingCode(_) => { // this case is covered in enqueue_functors, which // should be called instead (to_functor is a private @@ -559,7 +519,10 @@ impl Instruction { functor!(atom!("call_default"), [atom_as_cell(name), fixnum(arity)]) } &Instruction::DefaultExecuteNamed(arity, name, ..) => { - functor!(atom!("execute_default"), [atom_as_cell(name), fixnum(arity)]) + functor!( + atom!("execute_default"), + [atom_as_cell(name), fixnum(arity)] + ) } &Instruction::CallN(arity) => { functor!(atom!("call_n"), [fixnum(arity)]) @@ -579,657 +542,664 @@ impl Instruction { &Instruction::ExecuteFastCallN(arity) => { functor!(atom!("execute_fast_call_n"), [fixnum(arity)]) } - &Instruction::CallTermGreaterThan | - &Instruction::CallTermLessThan | - &Instruction::CallTermGreaterThanOrEqual | - &Instruction::CallTermLessThanOrEqual | - &Instruction::CallTermEqual | - &Instruction::CallTermNotEqual | - &Instruction::CallNumberGreaterThan(..) | - &Instruction::CallNumberLessThan(..) | - &Instruction::CallNumberGreaterThanOrEqual(..) | - &Instruction::CallNumberLessThanOrEqual(..) | - &Instruction::CallNumberEqual(..) | - &Instruction::CallNumberNotEqual(..) | - &Instruction::CallIs(..) | - &Instruction::CallAcyclicTerm | - &Instruction::CallArg | - &Instruction::CallCompare | - &Instruction::CallCopyTerm | - &Instruction::CallFunctor | - &Instruction::CallGround | - &Instruction::CallKeySort | - &Instruction::CallSort | - &Instruction::CallGetNumber(_) => { + &Instruction::CallTermGreaterThan + | &Instruction::CallTermLessThan + | &Instruction::CallTermGreaterThanOrEqual + | &Instruction::CallTermLessThanOrEqual + | &Instruction::CallTermEqual + | &Instruction::CallTermNotEqual + | &Instruction::CallNumberGreaterThan(..) + | &Instruction::CallNumberLessThan(..) + | &Instruction::CallNumberGreaterThanOrEqual(..) + | &Instruction::CallNumberLessThanOrEqual(..) + | &Instruction::CallNumberEqual(..) + | &Instruction::CallNumberNotEqual(..) + | &Instruction::CallIs(..) + | &Instruction::CallAcyclicTerm + | &Instruction::CallArg + | &Instruction::CallCompare + | &Instruction::CallCopyTerm + | &Instruction::CallFunctor + | &Instruction::CallGround + | &Instruction::CallKeySort + | &Instruction::CallSort + | &Instruction::CallGetNumber(_) => { let (name, arity) = self.to_name_and_arity(); functor!(atom!("call"), [atom_as_cell(name), fixnum(arity)]) } // - &Instruction::ExecuteTermGreaterThan | - &Instruction::ExecuteTermLessThan | - &Instruction::ExecuteTermGreaterThanOrEqual | - &Instruction::ExecuteTermLessThanOrEqual | - &Instruction::ExecuteTermEqual | - &Instruction::ExecuteTermNotEqual | - &Instruction::ExecuteNumberGreaterThan(..) | - &Instruction::ExecuteNumberLessThan(..) | - &Instruction::ExecuteNumberGreaterThanOrEqual(..) | - &Instruction::ExecuteNumberLessThanOrEqual(..) | - &Instruction::ExecuteNumberEqual(..) | - &Instruction::ExecuteNumberNotEqual(..) | - &Instruction::ExecuteAcyclicTerm | - &Instruction::ExecuteArg | - &Instruction::ExecuteCompare | - &Instruction::ExecuteCopyTerm | - &Instruction::ExecuteFunctor | - &Instruction::ExecuteGround | - &Instruction::ExecuteIs(..) | - &Instruction::ExecuteKeySort | - &Instruction::ExecuteSort | - &Instruction::ExecuteGetNumber(_) => { + &Instruction::ExecuteTermGreaterThan + | &Instruction::ExecuteTermLessThan + | &Instruction::ExecuteTermGreaterThanOrEqual + | &Instruction::ExecuteTermLessThanOrEqual + | &Instruction::ExecuteTermEqual + | &Instruction::ExecuteTermNotEqual + | &Instruction::ExecuteNumberGreaterThan(..) + | &Instruction::ExecuteNumberLessThan(..) + | &Instruction::ExecuteNumberGreaterThanOrEqual(..) + | &Instruction::ExecuteNumberLessThanOrEqual(..) + | &Instruction::ExecuteNumberEqual(..) + | &Instruction::ExecuteNumberNotEqual(..) + | &Instruction::ExecuteAcyclicTerm + | &Instruction::ExecuteArg + | &Instruction::ExecuteCompare + | &Instruction::ExecuteCopyTerm + | &Instruction::ExecuteFunctor + | &Instruction::ExecuteGround + | &Instruction::ExecuteIs(..) + | &Instruction::ExecuteKeySort + | &Instruction::ExecuteSort + | &Instruction::ExecuteGetNumber(_) => { let (name, arity) = self.to_name_and_arity(); functor!(atom!("execute"), [atom_as_cell(name), fixnum(arity)]) } // - &Instruction::DefaultCallTermGreaterThan | - &Instruction::DefaultCallTermLessThan | - &Instruction::DefaultCallTermGreaterThanOrEqual | - &Instruction::DefaultCallTermLessThanOrEqual | - &Instruction::DefaultCallTermEqual | - &Instruction::DefaultCallTermNotEqual | - &Instruction::DefaultCallNumberGreaterThan(..) | - &Instruction::DefaultCallNumberLessThan(..) | - &Instruction::DefaultCallNumberGreaterThanOrEqual(..) | - &Instruction::DefaultCallNumberLessThanOrEqual(..) | - &Instruction::DefaultCallNumberEqual(..) | - &Instruction::DefaultCallNumberNotEqual(..) | - &Instruction::DefaultCallAcyclicTerm | - &Instruction::DefaultCallArg | - &Instruction::DefaultCallCompare | - &Instruction::DefaultCallCopyTerm | - &Instruction::DefaultCallFunctor | - &Instruction::DefaultCallGround | - &Instruction::DefaultCallIs(..) | - &Instruction::DefaultCallKeySort | - &Instruction::DefaultCallSort | - &Instruction::DefaultCallGetNumber(_) => { + &Instruction::DefaultCallTermGreaterThan + | &Instruction::DefaultCallTermLessThan + | &Instruction::DefaultCallTermGreaterThanOrEqual + | &Instruction::DefaultCallTermLessThanOrEqual + | &Instruction::DefaultCallTermEqual + | &Instruction::DefaultCallTermNotEqual + | &Instruction::DefaultCallNumberGreaterThan(..) + | &Instruction::DefaultCallNumberLessThan(..) + | &Instruction::DefaultCallNumberGreaterThanOrEqual(..) + | &Instruction::DefaultCallNumberLessThanOrEqual(..) + | &Instruction::DefaultCallNumberEqual(..) + | &Instruction::DefaultCallNumberNotEqual(..) + | &Instruction::DefaultCallAcyclicTerm + | &Instruction::DefaultCallArg + | &Instruction::DefaultCallCompare + | &Instruction::DefaultCallCopyTerm + | &Instruction::DefaultCallFunctor + | &Instruction::DefaultCallGround + | &Instruction::DefaultCallIs(..) + | &Instruction::DefaultCallKeySort + | &Instruction::DefaultCallSort + | &Instruction::DefaultCallGetNumber(_) => { let (name, arity) = self.to_name_and_arity(); functor!(atom!("call_default"), [atom_as_cell(name), fixnum(arity)]) } // - &Instruction::DefaultExecuteTermGreaterThan | - &Instruction::DefaultExecuteTermLessThan | - &Instruction::DefaultExecuteTermGreaterThanOrEqual | - &Instruction::DefaultExecuteTermLessThanOrEqual | - &Instruction::DefaultExecuteTermEqual | - &Instruction::DefaultExecuteTermNotEqual | - &Instruction::DefaultExecuteNumberGreaterThan(..) | - &Instruction::DefaultExecuteNumberLessThan(..) | - &Instruction::DefaultExecuteNumberGreaterThanOrEqual(..) | - &Instruction::DefaultExecuteNumberLessThanOrEqual(..) | - &Instruction::DefaultExecuteNumberEqual(..) | - &Instruction::DefaultExecuteNumberNotEqual(..) | - &Instruction::DefaultExecuteAcyclicTerm | - &Instruction::DefaultExecuteArg | - &Instruction::DefaultExecuteCompare | - &Instruction::DefaultExecuteCopyTerm | - &Instruction::DefaultExecuteFunctor | - &Instruction::DefaultExecuteGround | - &Instruction::DefaultExecuteIs(..) | - &Instruction::DefaultExecuteKeySort | - &Instruction::DefaultExecuteSort | - &Instruction::DefaultExecuteGetNumber(_) => { + &Instruction::DefaultExecuteTermGreaterThan + | &Instruction::DefaultExecuteTermLessThan + | &Instruction::DefaultExecuteTermGreaterThanOrEqual + | &Instruction::DefaultExecuteTermLessThanOrEqual + | &Instruction::DefaultExecuteTermEqual + | &Instruction::DefaultExecuteTermNotEqual + | &Instruction::DefaultExecuteNumberGreaterThan(..) + | &Instruction::DefaultExecuteNumberLessThan(..) + | &Instruction::DefaultExecuteNumberGreaterThanOrEqual(..) + | &Instruction::DefaultExecuteNumberLessThanOrEqual(..) + | &Instruction::DefaultExecuteNumberEqual(..) + | &Instruction::DefaultExecuteNumberNotEqual(..) + | &Instruction::DefaultExecuteAcyclicTerm + | &Instruction::DefaultExecuteArg + | &Instruction::DefaultExecuteCompare + | &Instruction::DefaultExecuteCopyTerm + | &Instruction::DefaultExecuteFunctor + | &Instruction::DefaultExecuteGround + | &Instruction::DefaultExecuteIs(..) + | &Instruction::DefaultExecuteKeySort + | &Instruction::DefaultExecuteSort + | &Instruction::DefaultExecuteGetNumber(_) => { let (name, arity) = self.to_name_and_arity(); - functor!(atom!("execute_default"), [atom_as_cell(name), fixnum(arity)]) + functor!( + atom!("execute_default"), + [atom_as_cell(name), fixnum(arity)] + ) } - &Instruction::CallIsAtom(r) | - &Instruction::CallIsAtomic(r) | - &Instruction::CallIsCompound(r) | - &Instruction::CallIsInteger(r) | - &Instruction::CallIsNumber(r) | - &Instruction::CallIsRational(r) | - &Instruction::CallIsFloat(r) | - &Instruction::CallIsNonVar(r) | - &Instruction::CallIsVar(r) => { + &Instruction::CallIsAtom(r) + | &Instruction::CallIsAtomic(r) + | &Instruction::CallIsCompound(r) + | &Instruction::CallIsInteger(r) + | &Instruction::CallIsNumber(r) + | &Instruction::CallIsRational(r) + | &Instruction::CallIsFloat(r) + | &Instruction::CallIsNonVar(r) + | &Instruction::CallIsVar(r) => { let (name, arity) = self.to_name_and_arity(); let rt_stub = reg_type_into_functor(r); - functor!(atom!("call"), [atom_as_cell(name), fixnum(arity), functor(rt_stub)]) + functor!( + atom!("call"), + [atom_as_cell(name), fixnum(arity), functor(rt_stub)] + ) } - &Instruction::ExecuteIsAtom(r) | - &Instruction::ExecuteIsAtomic(r) | - &Instruction::ExecuteIsCompound(r) | - &Instruction::ExecuteIsInteger(r) | - &Instruction::ExecuteIsNumber(r) | - &Instruction::ExecuteIsRational(r) | - &Instruction::ExecuteIsFloat(r) | - &Instruction::ExecuteIsNonVar(r) | - &Instruction::ExecuteIsVar(r) => { + &Instruction::ExecuteIsAtom(r) + | &Instruction::ExecuteIsAtomic(r) + | &Instruction::ExecuteIsCompound(r) + | &Instruction::ExecuteIsInteger(r) + | &Instruction::ExecuteIsNumber(r) + | &Instruction::ExecuteIsRational(r) + | &Instruction::ExecuteIsFloat(r) + | &Instruction::ExecuteIsNonVar(r) + | &Instruction::ExecuteIsVar(r) => { let (name, arity) = self.to_name_and_arity(); let rt_stub = reg_type_into_functor(r); - functor!(atom!("execute"), [atom_as_cell(name), fixnum(arity), functor(rt_stub)]) + functor!( + atom!("execute"), + [atom_as_cell(name), fixnum(arity), functor(rt_stub)] + ) } // - &Instruction::CallAtomChars | - &Instruction::CallAtomCodes | - &Instruction::CallAtomLength | - &Instruction::CallBindFromRegister | - &Instruction::CallContinuation | - &Instruction::CallCharCode | - &Instruction::CallCharType | - &Instruction::CallCharsToNumber | - &Instruction::CallCodesToNumber | - &Instruction::CallCopyTermWithoutAttrVars | - &Instruction::CallCheckCutPoint | - &Instruction::CallClose | - &Instruction::CallCopyToLiftedHeap | - &Instruction::CallCreatePartialString | - &Instruction::CallCurrentHostname | - &Instruction::CallCurrentInput | - &Instruction::CallCurrentOutput | - &Instruction::CallDirectoryFiles | - &Instruction::CallFileSize | - &Instruction::CallFileExists | - &Instruction::CallDirectoryExists | - &Instruction::CallDirectorySeparator | - &Instruction::CallMakeDirectory | - &Instruction::CallMakeDirectoryPath | - &Instruction::CallDeleteFile | - &Instruction::CallRenameFile | - &Instruction::CallFileCopy | - &Instruction::CallWorkingDirectory | - &Instruction::CallDeleteDirectory | - &Instruction::CallPathCanonical | - &Instruction::CallFileTime | - &Instruction::CallDynamicModuleResolution(..) | - &Instruction::CallPrepareCallClause(..) | - &Instruction::CallCompileInlineOrExpandedGoal | - &Instruction::CallIsExpandedOrInlined | - &Instruction::CallGetClauseP | - &Instruction::CallInvokeClauseAtP | - &Instruction::CallGetFromAttributedVarList | - &Instruction::CallPutToAttributedVarList | - &Instruction::CallDeleteFromAttributedVarList | - &Instruction::CallDeleteAllAttributesFromVar | - &Instruction::CallUnattributedVar | - &Instruction::CallGetDBRefs | - &Instruction::CallKeySortWithConstantVarOrdering | - &Instruction::CallInferenceLimitExceeded | - &Instruction::CallFetchGlobalVar | - &Instruction::CallFirstStream | - &Instruction::CallFlushOutput | - &Instruction::CallGetByte | - &Instruction::CallGetChar | - &Instruction::CallGetNChars | - &Instruction::CallGetCode | - &Instruction::CallGetSingleChar | - &Instruction::CallTruncateIfNoLiftedHeapGrowthDiff | - &Instruction::CallTruncateIfNoLiftedHeapGrowth | - &Instruction::CallGetAttributedVariableList | - &Instruction::CallGetAttrVarQueueDelimiter | - &Instruction::CallGetAttrVarQueueBeyond | - &Instruction::CallGetBValue | - &Instruction::CallGetContinuationChunk | - &Instruction::CallGetNextOpDBRef | - &Instruction::CallLookupDBRef | - &Instruction::CallIsPartialString | - &Instruction::CallHalt | - &Instruction::CallGetLiftedHeapFromOffset | - &Instruction::CallGetLiftedHeapFromOffsetDiff | - &Instruction::CallGetSCCCleaner | - &Instruction::CallHeadIsDynamic | - &Instruction::CallInstallSCCCleaner | - &Instruction::CallInstallInferenceCounter | - &Instruction::CallInferenceCount | - &Instruction::CallLiftedHeapLength | - &Instruction::CallLoadLibraryAsStream | - &Instruction::CallModuleExists | - &Instruction::CallNextEP | - &Instruction::CallNoSuchPredicate | - &Instruction::CallNumberToChars | - &Instruction::CallNumberToCodes | - &Instruction::CallOpDeclaration | - &Instruction::CallOpen | - &Instruction::CallSetStreamOptions | - &Instruction::CallNextStream | - &Instruction::CallPartialStringTail | - &Instruction::CallPeekByte | - &Instruction::CallPeekChar | - &Instruction::CallPeekCode | - &Instruction::CallPointsToContinuationResetMarker | - &Instruction::CallPutByte | - &Instruction::CallPutChar | - &Instruction::CallPutChars | - &Instruction::CallPutCode | - &Instruction::CallReadQueryTerm | - &Instruction::CallReadTerm | - &Instruction::CallRedoAttrVarBinding | - &Instruction::CallRemoveCallPolicyCheck | - &Instruction::CallRemoveInferenceCounter | - &Instruction::CallResetContinuationMarker | - &Instruction::CallRestoreCutPolicy | - &Instruction::CallSetCutPoint(..) | - &Instruction::CallSetInput | - &Instruction::CallSetOutput | - &Instruction::CallStoreBacktrackableGlobalVar | - &Instruction::CallStoreGlobalVar | - &Instruction::CallStreamProperty | - &Instruction::CallSetStreamPosition | - &Instruction::CallInferenceLevel | - &Instruction::CallCleanUpBlock | - &Instruction::CallFail | - &Instruction::CallGetBall | - &Instruction::CallGetCurrentBlock | - &Instruction::CallGetCurrentSCCBlock | - &Instruction::CallGetCutPoint | - &Instruction::CallGetDoubleQuotes | - &Instruction::CallGetUnknown | - &Instruction::CallInstallNewBlock | - &Instruction::CallRandomInteger | - &Instruction::CallMaybe | - &Instruction::CallCpuNow | - &Instruction::CallDeterministicLengthRundown | - &Instruction::CallHttpOpen | - &Instruction::CallHttpListen | - &Instruction::CallHttpAccept | - &Instruction::CallHttpAnswer | - &Instruction::CallLoadForeignLib | - &Instruction::CallForeignCall | - &Instruction::CallDefineForeignStruct | - &Instruction::CallFfiAllocate | - &Instruction::CallFfiReadPtr | - &Instruction::CallFfiDeallocate | - &Instruction::CallJsEval | - &Instruction::CallPredicateDefined | - &Instruction::CallStripModule | - &Instruction::CallCurrentTime | - &Instruction::CallQuotedToken | - &Instruction::CallReadFromChars | - &Instruction::CallReadTermFromChars | - &Instruction::CallResetBlock | - &Instruction::CallResetSCCBlock | - &Instruction::CallReturnFromVerifyAttr | - &Instruction::CallSetBall | - &Instruction::CallPushBallStack | - &Instruction::CallPopBallStack | - &Instruction::CallPopFromBallStack | - &Instruction::CallSetCutPointByDefault(..) | - &Instruction::CallSetDoubleQuotes | - &Instruction::CallSetUnknown | - &Instruction::CallSetSeed | - &Instruction::CallSkipMaxList | - &Instruction::CallSleep | - &Instruction::CallSocketClientOpen | - &Instruction::CallSocketServerOpen | - &Instruction::CallSocketServerAccept | - &Instruction::CallSocketServerClose | - &Instruction::CallTLSAcceptClient | - &Instruction::CallTLSClientConnect | - &Instruction::CallSucceed | - &Instruction::CallTermAttributedVariables | - &Instruction::CallTermVariables | - &Instruction::CallTermVariablesUnderMaxDepth | - &Instruction::CallTruncateLiftedHeapTo | - &Instruction::CallUnifyWithOccursCheck | - &Instruction::CallUnwindEnvironments | - &Instruction::CallUnwindStack | - &Instruction::CallWAMInstructions | - &Instruction::CallInlinedInstructions | - &Instruction::CallWriteTerm | - &Instruction::CallWriteTermToChars | - &Instruction::CallScryerPrologVersion | - &Instruction::CallCryptoRandomByte | - &Instruction::CallCryptoDataHash | - &Instruction::CallCryptoHMAC | - &Instruction::CallCryptoDataHKDF | - &Instruction::CallCryptoPasswordHash | - &Instruction::CallCryptoCurveScalarMult | - &Instruction::CallCurve25519ScalarMult | - &Instruction::CallFirstNonOctet | - &Instruction::CallLoadHTML | - &Instruction::CallLoadXML | - &Instruction::CallGetEnv | - &Instruction::CallSetEnv | - &Instruction::CallUnsetEnv | - &Instruction::CallShell | - &Instruction::CallProcessCreate | - &Instruction::CallProcessId | - &Instruction::CallProcessWait | - &Instruction::CallProcessKill | - &Instruction::CallProcessRelease | - &Instruction::CallPid | - &Instruction::CallCharsBase64 | - &Instruction::CallDevourWhitespace | - &Instruction::CallIsSTOEnabled | - &Instruction::CallSetSTOAsUnify | - &Instruction::CallSetNSTOAsUnify | - &Instruction::CallSetSTOWithErrorAsUnify | - &Instruction::CallHomeDirectory | - &Instruction::CallDebugHook | - &Instruction::CallAddDiscontiguousPredicate | - &Instruction::CallAddDynamicPredicate | - &Instruction::CallAddMultifilePredicate | - &Instruction::CallAddGoalExpansionClause | - &Instruction::CallAddTermExpansionClause | - &Instruction::CallAddInSituFilenameModule | - &Instruction::CallClauseToEvacuable | - &Instruction::CallScopedClauseToEvacuable | - &Instruction::CallConcludeLoad | - &Instruction::CallDeclareModule | - &Instruction::CallLoadCompiledLibrary | - &Instruction::CallLoadContextSource | - &Instruction::CallLoadContextFile | - &Instruction::CallLoadContextDirectory | - &Instruction::CallLoadContextModule | - &Instruction::CallLoadContextStream | - &Instruction::CallPopLoadContext | - &Instruction::CallPopLoadStatePayload | - &Instruction::CallPushLoadContext | - &Instruction::CallPushLoadStatePayload | - &Instruction::CallUseModule | - &Instruction::CallBuiltInProperty | - &Instruction::CallMetaPredicateProperty | - &Instruction::CallMultifileProperty | - &Instruction::CallDiscontiguousProperty | - &Instruction::CallDynamicProperty | - &Instruction::CallAbolishClause | - &Instruction::CallAsserta | - &Instruction::CallAssertz | - &Instruction::CallRetract | - &Instruction::CallIsConsistentWithTermQueue | - &Instruction::CallFlushTermQueue | - &Instruction::CallRemoveModuleExports | - &Instruction::CallAddNonCountedBacktracking | - &Instruction::CallPopCount | - &Instruction::CallArgv | - &Instruction::CallEd25519SignRaw | - &Instruction::CallEd25519VerifyRaw | - &Instruction::CallEd25519SeedToPublicKey => { + &Instruction::CallAtomChars + | &Instruction::CallAtomCodes + | &Instruction::CallAtomLength + | &Instruction::CallBindFromRegister + | &Instruction::CallContinuation + | &Instruction::CallCharCode + | &Instruction::CallCharType + | &Instruction::CallCharsToNumber + | &Instruction::CallCodesToNumber + | &Instruction::CallCopyTermWithoutAttrVars + | &Instruction::CallCheckCutPoint + | &Instruction::CallClose + | &Instruction::CallCopyToLiftedHeap + | &Instruction::CallCreatePartialString + | &Instruction::CallCurrentHostname + | &Instruction::CallCurrentInput + | &Instruction::CallCurrentOutput + | &Instruction::CallDirectoryFiles + | &Instruction::CallFileSize + | &Instruction::CallFileExists + | &Instruction::CallDirectoryExists + | &Instruction::CallDirectorySeparator + | &Instruction::CallMakeDirectory + | &Instruction::CallMakeDirectoryPath + | &Instruction::CallDeleteFile + | &Instruction::CallRenameFile + | &Instruction::CallFileCopy + | &Instruction::CallWorkingDirectory + | &Instruction::CallDeleteDirectory + | &Instruction::CallPathCanonical + | &Instruction::CallFileTime + | &Instruction::CallDynamicModuleResolution(..) + | &Instruction::CallPrepareCallClause(..) + | &Instruction::CallCompileInlineOrExpandedGoal + | &Instruction::CallIsExpandedOrInlined + | &Instruction::CallGetClauseP + | &Instruction::CallInvokeClauseAtP + | &Instruction::CallGetFromAttributedVarList + | &Instruction::CallPutToAttributedVarList + | &Instruction::CallDeleteFromAttributedVarList + | &Instruction::CallDeleteAllAttributesFromVar + | &Instruction::CallUnattributedVar + | &Instruction::CallGetDBRefs + | &Instruction::CallKeySortWithConstantVarOrdering + | &Instruction::CallInferenceLimitExceeded + | &Instruction::CallFetchGlobalVar + | &Instruction::CallFirstStream + | &Instruction::CallFlushOutput + | &Instruction::CallGetByte + | &Instruction::CallGetChar + | &Instruction::CallGetNChars + | &Instruction::CallGetCode + | &Instruction::CallGetSingleChar + | &Instruction::CallTruncateIfNoLiftedHeapGrowthDiff + | &Instruction::CallTruncateIfNoLiftedHeapGrowth + | &Instruction::CallGetAttributedVariableList + | &Instruction::CallGetAttrVarQueueDelimiter + | &Instruction::CallGetAttrVarQueueBeyond + | &Instruction::CallGetBValue + | &Instruction::CallGetContinuationChunk + | &Instruction::CallGetNextOpDBRef + | &Instruction::CallLookupDBRef + | &Instruction::CallIsPartialString + | &Instruction::CallHalt + | &Instruction::CallGetLiftedHeapFromOffset + | &Instruction::CallGetLiftedHeapFromOffsetDiff + | &Instruction::CallGetSCCCleaner + | &Instruction::CallHeadIsDynamic + | &Instruction::CallInstallSCCCleaner + | &Instruction::CallInstallInferenceCounter + | &Instruction::CallInferenceCount + | &Instruction::CallLiftedHeapLength + | &Instruction::CallLoadLibraryAsStream + | &Instruction::CallModuleExists + | &Instruction::CallNextEP + | &Instruction::CallNoSuchPredicate + | &Instruction::CallNumberToChars + | &Instruction::CallNumberToCodes + | &Instruction::CallOpDeclaration + | &Instruction::CallOpen + | &Instruction::CallSetStreamOptions + | &Instruction::CallNextStream + | &Instruction::CallPartialStringTail + | &Instruction::CallPeekByte + | &Instruction::CallPeekChar + | &Instruction::CallPeekCode + | &Instruction::CallPointsToContinuationResetMarker + | &Instruction::CallPutByte + | &Instruction::CallPutChar + | &Instruction::CallPutChars + | &Instruction::CallPutCode + | &Instruction::CallReadQueryTerm + | &Instruction::CallReadTerm + | &Instruction::CallRedoAttrVarBinding + | &Instruction::CallRemoveCallPolicyCheck + | &Instruction::CallRemoveInferenceCounter + | &Instruction::CallResetContinuationMarker + | &Instruction::CallRestoreCutPolicy + | &Instruction::CallSetCutPoint(..) + | &Instruction::CallSetInput + | &Instruction::CallSetOutput + | &Instruction::CallStoreBacktrackableGlobalVar + | &Instruction::CallStoreGlobalVar + | &Instruction::CallStreamProperty + | &Instruction::CallSetStreamPosition + | &Instruction::CallInferenceLevel + | &Instruction::CallCleanUpBlock + | &Instruction::CallFail + | &Instruction::CallGetBall + | &Instruction::CallGetCurrentBlock + | &Instruction::CallGetCurrentSCCBlock + | &Instruction::CallGetCutPoint + | &Instruction::CallGetDoubleQuotes + | &Instruction::CallGetUnknown + | &Instruction::CallInstallNewBlock + | &Instruction::CallRandomInteger + | &Instruction::CallMaybe + | &Instruction::CallCpuNow + | &Instruction::CallDeterministicLengthRundown + | &Instruction::CallHttpOpen + | &Instruction::CallHttpListen + | &Instruction::CallHttpAccept + | &Instruction::CallHttpAnswer + | &Instruction::CallLoadForeignLib + | &Instruction::CallForeignCall + | &Instruction::CallDefineForeignStruct + | &Instruction::CallFfiAllocate + | &Instruction::CallFfiReadPtr + | &Instruction::CallFfiDeallocate + | &Instruction::CallJsEval + | &Instruction::CallPredicateDefined + | &Instruction::CallStripModule + | &Instruction::CallCurrentTime + | &Instruction::CallQuotedToken + | &Instruction::CallReadFromChars + | &Instruction::CallReadTermFromChars + | &Instruction::CallResetBlock + | &Instruction::CallResetSCCBlock + | &Instruction::CallReturnFromVerifyAttr + | &Instruction::CallSetBall + | &Instruction::CallPushBallStack + | &Instruction::CallPopBallStack + | &Instruction::CallPopFromBallStack + | &Instruction::CallSetCutPointByDefault(..) + | &Instruction::CallSetDoubleQuotes + | &Instruction::CallSetUnknown + | &Instruction::CallSetSeed + | &Instruction::CallSkipMaxList + | &Instruction::CallSleep + | &Instruction::CallSocketClientOpen + | &Instruction::CallSocketServerOpen + | &Instruction::CallSocketServerAccept + | &Instruction::CallSocketServerClose + | &Instruction::CallTLSAcceptClient + | &Instruction::CallTLSClientConnect + | &Instruction::CallSucceed + | &Instruction::CallTermAttributedVariables + | &Instruction::CallTermVariables + | &Instruction::CallTermVariablesUnderMaxDepth + | &Instruction::CallTruncateLiftedHeapTo + | &Instruction::CallUnifyWithOccursCheck + | &Instruction::CallUnwindEnvironments + | &Instruction::CallUnwindStack + | &Instruction::CallWAMInstructions + | &Instruction::CallInlinedInstructions + | &Instruction::CallWriteTerm + | &Instruction::CallWriteTermToChars + | &Instruction::CallScryerPrologVersion + | &Instruction::CallCryptoRandomByte + | &Instruction::CallCryptoDataHash + | &Instruction::CallCryptoHMAC + | &Instruction::CallCryptoDataHKDF + | &Instruction::CallCryptoPasswordHash + | &Instruction::CallCryptoCurveScalarMult + | &Instruction::CallCurve25519ScalarMult + | &Instruction::CallFirstNonOctet + | &Instruction::CallLoadHTML + | &Instruction::CallLoadXML + | &Instruction::CallGetEnv + | &Instruction::CallSetEnv + | &Instruction::CallUnsetEnv + | &Instruction::CallShell + | &Instruction::CallProcessCreate + | &Instruction::CallProcessId + | &Instruction::CallProcessWait + | &Instruction::CallProcessKill + | &Instruction::CallProcessRelease + | &Instruction::CallPid + | &Instruction::CallCharsBase64 + | &Instruction::CallDevourWhitespace + | &Instruction::CallIsSTOEnabled + | &Instruction::CallSetSTOAsUnify + | &Instruction::CallSetNSTOAsUnify + | &Instruction::CallSetSTOWithErrorAsUnify + | &Instruction::CallHomeDirectory + | &Instruction::CallDebugHook + | &Instruction::CallAddDiscontiguousPredicate + | &Instruction::CallAddDynamicPredicate + | &Instruction::CallAddMultifilePredicate + | &Instruction::CallAddGoalExpansionClause + | &Instruction::CallAddTermExpansionClause + | &Instruction::CallAddInSituFilenameModule + | &Instruction::CallClauseToEvacuable + | &Instruction::CallScopedClauseToEvacuable + | &Instruction::CallConcludeLoad + | &Instruction::CallDeclareModule + | &Instruction::CallLoadCompiledLibrary + | &Instruction::CallLoadContextSource + | &Instruction::CallLoadContextFile + | &Instruction::CallLoadContextDirectory + | &Instruction::CallLoadContextModule + | &Instruction::CallLoadContextStream + | &Instruction::CallPopLoadContext + | &Instruction::CallPopLoadStatePayload + | &Instruction::CallPushLoadContext + | &Instruction::CallPushLoadStatePayload + | &Instruction::CallUseModule + | &Instruction::CallBuiltInProperty + | &Instruction::CallMetaPredicateProperty + | &Instruction::CallMultifileProperty + | &Instruction::CallDiscontiguousProperty + | &Instruction::CallDynamicProperty + | &Instruction::CallAbolishClause + | &Instruction::CallAsserta + | &Instruction::CallAssertz + | &Instruction::CallRetract + | &Instruction::CallIsConsistentWithTermQueue + | &Instruction::CallFlushTermQueue + | &Instruction::CallRemoveModuleExports + | &Instruction::CallAddNonCountedBacktracking + | &Instruction::CallPopCount + | &Instruction::CallArgv + | &Instruction::CallEd25519SignRaw + | &Instruction::CallEd25519VerifyRaw + | &Instruction::CallEd25519SeedToPublicKey => { let (name, arity) = self.to_name_and_arity(); functor!(atom!("call"), [atom_as_cell(name), fixnum(arity)]) } // #[cfg(feature = "crypto-full")] - &Instruction::CallCryptoDataEncrypt | - &Instruction::CallCryptoDataDecrypt => { + &Instruction::CallCryptoDataEncrypt | &Instruction::CallCryptoDataDecrypt => { let (name, arity) = self.to_name_and_arity(); functor!(atom!("call"), [atom_as_cell(name), fixnum(arity)]) } // - &Instruction::CallBeta | - &Instruction::CallBetaI | - &Instruction::CallInvBetaI | - &Instruction::CallGamma | - &Instruction::CallGammP | - &Instruction::CallGammQ | - &Instruction::CallInvGammP | - &Instruction::CallLnGamma | - &Instruction::CallErf | - &Instruction::CallErfc | - &Instruction::CallInvErf | - &Instruction::CallInvErfc => { + &Instruction::CallBeta + | &Instruction::CallBetaI + | &Instruction::CallInvBetaI + | &Instruction::CallGamma + | &Instruction::CallGammP + | &Instruction::CallGammQ + | &Instruction::CallInvGammP + | &Instruction::CallLnGamma + | &Instruction::CallErf + | &Instruction::CallErfc + | &Instruction::CallInvErf + | &Instruction::CallInvErfc => { let (name, arity) = self.to_name_and_arity(); functor!(atom!("call"), [atom_as_cell(name), fixnum(arity)]) } - &Instruction::ExecuteAtomChars | - &Instruction::ExecuteAtomCodes | - &Instruction::ExecuteAtomLength | - &Instruction::ExecuteBindFromRegister | - &Instruction::ExecuteContinuation | - &Instruction::ExecuteCharCode | - &Instruction::ExecuteCharType | - &Instruction::ExecuteCharsToNumber | - &Instruction::ExecuteCodesToNumber | - &Instruction::ExecuteCopyTermWithoutAttrVars | - &Instruction::ExecuteCheckCutPoint | - &Instruction::ExecuteClose | - &Instruction::ExecuteCopyToLiftedHeap | - &Instruction::ExecuteCreatePartialString | - &Instruction::ExecuteCurrentHostname | - &Instruction::ExecuteCurrentInput | - &Instruction::ExecuteCurrentOutput | - &Instruction::ExecuteDirectoryFiles | - &Instruction::ExecuteFileSize | - &Instruction::ExecuteFileExists | - &Instruction::ExecuteDirectoryExists | - &Instruction::ExecuteDirectorySeparator | - &Instruction::ExecuteMakeDirectory | - &Instruction::ExecuteMakeDirectoryPath | - &Instruction::ExecuteDeleteFile | - &Instruction::ExecuteRenameFile | - &Instruction::ExecuteFileCopy | - &Instruction::ExecuteWorkingDirectory | - &Instruction::ExecuteDeleteDirectory | - &Instruction::ExecutePathCanonical | - &Instruction::ExecuteFileTime | - &Instruction::ExecuteDynamicModuleResolution(..) | - &Instruction::ExecutePrepareCallClause(..) | - &Instruction::ExecuteCompileInlineOrExpandedGoal | - &Instruction::ExecuteIsExpandedOrInlined | - &Instruction::ExecuteGetClauseP | - &Instruction::ExecuteInvokeClauseAtP | - &Instruction::ExecuteGetFromAttributedVarList | - &Instruction::ExecutePutToAttributedVarList | - &Instruction::ExecuteDeleteFromAttributedVarList | - &Instruction::ExecuteDeleteAllAttributesFromVar | - &Instruction::ExecuteUnattributedVar | - &Instruction::ExecuteGetDBRefs | - &Instruction::ExecuteKeySortWithConstantVarOrdering | - &Instruction::ExecuteInferenceLimitExceeded | - &Instruction::ExecuteFetchGlobalVar | - &Instruction::ExecuteFirstStream | - &Instruction::ExecuteFlushOutput | - &Instruction::ExecuteGetByte | - &Instruction::ExecuteGetChar | - &Instruction::ExecuteGetNChars | - &Instruction::ExecuteGetCode | - &Instruction::ExecuteGetSingleChar | - &Instruction::ExecuteTruncateIfNoLiftedHeapGrowthDiff | - &Instruction::ExecuteTruncateIfNoLiftedHeapGrowth | - &Instruction::ExecuteGetAttributedVariableList | - &Instruction::ExecuteGetAttrVarQueueDelimiter | - &Instruction::ExecuteGetAttrVarQueueBeyond | - &Instruction::ExecuteGetBValue | - &Instruction::ExecuteGetContinuationChunk | - &Instruction::ExecuteGetNextOpDBRef | - &Instruction::ExecuteLookupDBRef | - &Instruction::ExecuteIsPartialString | - &Instruction::ExecuteHalt | - &Instruction::ExecuteGetLiftedHeapFromOffset | - &Instruction::ExecuteGetLiftedHeapFromOffsetDiff | - &Instruction::ExecuteGetSCCCleaner | - &Instruction::ExecuteHeadIsDynamic | - &Instruction::ExecuteInstallSCCCleaner | - &Instruction::ExecuteInstallInferenceCounter | - &Instruction::ExecuteInferenceCount | - &Instruction::ExecuteLiftedHeapLength | - &Instruction::ExecuteLoadLibraryAsStream | - &Instruction::ExecuteModuleExists | - &Instruction::ExecuteNextEP | - &Instruction::ExecuteNoSuchPredicate | - &Instruction::ExecuteNumberToChars | - &Instruction::ExecuteNumberToCodes | - &Instruction::ExecuteOpDeclaration | - &Instruction::ExecuteOpen | - &Instruction::ExecuteSetStreamOptions | - &Instruction::ExecuteNextStream | - &Instruction::ExecutePartialStringTail | - &Instruction::ExecutePeekByte | - &Instruction::ExecutePeekChar | - &Instruction::ExecutePeekCode | - &Instruction::ExecutePointsToContinuationResetMarker | - &Instruction::ExecutePutByte | - &Instruction::ExecutePutChar | - &Instruction::ExecutePutChars | - &Instruction::ExecutePutCode | - &Instruction::ExecuteReadQueryTerm | - &Instruction::ExecuteReadTerm | - &Instruction::ExecuteRedoAttrVarBinding | - &Instruction::ExecuteRemoveCallPolicyCheck | - &Instruction::ExecuteRemoveInferenceCounter | - &Instruction::ExecuteResetContinuationMarker | - &Instruction::ExecuteRestoreCutPolicy | - &Instruction::ExecuteSetCutPoint(_) | - &Instruction::ExecuteSetInput | - &Instruction::ExecuteSetOutput | - &Instruction::ExecuteStoreBacktrackableGlobalVar | - &Instruction::ExecuteStoreGlobalVar | - &Instruction::ExecuteStreamProperty | - &Instruction::ExecuteSetStreamPosition | - &Instruction::ExecuteInferenceLevel | - &Instruction::ExecuteCleanUpBlock | - &Instruction::ExecuteFail | - &Instruction::ExecuteGetBall | - &Instruction::ExecuteGetCurrentBlock | - &Instruction::ExecuteGetCurrentSCCBlock | - &Instruction::ExecuteGetCutPoint | - &Instruction::ExecuteGetDoubleQuotes | - &Instruction::ExecuteGetUnknown | - &Instruction::ExecuteInstallNewBlock | - &Instruction::ExecuteRandomInteger | - &Instruction::ExecuteMaybe | - &Instruction::ExecuteCpuNow | - &Instruction::ExecuteDeterministicLengthRundown | - &Instruction::ExecuteHttpOpen | - &Instruction::ExecuteHttpListen | - &Instruction::ExecuteHttpAccept | - &Instruction::ExecuteHttpAnswer | - &Instruction::ExecuteLoadForeignLib | - &Instruction::ExecuteForeignCall | - &Instruction::ExecuteDefineForeignStruct | - &Instruction::ExecuteFfiAllocate | - &Instruction::ExecuteFfiReadPtr | - &Instruction::ExecuteFfiDeallocate | - &Instruction::ExecuteJsEval | - &Instruction::ExecutePredicateDefined | - &Instruction::ExecuteStripModule | - &Instruction::ExecuteCurrentTime | - &Instruction::ExecuteQuotedToken | - &Instruction::ExecuteReadFromChars | - &Instruction::ExecuteReadTermFromChars | - &Instruction::ExecuteResetBlock | - &Instruction::ExecuteResetSCCBlock | - &Instruction::ExecuteReturnFromVerifyAttr | - &Instruction::ExecuteSetBall | - &Instruction::ExecutePushBallStack | - &Instruction::ExecutePopBallStack | - &Instruction::ExecutePopFromBallStack | - &Instruction::ExecuteSetCutPointByDefault(_) | - &Instruction::ExecuteSetDoubleQuotes | - &Instruction::ExecuteSetUnknown | - &Instruction::ExecuteSetSeed | - &Instruction::ExecuteSkipMaxList | - &Instruction::ExecuteSleep | - &Instruction::ExecuteSocketClientOpen | - &Instruction::ExecuteSocketServerOpen | - &Instruction::ExecuteSocketServerAccept | - &Instruction::ExecuteSocketServerClose | - &Instruction::ExecuteTLSAcceptClient | - &Instruction::ExecuteTLSClientConnect | - &Instruction::ExecuteSucceed | - &Instruction::ExecuteTermAttributedVariables | - &Instruction::ExecuteTermVariables | - &Instruction::ExecuteTermVariablesUnderMaxDepth | - &Instruction::ExecuteTruncateLiftedHeapTo | - &Instruction::ExecuteUnifyWithOccursCheck | - &Instruction::ExecuteUnwindEnvironments | - &Instruction::ExecuteUnwindStack | - &Instruction::ExecuteWAMInstructions | - &Instruction::ExecuteInlinedInstructions | - &Instruction::ExecuteWriteTerm | - &Instruction::ExecuteWriteTermToChars | - &Instruction::ExecuteScryerPrologVersion | - &Instruction::ExecuteCryptoRandomByte | - &Instruction::ExecuteCryptoDataHash | - &Instruction::ExecuteCryptoHMAC | - &Instruction::ExecuteCryptoDataHKDF | - &Instruction::ExecuteCryptoPasswordHash | - &Instruction::ExecuteCryptoCurveScalarMult | - &Instruction::ExecuteCurve25519ScalarMult | - &Instruction::ExecuteFirstNonOctet | - &Instruction::ExecuteLoadHTML | - &Instruction::ExecuteLoadXML | - &Instruction::ExecuteGetEnv | - &Instruction::ExecuteSetEnv | - &Instruction::ExecuteUnsetEnv | - &Instruction::ExecuteShell | - &Instruction::ExecuteProcessCreate | - &Instruction::ExecuteProcessId | - &Instruction::ExecuteProcessWait | - &Instruction::ExecuteProcessKill | - &Instruction::ExecuteProcessRelease | - &Instruction::ExecutePid | - &Instruction::ExecuteCharsBase64 | - &Instruction::ExecuteDevourWhitespace | - &Instruction::ExecuteIsSTOEnabled | - &Instruction::ExecuteSetSTOAsUnify | - &Instruction::ExecuteSetNSTOAsUnify | - &Instruction::ExecuteSetSTOWithErrorAsUnify | - &Instruction::ExecuteHomeDirectory | - &Instruction::ExecuteDebugHook | - &Instruction::ExecuteAddDiscontiguousPredicate | - &Instruction::ExecuteAddDynamicPredicate | - &Instruction::ExecuteAddMultifilePredicate | - &Instruction::ExecuteAddGoalExpansionClause | - &Instruction::ExecuteAddTermExpansionClause | - &Instruction::ExecuteAddInSituFilenameModule | - &Instruction::ExecuteClauseToEvacuable | - &Instruction::ExecuteScopedClauseToEvacuable | - &Instruction::ExecuteConcludeLoad | - &Instruction::ExecuteDeclareModule | - &Instruction::ExecuteLoadCompiledLibrary | - &Instruction::ExecuteLoadContextSource | - &Instruction::ExecuteLoadContextFile | - &Instruction::ExecuteLoadContextDirectory | - &Instruction::ExecuteLoadContextModule | - &Instruction::ExecuteLoadContextStream | - &Instruction::ExecutePopLoadContext | - &Instruction::ExecutePopLoadStatePayload | - &Instruction::ExecutePushLoadContext | - &Instruction::ExecutePushLoadStatePayload | - &Instruction::ExecuteUseModule | - &Instruction::ExecuteBuiltInProperty | - &Instruction::ExecuteMetaPredicateProperty | - &Instruction::ExecuteMultifileProperty | - &Instruction::ExecuteDiscontiguousProperty | - &Instruction::ExecuteDynamicProperty | - &Instruction::ExecuteAbolishClause | - &Instruction::ExecuteAsserta | - &Instruction::ExecuteAssertz | - &Instruction::ExecuteRetract | - &Instruction::ExecuteIsConsistentWithTermQueue | - &Instruction::ExecuteFlushTermQueue | - &Instruction::ExecuteRemoveModuleExports | - &Instruction::ExecuteAddNonCountedBacktracking | - &Instruction::ExecutePopCount | - &Instruction::ExecuteArgv | - &Instruction::ExecuteEd25519SignRaw | - &Instruction::ExecuteEd25519VerifyRaw | - &Instruction::ExecuteEd25519SeedToPublicKey => { + &Instruction::ExecuteAtomChars + | &Instruction::ExecuteAtomCodes + | &Instruction::ExecuteAtomLength + | &Instruction::ExecuteBindFromRegister + | &Instruction::ExecuteContinuation + | &Instruction::ExecuteCharCode + | &Instruction::ExecuteCharType + | &Instruction::ExecuteCharsToNumber + | &Instruction::ExecuteCodesToNumber + | &Instruction::ExecuteCopyTermWithoutAttrVars + | &Instruction::ExecuteCheckCutPoint + | &Instruction::ExecuteClose + | &Instruction::ExecuteCopyToLiftedHeap + | &Instruction::ExecuteCreatePartialString + | &Instruction::ExecuteCurrentHostname + | &Instruction::ExecuteCurrentInput + | &Instruction::ExecuteCurrentOutput + | &Instruction::ExecuteDirectoryFiles + | &Instruction::ExecuteFileSize + | &Instruction::ExecuteFileExists + | &Instruction::ExecuteDirectoryExists + | &Instruction::ExecuteDirectorySeparator + | &Instruction::ExecuteMakeDirectory + | &Instruction::ExecuteMakeDirectoryPath + | &Instruction::ExecuteDeleteFile + | &Instruction::ExecuteRenameFile + | &Instruction::ExecuteFileCopy + | &Instruction::ExecuteWorkingDirectory + | &Instruction::ExecuteDeleteDirectory + | &Instruction::ExecutePathCanonical + | &Instruction::ExecuteFileTime + | &Instruction::ExecuteDynamicModuleResolution(..) + | &Instruction::ExecutePrepareCallClause(..) + | &Instruction::ExecuteCompileInlineOrExpandedGoal + | &Instruction::ExecuteIsExpandedOrInlined + | &Instruction::ExecuteGetClauseP + | &Instruction::ExecuteInvokeClauseAtP + | &Instruction::ExecuteGetFromAttributedVarList + | &Instruction::ExecutePutToAttributedVarList + | &Instruction::ExecuteDeleteFromAttributedVarList + | &Instruction::ExecuteDeleteAllAttributesFromVar + | &Instruction::ExecuteUnattributedVar + | &Instruction::ExecuteGetDBRefs + | &Instruction::ExecuteKeySortWithConstantVarOrdering + | &Instruction::ExecuteInferenceLimitExceeded + | &Instruction::ExecuteFetchGlobalVar + | &Instruction::ExecuteFirstStream + | &Instruction::ExecuteFlushOutput + | &Instruction::ExecuteGetByte + | &Instruction::ExecuteGetChar + | &Instruction::ExecuteGetNChars + | &Instruction::ExecuteGetCode + | &Instruction::ExecuteGetSingleChar + | &Instruction::ExecuteTruncateIfNoLiftedHeapGrowthDiff + | &Instruction::ExecuteTruncateIfNoLiftedHeapGrowth + | &Instruction::ExecuteGetAttributedVariableList + | &Instruction::ExecuteGetAttrVarQueueDelimiter + | &Instruction::ExecuteGetAttrVarQueueBeyond + | &Instruction::ExecuteGetBValue + | &Instruction::ExecuteGetContinuationChunk + | &Instruction::ExecuteGetNextOpDBRef + | &Instruction::ExecuteLookupDBRef + | &Instruction::ExecuteIsPartialString + | &Instruction::ExecuteHalt + | &Instruction::ExecuteGetLiftedHeapFromOffset + | &Instruction::ExecuteGetLiftedHeapFromOffsetDiff + | &Instruction::ExecuteGetSCCCleaner + | &Instruction::ExecuteHeadIsDynamic + | &Instruction::ExecuteInstallSCCCleaner + | &Instruction::ExecuteInstallInferenceCounter + | &Instruction::ExecuteInferenceCount + | &Instruction::ExecuteLiftedHeapLength + | &Instruction::ExecuteLoadLibraryAsStream + | &Instruction::ExecuteModuleExists + | &Instruction::ExecuteNextEP + | &Instruction::ExecuteNoSuchPredicate + | &Instruction::ExecuteNumberToChars + | &Instruction::ExecuteNumberToCodes + | &Instruction::ExecuteOpDeclaration + | &Instruction::ExecuteOpen + | &Instruction::ExecuteSetStreamOptions + | &Instruction::ExecuteNextStream + | &Instruction::ExecutePartialStringTail + | &Instruction::ExecutePeekByte + | &Instruction::ExecutePeekChar + | &Instruction::ExecutePeekCode + | &Instruction::ExecutePointsToContinuationResetMarker + | &Instruction::ExecutePutByte + | &Instruction::ExecutePutChar + | &Instruction::ExecutePutChars + | &Instruction::ExecutePutCode + | &Instruction::ExecuteReadQueryTerm + | &Instruction::ExecuteReadTerm + | &Instruction::ExecuteRedoAttrVarBinding + | &Instruction::ExecuteRemoveCallPolicyCheck + | &Instruction::ExecuteRemoveInferenceCounter + | &Instruction::ExecuteResetContinuationMarker + | &Instruction::ExecuteRestoreCutPolicy + | &Instruction::ExecuteSetCutPoint(_) + | &Instruction::ExecuteSetInput + | &Instruction::ExecuteSetOutput + | &Instruction::ExecuteStoreBacktrackableGlobalVar + | &Instruction::ExecuteStoreGlobalVar + | &Instruction::ExecuteStreamProperty + | &Instruction::ExecuteSetStreamPosition + | &Instruction::ExecuteInferenceLevel + | &Instruction::ExecuteCleanUpBlock + | &Instruction::ExecuteFail + | &Instruction::ExecuteGetBall + | &Instruction::ExecuteGetCurrentBlock + | &Instruction::ExecuteGetCurrentSCCBlock + | &Instruction::ExecuteGetCutPoint + | &Instruction::ExecuteGetDoubleQuotes + | &Instruction::ExecuteGetUnknown + | &Instruction::ExecuteInstallNewBlock + | &Instruction::ExecuteRandomInteger + | &Instruction::ExecuteMaybe + | &Instruction::ExecuteCpuNow + | &Instruction::ExecuteDeterministicLengthRundown + | &Instruction::ExecuteHttpOpen + | &Instruction::ExecuteHttpListen + | &Instruction::ExecuteHttpAccept + | &Instruction::ExecuteHttpAnswer + | &Instruction::ExecuteLoadForeignLib + | &Instruction::ExecuteForeignCall + | &Instruction::ExecuteDefineForeignStruct + | &Instruction::ExecuteFfiAllocate + | &Instruction::ExecuteFfiReadPtr + | &Instruction::ExecuteFfiDeallocate + | &Instruction::ExecuteJsEval + | &Instruction::ExecutePredicateDefined + | &Instruction::ExecuteStripModule + | &Instruction::ExecuteCurrentTime + | &Instruction::ExecuteQuotedToken + | &Instruction::ExecuteReadFromChars + | &Instruction::ExecuteReadTermFromChars + | &Instruction::ExecuteResetBlock + | &Instruction::ExecuteResetSCCBlock + | &Instruction::ExecuteReturnFromVerifyAttr + | &Instruction::ExecuteSetBall + | &Instruction::ExecutePushBallStack + | &Instruction::ExecutePopBallStack + | &Instruction::ExecutePopFromBallStack + | &Instruction::ExecuteSetCutPointByDefault(_) + | &Instruction::ExecuteSetDoubleQuotes + | &Instruction::ExecuteSetUnknown + | &Instruction::ExecuteSetSeed + | &Instruction::ExecuteSkipMaxList + | &Instruction::ExecuteSleep + | &Instruction::ExecuteSocketClientOpen + | &Instruction::ExecuteSocketServerOpen + | &Instruction::ExecuteSocketServerAccept + | &Instruction::ExecuteSocketServerClose + | &Instruction::ExecuteTLSAcceptClient + | &Instruction::ExecuteTLSClientConnect + | &Instruction::ExecuteSucceed + | &Instruction::ExecuteTermAttributedVariables + | &Instruction::ExecuteTermVariables + | &Instruction::ExecuteTermVariablesUnderMaxDepth + | &Instruction::ExecuteTruncateLiftedHeapTo + | &Instruction::ExecuteUnifyWithOccursCheck + | &Instruction::ExecuteUnwindEnvironments + | &Instruction::ExecuteUnwindStack + | &Instruction::ExecuteWAMInstructions + | &Instruction::ExecuteInlinedInstructions + | &Instruction::ExecuteWriteTerm + | &Instruction::ExecuteWriteTermToChars + | &Instruction::ExecuteScryerPrologVersion + | &Instruction::ExecuteCryptoRandomByte + | &Instruction::ExecuteCryptoDataHash + | &Instruction::ExecuteCryptoHMAC + | &Instruction::ExecuteCryptoDataHKDF + | &Instruction::ExecuteCryptoPasswordHash + | &Instruction::ExecuteCryptoCurveScalarMult + | &Instruction::ExecuteCurve25519ScalarMult + | &Instruction::ExecuteFirstNonOctet + | &Instruction::ExecuteLoadHTML + | &Instruction::ExecuteLoadXML + | &Instruction::ExecuteGetEnv + | &Instruction::ExecuteSetEnv + | &Instruction::ExecuteUnsetEnv + | &Instruction::ExecuteShell + | &Instruction::ExecuteProcessCreate + | &Instruction::ExecuteProcessId + | &Instruction::ExecuteProcessWait + | &Instruction::ExecuteProcessKill + | &Instruction::ExecuteProcessRelease + | &Instruction::ExecutePid + | &Instruction::ExecuteCharsBase64 + | &Instruction::ExecuteDevourWhitespace + | &Instruction::ExecuteIsSTOEnabled + | &Instruction::ExecuteSetSTOAsUnify + | &Instruction::ExecuteSetNSTOAsUnify + | &Instruction::ExecuteSetSTOWithErrorAsUnify + | &Instruction::ExecuteHomeDirectory + | &Instruction::ExecuteDebugHook + | &Instruction::ExecuteAddDiscontiguousPredicate + | &Instruction::ExecuteAddDynamicPredicate + | &Instruction::ExecuteAddMultifilePredicate + | &Instruction::ExecuteAddGoalExpansionClause + | &Instruction::ExecuteAddTermExpansionClause + | &Instruction::ExecuteAddInSituFilenameModule + | &Instruction::ExecuteClauseToEvacuable + | &Instruction::ExecuteScopedClauseToEvacuable + | &Instruction::ExecuteConcludeLoad + | &Instruction::ExecuteDeclareModule + | &Instruction::ExecuteLoadCompiledLibrary + | &Instruction::ExecuteLoadContextSource + | &Instruction::ExecuteLoadContextFile + | &Instruction::ExecuteLoadContextDirectory + | &Instruction::ExecuteLoadContextModule + | &Instruction::ExecuteLoadContextStream + | &Instruction::ExecutePopLoadContext + | &Instruction::ExecutePopLoadStatePayload + | &Instruction::ExecutePushLoadContext + | &Instruction::ExecutePushLoadStatePayload + | &Instruction::ExecuteUseModule + | &Instruction::ExecuteBuiltInProperty + | &Instruction::ExecuteMetaPredicateProperty + | &Instruction::ExecuteMultifileProperty + | &Instruction::ExecuteDiscontiguousProperty + | &Instruction::ExecuteDynamicProperty + | &Instruction::ExecuteAbolishClause + | &Instruction::ExecuteAsserta + | &Instruction::ExecuteAssertz + | &Instruction::ExecuteRetract + | &Instruction::ExecuteIsConsistentWithTermQueue + | &Instruction::ExecuteFlushTermQueue + | &Instruction::ExecuteRemoveModuleExports + | &Instruction::ExecuteAddNonCountedBacktracking + | &Instruction::ExecutePopCount + | &Instruction::ExecuteArgv + | &Instruction::ExecuteEd25519SignRaw + | &Instruction::ExecuteEd25519VerifyRaw + | &Instruction::ExecuteEd25519SeedToPublicKey => { let (name, arity) = self.to_name_and_arity(); functor!(atom!("execute"), [atom_as_cell(name), fixnum(arity)]) } // #[cfg(feature = "crypto-full")] - &Instruction::ExecuteCryptoDataEncrypt | - &Instruction::ExecuteCryptoDataDecrypt => { + &Instruction::ExecuteCryptoDataEncrypt | &Instruction::ExecuteCryptoDataDecrypt => { let (name, arity) = self.to_name_and_arity(); functor!(atom!("execute"), [atom_as_cell(name), fixnum(arity)]) } // - &Instruction::ExecuteBeta | - &Instruction::ExecuteBetaI | - &Instruction::ExecuteInvBetaI | - &Instruction::ExecuteGamma | - &Instruction::ExecuteGammP | - &Instruction::ExecuteGammQ | - &Instruction::ExecuteInvGammP | - &Instruction::ExecuteLnGamma | - &Instruction::ExecuteErf | - &Instruction::ExecuteErfc | - &Instruction::ExecuteInvErf | - &Instruction::ExecuteInvErfc => { + &Instruction::ExecuteBeta + | &Instruction::ExecuteBetaI + | &Instruction::ExecuteInvBetaI + | &Instruction::ExecuteGamma + | &Instruction::ExecuteGammP + | &Instruction::ExecuteGammQ + | &Instruction::ExecuteInvGammP + | &Instruction::ExecuteLnGamma + | &Instruction::ExecuteErf + | &Instruction::ExecuteErfc + | &Instruction::ExecuteInvErf + | &Instruction::ExecuteInvErfc => { let (name, arity) = self.to_name_and_arity(); functor!(atom!("execute"), [atom_as_cell(name), fixnum(arity)]) } @@ -1249,9 +1219,10 @@ impl Instruction { let lvl_stub = lvl.into_functor(); let rt_stub = reg_type_into_functor(r); - functor!(atom!("get_constant"), [functor(lvl_stub), - cell(lit), - functor(rt_stub)]) + functor!( + atom!("get_constant"), + [functor(lvl_stub), cell(lit), functor(rt_stub)] + ) } &Instruction::GetList(lvl, r) => { let lvl_stub = lvl.into_functor(); @@ -1263,23 +1234,28 @@ impl Instruction { let lvl_stub = lvl.into_functor(); let rt_stub = reg_type_into_functor(r); - functor!(atom!("get_partial_string"), [functor(lvl_stub), - string((s.to_string())), - functor(rt_stub)]) + functor!( + atom!("get_partial_string"), + [functor(lvl_stub), string((s.to_string())), functor(rt_stub)] + ) } &Instruction::GetStructure(lvl, name, arity, r) => { let lvl_stub = lvl.into_functor(); let rt_stub = reg_type_into_functor(r); - functor!(atom!("get_structure"), [functor(lvl_stub), - atom_as_cell(name), - fixnum(arity), - functor(rt_stub)]) + functor!( + atom!("get_structure"), + [ + functor(lvl_stub), + atom_as_cell(name), + fixnum(arity), + functor(rt_stub) + ] + ) } &Instruction::GetValue(r, arg) => { let rt_stub = reg_type_into_functor(r); - functor!(atom!("get_value"), [functor(rt_stub), - fixnum(arg)]) + functor!(atom!("get_value"), [functor(rt_stub), fixnum(arg)]) } &Instruction::GetVariable(r, arg) => { let rt_stub = reg_type_into_functor(r); @@ -1310,7 +1286,10 @@ impl Instruction { let lvl_stub = lvl.into_functor(); let rt_stub = reg_type_into_functor(r); - functor!(atom!("put_constant"), [functor(rt_stub), cell(c), functor(lvl_stub)]) + functor!( + atom!("put_constant"), + [functor(rt_stub), cell(c), functor(lvl_stub)] + ) } &Instruction::PutList(lvl, r) => { let lvl_stub = lvl.into_functor(); @@ -1322,28 +1301,28 @@ impl Instruction { let lvl_stub = lvl.into_functor(); let rt_stub = reg_type_into_functor(r); - functor!(atom!("put_partial_string"), [functor(lvl_stub), - string((s.to_string())), - functor(rt_stub)]) + functor!( + atom!("put_partial_string"), + [functor(lvl_stub), string((s.to_string())), functor(rt_stub)] + ) } &Instruction::PutStructure(name, arity, r) => { let rt_stub = reg_type_into_functor(r); - functor!(atom!("put_structure"), [atom_as_cell(name), - fixnum(arity), - functor(rt_stub)]) + functor!( + atom!("put_structure"), + [atom_as_cell(name), fixnum(arity), functor(rt_stub)] + ) } &Instruction::PutValue(r, arg) => { let rt_stub = reg_type_into_functor(r); - functor!(atom!("put_value"), [functor(rt_stub), - fixnum(arg)]) + functor!(atom!("put_value"), [functor(rt_stub), fixnum(arg)]) } &Instruction::PutVariable(r, arg) => { let rt_stub = reg_type_into_functor(r); - functor!(atom!("put_variable"), [functor(rt_stub), - fixnum(arg)]) + functor!(atom!("put_variable"), [functor(rt_stub), fixnum(arg)]) } &Instruction::SetConstant(c) => { functor!(atom!("set_constant"), [cell(c)]) @@ -1371,20 +1350,21 @@ impl Instruction { #[allow(dead_code)] pub fn is_query_instr(&self) -> bool { - matches!(self, - &Instruction::GetVariable(..) | - &Instruction::PutConstant(..) | - &Instruction::PutList(..) | - &Instruction::PutPartialString(..) | - &Instruction::PutStructure(..) | - &Instruction::PutUnsafeValue(..) | - &Instruction::PutValue(..) | - &Instruction::PutVariable(..) | - &Instruction::SetConstant(..) | - &Instruction::SetLocalValue(..) | - &Instruction::SetVariable(..) | - &Instruction::SetValue(..) | - &Instruction::SetVoid(..) + matches!( + self, + &Instruction::GetVariable(..) + | &Instruction::PutConstant(..) + | &Instruction::PutList(..) + | &Instruction::PutPartialString(..) + | &Instruction::PutStructure(..) + | &Instruction::PutUnsafeValue(..) + | &Instruction::PutValue(..) + | &Instruction::PutVariable(..) + | &Instruction::SetConstant(..) + | &Instruction::SetLocalValue(..) + | &Instruction::SetVariable(..) + | &Instruction::SetValue(..) + | &Instruction::SetVoid(..) ) } } @@ -1392,15 +1372,15 @@ impl Instruction { impl CompareNumber { pub fn set_terms(&mut self, l_at_1: ArithmeticTerm, l_at_2: ArithmeticTerm) { match self { - CompareNumber::NumberGreaterThan(ref mut at_1, ref mut at_2) | - CompareNumber::NumberLessThan(ref mut at_1, ref mut at_2) | - CompareNumber::NumberGreaterThanOrEqual(ref mut at_1, ref mut at_2) | - CompareNumber::NumberLessThanOrEqual(ref mut at_1, ref mut at_2) | - CompareNumber::NumberNotEqual(ref mut at_1, ref mut at_2) | - CompareNumber::NumberEqual(ref mut at_1, ref mut at_2) => { + CompareNumber::NumberGreaterThan(ref mut at_1, ref mut at_2) + | CompareNumber::NumberLessThan(ref mut at_1, ref mut at_2) + | CompareNumber::NumberGreaterThanOrEqual(ref mut at_1, ref mut at_2) + | CompareNumber::NumberLessThanOrEqual(ref mut at_1, ref mut at_2) + | CompareNumber::NumberNotEqual(ref mut at_1, ref mut at_2) + | CompareNumber::NumberEqual(ref mut at_1, ref mut at_2) => { *at_1 = l_at_1; *at_2 = l_at_2; } } } -} \ No newline at end of file +} diff --git a/tests/scryer/src_tests.rs b/tests/scryer/src_tests.rs index 03049462..ae560f1c 100644 --- a/tests/scryer/src_tests.rs +++ b/tests/scryer/src_tests.rs @@ -57,7 +57,6 @@ fn rules() { #[test] #[cfg_attr(miri, ignore = "it takes too long to run")] fn setup_call_cleanup_load() { - load_module_test( "src/tests/setup_call_cleanup.pl", // spellchecker:ignore-next-line