allow abolish of static procedures, even if they are being used.

git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@546 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
vsc 2002-06-18 05:22:35 +00:00
parent 1adc2585a7
commit fa33648499
6 changed files with 21 additions and 59 deletions

View File

@ -31,7 +31,7 @@ static char SccsId[] = "@(#)cdmgr.c 1.1 05/02/98";
#endif
STATIC_PROTO(void retract_all, (PredEntry *));
STATIC_PROTO(void retract_all, (PredEntry *, int));
STATIC_PROTO(void add_first_static, (PredEntry *, CODEADDR, int));
STATIC_PROTO(void add_first_dynamic, (PredEntry *, CODEADDR, int));
STATIC_PROTO(void asserta_stat_clause, (PredEntry *, CODEADDR, int));
@ -291,22 +291,9 @@ RemoveIndexation(PredEntry *ap)
else {
Clause *cl = ClauseCodeToClause(ap->TrueCodeOfPred);
if (static_in_use(ap, FALSE)) {
Int Arity = ap->ArityOfPE;
ErrorMessage = ErrorSay;
Error_Term = TermNil;
Error_TYPE = PERMISSION_ERROR_MODIFY_STATIC_PROCEDURE;
if (Arity == 0)
sprintf(ErrorMessage, "predicate %s is in use", RepAtom((Atom)(ap->FunctorOfPred))->StrOfAE);
else
sprintf(ErrorMessage,
#if SHORT_INTS
"predicate %s/%ld is in use",
#else
"predicate %s/%d is in use",
#endif
RepAtom(NameOfFunctor(ap->FunctorOfPred))->StrOfAE, Arity);
return(FALSE);
/* This should never happen */
cl->u.NextCl = DeadClauses;
DeadClauses = cl;
} else {
FreeCodeSpace((char *)cl);
}
@ -339,7 +326,7 @@ RemoveIndexation(PredEntry *ap)
/* p is already locked */
static void
retract_all(PredEntry *p)
retract_all(PredEntry *p, int in_use)
{
CODEADDR q, q1;
int multifile_pred = p->PredFlags & MultiFileFlag;
@ -757,29 +744,7 @@ not_was_reconsulted(PredEntry *p, Term t, int mode)
--ConsultSp;
ConsultSp->p = p0;
if (ConsultBase[1].mode) /* we are in reconsult mode */ {
if (static_in_use(p, TRUE)) {
Int Arity = p->ArityOfPE;
#ifdef DEBUG
if(0)
list_all_predicates_in_use();
#endif
ErrorMessage = ErrorSay;
Error_Term = t;
Error_TYPE = PERMISSION_ERROR_MODIFY_STATIC_PROCEDURE;
if (Arity == 0)
sprintf(ErrorMessage, "predicate %s is in use", RepAtom((Atom)(p->FunctorOfPred))->StrOfAE);
else
sprintf(ErrorMessage,
#if SHORT_INTS
"predicate %s/%ld is in use",
#else
"predicate %s/%d is in use",
#endif
RepAtom(NameOfFunctor(p->FunctorOfPred))->StrOfAE, Arity);
return(FALSE);
}
retract_all(p);
retract_all(p, static_in_use(p,TRUE));
}
if (!(p->PredFlags & MultiFileFlag)) {
p->OwnerFile = YapConsultingFile();
@ -1220,7 +1185,8 @@ p_purge_clauses(void)
Term t = Deref(ARG1);
Term t2 = Deref(ARG2);
CODEADDR q, q1;
int mod;
SMALLUNSGN mod;
int in_use;
PutValue(AtomAbol, MkAtomTerm(AtomNil));
if (IsVarTerm(t))
@ -1247,6 +1213,7 @@ p_purge_clauses(void)
RemoveIndexation(pred);
PutValue(AtomAbol, MkAtomTerm(AtomTrue));
q = pred->FirstClause;
in_use = static_in_use(pred,FALSE);
if (q != NIL)
do {
q1 = q;
@ -1255,7 +1222,7 @@ p_purge_clauses(void)
ErCl(ClauseCodeToClause(q1));
else {
Clause *cl = ClauseCodeToClause(q1);
if (cl->ClFlags & HasBlobsMask) {
if (cl->ClFlags & HasBlobsMask || in_use) {
cl->u.NextCl = DeadClauses;
DeadClauses = cl;
} else {

View File

@ -1129,6 +1129,7 @@ InitYaamRegs(void)
WokenGoals = NewTimedVar(TermNil);
MutableList = NewTimedVar(TermNil);
AttsMutableList = NewTimedVar(TermNil);
printf("TermNil is %lx and AttsMutableList is %x\n",TermNil, AttsMutableList);
#endif
}

View File

@ -327,14 +327,12 @@ restore_codes(void)
if (heap_regs->spy_code != NULL)
heap_regs->spy_code = (PredEntry *)PtoHeapCellAdjust((CELL *)(heap_regs->spy_code));
#ifdef COROUTINING
#ifdef MULTI_ASSIGNMENT_VARIABLES
if (heap_regs->wake_up_code != NULL)
heap_regs->wake_up_code = (PredEntry *)PtoHeapCellAdjust((CELL *)(heap_regs->wake_up_code));
heap_regs->mutable_list =
AbsAppl(PtoGloAdjust(RepAppl(heap_regs->mutable_list)));
heap_regs->atts_mutable_list =
AbsAppl(PtoGloAdjust(RepAppl(heap_regs->atts_mutable_list)));
#endif
#endif
if (heap_regs->last_wtime != NULL)
heap_regs->last_wtime = (void *)PtoHeapCellAdjust((CELL *)(heap_regs->last_wtime));

View File

@ -17,9 +17,10 @@
<h2>Yap-4.3.23:</h2>
<ul>
<li>FIXED: always allow abolish on static predicates.</li>
<li>UPDATE: include new apply_macros code from Erick Alphonse,
and acknowledge J. Schimpf</li>
<li>FIXED: YapRunGoal (Roberto Bagnara)</li>
and acknowledge J. Schimpf.</li>
<li>FIXED: YapRunGoal (Roberto Bagnara).</li>
<li>NEW: term_position option for read_term (Nicos)</li>
<li>UPDATE: fixed shell/1 and shell/2 in library(system). (Nicos)</li>
<li>UPDATE: new Logtalk version (2.13.0).</li>

View File

@ -4660,11 +4660,10 @@ undefined, declare it as dynamic.
undefined, declare it as dynamic.
Most Prolog systems only allow asserting clauses for dynamic
predicates. This is also as specified in the ISO
standard. YAP allows asserting clauses for static predicates,
as long as the predicate is not in use. The current version of
YAP supports this feature, but this feature is deprecated and
support may go away in future versions.
predicates. This is also as specified in the ISO standard. YAP allows
asserting clauses for static predicates. The current version of YAP
supports this feature, but this feature is deprecated and support may go
away in future versions.
@item abolish(+@var{PredSpec}) [ISO]
@findex abolish/1
@ -4675,8 +4674,7 @@ support may go away in future versions.
current module. The
specification must include the name and arity, and it may include module
information. Under @t{iso} language mode this builtin will only abolish
dynamic procedures. Under other modes it will abolish any procedures, as
long as they are not currently in use.
dynamic procedures. Under other modes it will abolish any procedures.
@item abolish(+@var{P},+@var{N})
@findex abolish/2
@ -4689,8 +4687,8 @@ both static and dynamic predicates.
@findex assert_static/1
@snindex assert_static/1
@cnindex assert_static/1
Adds clause @var{C} to a static procedure. Asserting a static clause
for a predicate while choice-points for the predicate are availabe has
Adds clause @var{C} to a static procedure. Asserting a static clause
for a predicate while choice-points for the predicate are available has
undefined results.
@item asserta_static(:@var{C})

View File

@ -485,9 +485,6 @@ abolish(X) :-
'$abolishd'(T, M) :- '$kill_dynamic'(T,M), fail.
'$abolishd'(_, _).
'$abolishs'(G, M) :- '$in_use'(G, M), !,
functor(G,Name,Arity),
throw(error(permission_error(modify,static_procedure_in_use,Name/Arity),abolish(M:G))).
'$abolishs'(G, M) :- '$system_predicate'(G,M), !,
functor(G,Name,Arity),
throw(error(permission_error(modify,static_procedure,Name/Arity),abolish(M:G))).