current_predicate

This commit is contained in:
Vítor Santos Costa 2016-01-08 03:18:36 +00:00
parent bdb2f0562a
commit 1a23e47316
5 changed files with 37 additions and 59 deletions

View File

@ -2908,36 +2908,8 @@ static Int p_clean_up_dead_clauses(USES_REGS1) {
void Yap_HidePred(PredEntry *pe) {
Prop p0 = AbsPredProp(pe);
if (pe->ArityOfPE == 0) {
Atom a = (Atom)pe->FunctorOfPred;
p0 = RepAtom(a)->PropsOfAE;
if (p0 == AbsPredProp(pe)) {
RepAtom(a)->PropsOfAE = pe->NextOfPE;
} else {
while (p0->NextOfPE != AbsPredProp(pe))
p0 = p0->NextOfPE;
if (p0 == NIL)
return;
p0->NextOfPE = pe->NextOfPE;
}
} else {
Functor funt = pe->FunctorOfPred;
p0 = funt->PropsOfFE;
if (p0 == AbsPredProp(pe)) {
funt->PropsOfFE = pe->NextOfPE;
} else {
while (p0->NextOfPE != AbsPredProp(pe))
p0 = p0->NextOfPE;
if (p0 == NIL)
return;
p0->NextOfPE = pe->NextOfPE;
}
}
pe->NextOfPE = HIDDEN_PREDICATES;
HIDDEN_PREDICATES = AbsPredProp(pe);
pe->PredFlags |= HiddenPredFlag;
pe->PredFlags |= (HiddenPredFlag | NoSpyPredFlag | NoTracePredFlag);
}
static Int /* $system_predicate(P) */
@ -3022,7 +2994,7 @@ restart_system_pred:
return false;
if (EndOfPAEntr(pe))
return false;
pe->PredFlags |= (HiddenPredFlag / NoSpyPredFlag | NoTracePredFlag);
pe->PredFlags |= (HiddenPredFlag | NoSpyPredFlag | NoTracePredFlag);
return true;
}

View File

@ -1876,6 +1876,7 @@ static LogUpdClause *new_lu_db_entry(Term t, PredEntry *pe) {
cl->ClTimeStart = 0L;
}
cl->ClTimeEnd = TIMESTAMP_EOT;
#if MULTIPLE_STACKS
// INIT_LOCK(cl->ClLock);
INIT_CLREF_COUNT(cl);
@ -2709,6 +2710,8 @@ static PredEntry *new_lu_entry(Term t) {
}
pe->ArityOfPE = 3;
pe->OpcodeOfPred = Yap_opcode(_op_fail);
if (CurrentModule == PROLOG_MODULE)
pe->PredFlags |= StandardPredFlag;
pe->cs.p_code.TrueCodeOfPred = pe->CodeOfPred = FAILCODE;
return pe;
}
@ -5107,7 +5110,7 @@ static Int p_dequeue(USES_REGS1) {
QueueEntry *cur_instance;
Term Father = Deref(ARG1);
Int rc;
if (IsVarTerm(Father)) {
Yap_Error(INSTANTIATION_ERROR, Father, "dequeue");
return FALSE;

View File

@ -878,13 +878,20 @@ static Int
}
static bool valid_prop(Prop p, Term task) {
if (RepPredProp(p)->OpcodeOfPred == UNDEF_OPCODE)
if ((RepPredProp(p)->PredFlags & HiddenPredFlag) ||
(RepPredProp(p)->OpcodeOfPred == UNDEF_OPCODE) ){
return false;
if ((RepPredProp(p)->PredFlags & (HiddenPredFlag | StandardPredFlag))) {
return (task == SYSTEM_MODULE || task == TermTrue || IsVarTerm(task));
} else {
return (task == USER_MODULE || task == TermTrue || IsVarTerm(task));
}
if(task == TermSystem || task == TermProlog) {
return RepPredProp(p)->PredFlags & StandardPredFlag;
}
if(task == TermUser) {
return !(RepPredProp(p)->PredFlags & StandardPredFlag);
}
if (IsVarTerm(task)) {
return true;
}
return false;
}
static PropEntry *followLinkedListOfProps(PropEntry *p, Term task) {

View File

@ -13,7 +13,15 @@
%% @{
/** @defgroup absolute_file_name File Name Resolution
:- system_module( absf, [absolute_file_name/2,
absolute_file_name/3,
add_to_path/1,
add_to_path/2,
path/1,
remove_from_path/1], ['$full_filename'/3,
'$system_library_directories'/2]).
/** @defgroup absf File Name Resolution
@ingroup builtins
@ -24,14 +32,6 @@
variables and registry information to search for files.
**/
:- system_module( absolute_file_name, [absolute_file_name/2,
absolute_file_name/3,
add_to_path/1,
add_to_path/2,
path/1,
remove_from_path/1], ['$full_filename'/3,
'$system_library_directories'/2]).
:- use_system_module( '$_boot', ['$system_catch'/4]).
:- use_system_module( '$_errors', ['$do_error'/2]).

View File

@ -20,14 +20,11 @@ xc/*************************************************************************
% This protects all code from further changes
% and also makes it impossible from some predicates to be seen
'$protect' :-
current_atom(Name),
'$current_predicate'(Name,M,P,_),
'$current_predicate'(Name,M,P,_),riteln(P),
M \= user,
functor(P,Name,Arity),
'$new_system_predicate'(Name,Arity,M),
sub_atom(Name,0,1,_, '$'),
\+ '$visible'(Name),
hide_predicate(M:P),
fail.
'$protect' :-
current_atom(Name),
@ -44,15 +41,15 @@ xc/*************************************************************************
'$visible'('$dbref'). /* not stream position */
'$visible'('$stream'). /* not $STREAM */
'$visible'('$stream_position'). /* not stream position */
'$visible'('$hacks').
'$visible'('$source_location').
'$visible'('$messages').
'$visible'('$push_input_context').
'$visible'('$pop_input_context').
'$visible'('$set_source_module').
'$visible'('$declare_module').
'$visible'('$store_clause').
'$visible'('$skip_list').
'$visible'('$hacks').
'$visible'('$source_location').
'$visible'('$messages').
'$visible'('$push_input_context').
'$visible'('$pop_input_context').
'$visible'('$set_source_module').
'$visible'('$declare_module').
'$visible'('$store_clause').
'$visible'('$skip_list').
'$visible'('$win_insert_menu_item').
'$visible'('$set_predicate_attribute').
'$visible'('$parse_quasi_quotations').
@ -60,4 +57,3 @@ xc/*************************************************************************
'$visible'('$qq_open').
'$visible'('$live').
'$visible'('$init_prolog').