correct and generalize current_predicate/1

This commit is contained in:
Mark
2023-06-28 17:31:43 -06:00
parent c4b13a2176
commit 58af615dd4
4 changed files with 9 additions and 10 deletions

View File

@@ -1252,14 +1252,13 @@ abolish(Pred) :-
% It can be used to check for existence of a predicate or to enumerate all loaded predicates % It can be used to check for existence of a predicate or to enumerate all loaded predicates
current_predicate(Pred) :- current_predicate(Pred) :-
( var(Pred) -> ( var(Pred) ->
'$get_db_refs'(_, _, PIs), '$get_db_refs'(_, _, _, PIs),
lists:member(Pred, PIs) lists:member(Pred, PIs)
; '$strip_module'(Pred, Module, UnqualifiedPred), ; '$strip_module'(Pred, Module, UnqualifiedPred),
( var(Module), ( var(Module),
\+ functor(Pred, (:), 2) \+ functor(Pred, (:), 2)
; atom(Module) ; atom(Module)
), ),
nonvar(UnqualifiedPred),
UnqualifiedPred = Name/Arity -> UnqualifiedPred = Name/Arity ->
( ( nonvar(Name), \+ atom(Name) ( ( nonvar(Name), \+ atom(Name)
; nonvar(Arity), \+ integer(Arity) ; nonvar(Arity), \+ integer(Arity)

View File

@@ -3774,7 +3774,7 @@ impl Machine {
(HeapCellValueTag::Atom, (module_name, _arity)) => { (HeapCellValueTag::Atom, (module_name, _arity)) => {
module_name module_name
} }
(HeapCellValueTag::AttrVar | HeapCellValueTag::Var) => { (HeapCellValueTag::AttrVar | HeapCellValueTag::Var | HeapCellValueTag::StackVar) => {
atom!("user") atom!("user")
} }
_ => { _ => {
@@ -3845,9 +3845,9 @@ impl Machine {
(0 .. num_functors).map(|i| str_loc_as_cell!(h + 3 * i)), (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 { } 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]);
} }
} }