From 58af615dd4d5223b1d47caa383b24dd79479a5d4 Mon Sep 17 00:00:00 2001 From: Mark Date: Wed, 28 Jun 2023 17:31:43 -0600 Subject: [PATCH] correct and generalize current_predicate/1 --- src/lib/builtins.pl | 3 +-- src/lib/files.pl | 6 +++--- src/lib/iso_ext.pl | 4 ++-- src/machine/system_calls.rs | 6 +++--- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/lib/builtins.pl b/src/lib/builtins.pl index ab821f4b..904d2f69 100644 --- a/src/lib/builtins.pl +++ b/src/lib/builtins.pl @@ -1252,14 +1252,13 @@ abolish(Pred) :- % It can be used to check for existence of a predicate or to enumerate all loaded predicates current_predicate(Pred) :- ( var(Pred) -> - '$get_db_refs'(_, _, PIs), + '$get_db_refs'(_, _, _, PIs), lists:member(Pred, PIs) ; '$strip_module'(Pred, Module, UnqualifiedPred), ( var(Module), \+ functor(Pred, (:), 2) ; atom(Module) ), - nonvar(UnqualifiedPred), UnqualifiedPred = Name/Arity -> ( ( nonvar(Name), \+ atom(Name) ; nonvar(Arity), \+ integer(Arity) diff --git a/src/lib/files.pl b/src/lib/files.pl index 90c1307d..6d89eaad 100644 --- a/src/lib/files.pl +++ b/src/lib/files.pl @@ -70,9 +70,9 @@ _lists of characters_. This is an ideal representation: file_exists/1, directory_exists/1, delete_file/1, - rename_file/2, - file_copy/2, - delete_directory/1, + rename_file/2, + file_copy/2, + delete_directory/1, make_directory/1, make_directory_path/1, working_directory/2, diff --git a/src/lib/iso_ext.pl b/src/lib/iso_ext.pl index d6f13df0..0af55c99 100644 --- a/src/lib/iso_ext.pl +++ b/src/lib/iso_ext.pl @@ -16,8 +16,8 @@ but they're not part of the ISO Prolog standard at the moment. setup_call_cleanup/3, call_nth/2, copy_term_nat/2, - asserta/2, - assertz/2]). + asserta/2, + assertz/2]). :- use_module(library(error), [can_be/2, domain_error/3, diff --git a/src/machine/system_calls.rs b/src/machine/system_calls.rs index 48741974..7dbaf43b 100644 --- a/src/machine/system_calls.rs +++ b/src/machine/system_calls.rs @@ -3774,7 +3774,7 @@ impl Machine { (HeapCellValueTag::Atom, (module_name, _arity)) => { module_name } - (HeapCellValueTag::AttrVar | HeapCellValueTag::Var) => { + (HeapCellValueTag::AttrVar | HeapCellValueTag::Var | HeapCellValueTag::StackVar) => { atom!("user") } _ => { @@ -3845,9 +3845,9 @@ impl Machine { (0 .. num_functors).map(|i| str_loc_as_cell!(h + 3 * i)), ); - unify!(self.machine_st, heap_loc_as_cell!(h), self.machine_st.registers[3]); + unify!(self.machine_st, heap_loc_as_cell!(h), self.machine_st.registers[4]); } else { - unify!(self.machine_st, empty_list_as_cell!(), self.machine_st.registers[3]); + unify!(self.machine_st, empty_list_as_cell!(), self.machine_st.registers[4]); } } -- 2.54.0