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:
parent
1adc2585a7
commit
fa33648499
53
C/cdmgr.c
53
C/cdmgr.c
@ -31,7 +31,7 @@ static char SccsId[] = "@(#)cdmgr.c 1.1 05/02/98";
|
|||||||
#endif
|
#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_static, (PredEntry *, CODEADDR, int));
|
||||||
STATIC_PROTO(void add_first_dynamic, (PredEntry *, CODEADDR, int));
|
STATIC_PROTO(void add_first_dynamic, (PredEntry *, CODEADDR, int));
|
||||||
STATIC_PROTO(void asserta_stat_clause, (PredEntry *, CODEADDR, int));
|
STATIC_PROTO(void asserta_stat_clause, (PredEntry *, CODEADDR, int));
|
||||||
@ -291,22 +291,9 @@ RemoveIndexation(PredEntry *ap)
|
|||||||
else {
|
else {
|
||||||
Clause *cl = ClauseCodeToClause(ap->TrueCodeOfPred);
|
Clause *cl = ClauseCodeToClause(ap->TrueCodeOfPred);
|
||||||
if (static_in_use(ap, FALSE)) {
|
if (static_in_use(ap, FALSE)) {
|
||||||
Int Arity = ap->ArityOfPE;
|
/* This should never happen */
|
||||||
|
cl->u.NextCl = DeadClauses;
|
||||||
ErrorMessage = ErrorSay;
|
DeadClauses = cl;
|
||||||
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);
|
|
||||||
} else {
|
} else {
|
||||||
FreeCodeSpace((char *)cl);
|
FreeCodeSpace((char *)cl);
|
||||||
}
|
}
|
||||||
@ -339,7 +326,7 @@ RemoveIndexation(PredEntry *ap)
|
|||||||
|
|
||||||
/* p is already locked */
|
/* p is already locked */
|
||||||
static void
|
static void
|
||||||
retract_all(PredEntry *p)
|
retract_all(PredEntry *p, int in_use)
|
||||||
{
|
{
|
||||||
CODEADDR q, q1;
|
CODEADDR q, q1;
|
||||||
int multifile_pred = p->PredFlags & MultiFileFlag;
|
int multifile_pred = p->PredFlags & MultiFileFlag;
|
||||||
@ -757,29 +744,7 @@ not_was_reconsulted(PredEntry *p, Term t, int mode)
|
|||||||
--ConsultSp;
|
--ConsultSp;
|
||||||
ConsultSp->p = p0;
|
ConsultSp->p = p0;
|
||||||
if (ConsultBase[1].mode) /* we are in reconsult mode */ {
|
if (ConsultBase[1].mode) /* we are in reconsult mode */ {
|
||||||
if (static_in_use(p, TRUE)) {
|
retract_all(p, 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);
|
|
||||||
}
|
}
|
||||||
if (!(p->PredFlags & MultiFileFlag)) {
|
if (!(p->PredFlags & MultiFileFlag)) {
|
||||||
p->OwnerFile = YapConsultingFile();
|
p->OwnerFile = YapConsultingFile();
|
||||||
@ -1220,7 +1185,8 @@ p_purge_clauses(void)
|
|||||||
Term t = Deref(ARG1);
|
Term t = Deref(ARG1);
|
||||||
Term t2 = Deref(ARG2);
|
Term t2 = Deref(ARG2);
|
||||||
CODEADDR q, q1;
|
CODEADDR q, q1;
|
||||||
int mod;
|
SMALLUNSGN mod;
|
||||||
|
int in_use;
|
||||||
|
|
||||||
PutValue(AtomAbol, MkAtomTerm(AtomNil));
|
PutValue(AtomAbol, MkAtomTerm(AtomNil));
|
||||||
if (IsVarTerm(t))
|
if (IsVarTerm(t))
|
||||||
@ -1247,6 +1213,7 @@ p_purge_clauses(void)
|
|||||||
RemoveIndexation(pred);
|
RemoveIndexation(pred);
|
||||||
PutValue(AtomAbol, MkAtomTerm(AtomTrue));
|
PutValue(AtomAbol, MkAtomTerm(AtomTrue));
|
||||||
q = pred->FirstClause;
|
q = pred->FirstClause;
|
||||||
|
in_use = static_in_use(pred,FALSE);
|
||||||
if (q != NIL)
|
if (q != NIL)
|
||||||
do {
|
do {
|
||||||
q1 = q;
|
q1 = q;
|
||||||
@ -1255,7 +1222,7 @@ p_purge_clauses(void)
|
|||||||
ErCl(ClauseCodeToClause(q1));
|
ErCl(ClauseCodeToClause(q1));
|
||||||
else {
|
else {
|
||||||
Clause *cl = ClauseCodeToClause(q1);
|
Clause *cl = ClauseCodeToClause(q1);
|
||||||
if (cl->ClFlags & HasBlobsMask) {
|
if (cl->ClFlags & HasBlobsMask || in_use) {
|
||||||
cl->u.NextCl = DeadClauses;
|
cl->u.NextCl = DeadClauses;
|
||||||
DeadClauses = cl;
|
DeadClauses = cl;
|
||||||
} else {
|
} else {
|
||||||
|
1
C/init.c
1
C/init.c
@ -1129,6 +1129,7 @@ InitYaamRegs(void)
|
|||||||
WokenGoals = NewTimedVar(TermNil);
|
WokenGoals = NewTimedVar(TermNil);
|
||||||
MutableList = NewTimedVar(TermNil);
|
MutableList = NewTimedVar(TermNil);
|
||||||
AttsMutableList = NewTimedVar(TermNil);
|
AttsMutableList = NewTimedVar(TermNil);
|
||||||
|
printf("TermNil is %lx and AttsMutableList is %x\n",TermNil, AttsMutableList);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -327,14 +327,12 @@ restore_codes(void)
|
|||||||
if (heap_regs->spy_code != NULL)
|
if (heap_regs->spy_code != NULL)
|
||||||
heap_regs->spy_code = (PredEntry *)PtoHeapCellAdjust((CELL *)(heap_regs->spy_code));
|
heap_regs->spy_code = (PredEntry *)PtoHeapCellAdjust((CELL *)(heap_regs->spy_code));
|
||||||
#ifdef COROUTINING
|
#ifdef COROUTINING
|
||||||
#ifdef MULTI_ASSIGNMENT_VARIABLES
|
|
||||||
if (heap_regs->wake_up_code != NULL)
|
if (heap_regs->wake_up_code != NULL)
|
||||||
heap_regs->wake_up_code = (PredEntry *)PtoHeapCellAdjust((CELL *)(heap_regs->wake_up_code));
|
heap_regs->wake_up_code = (PredEntry *)PtoHeapCellAdjust((CELL *)(heap_regs->wake_up_code));
|
||||||
heap_regs->mutable_list =
|
heap_regs->mutable_list =
|
||||||
AbsAppl(PtoGloAdjust(RepAppl(heap_regs->mutable_list)));
|
AbsAppl(PtoGloAdjust(RepAppl(heap_regs->mutable_list)));
|
||||||
heap_regs->atts_mutable_list =
|
heap_regs->atts_mutable_list =
|
||||||
AbsAppl(PtoGloAdjust(RepAppl(heap_regs->atts_mutable_list)));
|
AbsAppl(PtoGloAdjust(RepAppl(heap_regs->atts_mutable_list)));
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
if (heap_regs->last_wtime != NULL)
|
if (heap_regs->last_wtime != NULL)
|
||||||
heap_regs->last_wtime = (void *)PtoHeapCellAdjust((CELL *)(heap_regs->last_wtime));
|
heap_regs->last_wtime = (void *)PtoHeapCellAdjust((CELL *)(heap_regs->last_wtime));
|
||||||
|
@ -17,9 +17,10 @@
|
|||||||
<h2>Yap-4.3.23:</h2>
|
<h2>Yap-4.3.23:</h2>
|
||||||
<ul>
|
<ul>
|
||||||
|
|
||||||
|
<li>FIXED: always allow abolish on static predicates.</li>
|
||||||
<li>UPDATE: include new apply_macros code from Erick Alphonse,
|
<li>UPDATE: include new apply_macros code from Erick Alphonse,
|
||||||
and acknowledge J. Schimpf</li>
|
and acknowledge J. Schimpf.</li>
|
||||||
<li>FIXED: YapRunGoal (Roberto Bagnara)</li>
|
<li>FIXED: YapRunGoal (Roberto Bagnara).</li>
|
||||||
<li>NEW: term_position option for read_term (Nicos)</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: fixed shell/1 and shell/2 in library(system). (Nicos)</li>
|
||||||
<li>UPDATE: new Logtalk version (2.13.0).</li>
|
<li>UPDATE: new Logtalk version (2.13.0).</li>
|
||||||
|
16
docs/yap.tex
16
docs/yap.tex
@ -4660,11 +4660,10 @@ undefined, declare it as dynamic.
|
|||||||
undefined, declare it as dynamic.
|
undefined, declare it as dynamic.
|
||||||
|
|
||||||
Most Prolog systems only allow asserting clauses for dynamic
|
Most Prolog systems only allow asserting clauses for dynamic
|
||||||
predicates. This is also as specified in the ISO
|
predicates. This is also as specified in the ISO standard. YAP allows
|
||||||
standard. YAP allows asserting clauses for static predicates,
|
asserting clauses for static predicates. The current version of YAP
|
||||||
as long as the predicate is not in use. The current version of
|
supports this feature, but this feature is deprecated and support may go
|
||||||
YAP supports this feature, but this feature is deprecated and
|
away in future versions.
|
||||||
support may go away in future versions.
|
|
||||||
|
|
||||||
@item abolish(+@var{PredSpec}) [ISO]
|
@item abolish(+@var{PredSpec}) [ISO]
|
||||||
@findex abolish/1
|
@findex abolish/1
|
||||||
@ -4675,8 +4674,7 @@ support may go away in future versions.
|
|||||||
current module. The
|
current module. The
|
||||||
specification must include the name and arity, and it may include module
|
specification must include the name and arity, and it may include module
|
||||||
information. Under @t{iso} language mode this builtin will only abolish
|
information. Under @t{iso} language mode this builtin will only abolish
|
||||||
dynamic procedures. Under other modes it will abolish any procedures, as
|
dynamic procedures. Under other modes it will abolish any procedures.
|
||||||
long as they are not currently in use.
|
|
||||||
|
|
||||||
@item abolish(+@var{P},+@var{N})
|
@item abolish(+@var{P},+@var{N})
|
||||||
@findex abolish/2
|
@findex abolish/2
|
||||||
@ -4689,8 +4687,8 @@ both static and dynamic predicates.
|
|||||||
@findex assert_static/1
|
@findex assert_static/1
|
||||||
@snindex assert_static/1
|
@snindex assert_static/1
|
||||||
@cnindex assert_static/1
|
@cnindex assert_static/1
|
||||||
Adds clause @var{C} to a static procedure. Asserting a static clause
|
Adds clause @var{C} to a static procedure. Asserting a static clause
|
||||||
for a predicate while choice-points for the predicate are availabe has
|
for a predicate while choice-points for the predicate are available has
|
||||||
undefined results.
|
undefined results.
|
||||||
|
|
||||||
@item asserta_static(:@var{C})
|
@item asserta_static(:@var{C})
|
||||||
|
@ -485,9 +485,6 @@ abolish(X) :-
|
|||||||
'$abolishd'(T, M) :- '$kill_dynamic'(T,M), fail.
|
'$abolishd'(T, M) :- '$kill_dynamic'(T,M), fail.
|
||||||
'$abolishd'(_, _).
|
'$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), !,
|
'$abolishs'(G, M) :- '$system_predicate'(G,M), !,
|
||||||
functor(G,Name,Arity),
|
functor(G,Name,Arity),
|
||||||
throw(error(permission_error(modify,static_procedure,Name/Arity),abolish(M:G))).
|
throw(error(permission_error(modify,static_procedure,Name/Arity),abolish(M:G))).
|
||||||
|
Reference in New Issue
Block a user