IsUnboundVar should check addresses

git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1144 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
vsc 2004-09-18 14:03:42 +00:00
parent 2144835fe5
commit 2e2df1a64f
7 changed files with 26 additions and 20 deletions

View File

@ -684,7 +684,7 @@ p_create_array(void)
ArrayEntry *app = (ArrayEntry *) pp; ArrayEntry *app = (ArrayEntry *) pp;
WRITE_UNLOCK(ae->ARWLock); WRITE_UNLOCK(ae->ARWLock);
if (!IsVarTerm(app->ValueOfVE) || !IsUnboundVar(app->ValueOfVE)) if (!IsVarTerm(app->ValueOfVE) || !IsUnboundVar(&app->ValueOfVE))
Yap_Error(PERMISSION_ERROR_CREATE_ARRAY,t,"create_array", Yap_Error(PERMISSION_ERROR_CREATE_ARRAY,t,"create_array",
ae->StrOfAE); ae->StrOfAE);
else { else {
@ -781,7 +781,7 @@ p_create_static_array(void)
return(FALSE); return(FALSE);
return (TRUE); return (TRUE);
} else if (ArrayIsDynamic(app)) { } else if (ArrayIsDynamic(app)) {
if (IsVarTerm(app->ValueOfVE) && IsUnboundVar(app->ValueOfVE)) { if (IsVarTerm(app->ValueOfVE) && IsUnboundVar(&app->ValueOfVE)) {
pp = CreateStaticArray(ae, size, props, NULL, pp); pp = CreateStaticArray(ae, size, props, NULL, pp);
if (pp == NULL) if (pp == NULL)
return(FALSE); return(FALSE);

View File

@ -98,7 +98,7 @@ CopyAttVar(CELL *orig, CELL ***to_visit_ptr, CELL *res)
to_visit[0] = vt-1; to_visit[0] = vt-1;
to_visit[1] = vt; to_visit[1] = vt;
to_visit[2] = newv->Atts+2*j+1; to_visit[2] = newv->Atts+2*j+1;
to_visit[3] = vt; to_visit[3] = (CELL *)vt[-1];
to_visit += 4; to_visit += 4;
} }
} else if (IsVarTerm(t) && IsAtomicTerm(t)) { } else if (IsVarTerm(t) && IsAtomicTerm(t)) {
@ -161,7 +161,7 @@ WakeAttVar(CELL* pt1, CELL reg2)
return; return;
} }
if (susp2 >= attv) { if (susp2 >= attv) {
if (!IsVarTerm(susp2->Value) || !IsUnboundVar(susp2->Value)) { if (!IsVarTerm(susp2->Value) || !IsUnboundVar(&susp2->Value)) {
/* oops, our goal is on the queue to be woken */ /* oops, our goal is on the queue to be woken */
if (!Yap_unify(susp2->Value, (CELL)pt1)) { if (!Yap_unify(susp2->Value, (CELL)pt1)) {
AddFailToQueue(); AddFailToQueue();
@ -176,7 +176,7 @@ WakeAttVar(CELL* pt1, CELL reg2)
return; return;
} }
} }
if (!IsVarTerm(attv->Value) || !IsUnboundVar(attv->Value)) { if (!IsVarTerm(attv->Value) || !IsUnboundVar(&attv->Value)) {
/* oops, our goal is on the queue to be woken */ /* oops, our goal is on the queue to be woken */
if (!Yap_unify(attv->Value, reg2)) { if (!Yap_unify(attv->Value, reg2)) {
AddFailToQueue(); AddFailToQueue();
@ -283,7 +283,7 @@ static Int
UpdateAtt(attvar_record *attv, Int i, Term tatt) { UpdateAtt(attvar_record *attv, Int i, Term tatt) {
Int pos = i*2; Int pos = i*2;
Term tv = attv->Atts[pos+1]; Term tv = attv->Atts[pos+1];
if (!IsVarTerm(tv) || !IsUnboundVar(tv)) { if (!IsVarTerm(tv) || !IsUnboundVar(attv->Atts+pos+1)) {
tatt = MkPairTerm(tatt, attv->Atts[pos+1]); tatt = MkPairTerm(tatt, attv->Atts[pos+1]);
} else { } else {
tatt = MkPairTerm(tatt, TermNil); tatt = MkPairTerm(tatt, TermNil);
@ -390,7 +390,7 @@ static Int
GetAtt(attvar_record *attv, int i) { GetAtt(attvar_record *attv, int i) {
Int pos = i *2; Int pos = i *2;
#if SBA #if SBA
if (IsVarTerm(attv->Atts[pos+1]) && IsUnboundVar(attv->Atts[pos+1])) if (IsVarTerm(attv->Atts[pos+1]) && IsUnboundVar(attv->Atts+pos+1))
return((CELL)&(attv->Atts[pos+1])); return((CELL)&(attv->Atts[pos+1]));
#endif #endif
return(attv->Atts[pos+1]); return(attv->Atts[pos+1]);
@ -404,7 +404,7 @@ FreeAtt(attvar_record *attv, int i) {
static Int static Int
BindAttVar(attvar_record *attv) { BindAttVar(attvar_record *attv) {
if (IsVarTerm(attv->Done) && IsUnboundVar(attv->Done)) { if (IsVarTerm(attv->Done) && IsUnboundVar(&attv->Done)) {
/* make sure we are not trying to bind a variable against itself */ /* make sure we are not trying to bind a variable against itself */
if (!IsVarTerm(attv->Value)) { if (!IsVarTerm(attv->Value)) {
Bind_Global(&(attv->Done), attv->Value); Bind_Global(&(attv->Done), attv->Value);
@ -450,7 +450,7 @@ AllAttVars(Term t) {
return(t); return(t);
} else { } else {
attvar_record *attv = (attvar_record *)VarOfTerm(t); attvar_record *attv = (attvar_record *)VarOfTerm(t);
if (!IsVarTerm(attv->Done) || !IsUnboundVar(attv->Done)) if (!IsVarTerm(attv->Done) || !IsUnboundVar(&attv->Done))
return(AllAttVars(attv->NS)); return(AllAttVars(attv->NS));
else return(MkPairTerm(t,AllAttVars(attv->NS))); else return(MkPairTerm(t,AllAttVars(attv->NS)));
} }
@ -665,7 +665,7 @@ p_attvar_bound(void)
return(IsVarTerm(t) && return(IsVarTerm(t) &&
IsAttachedTerm(t) && IsAttachedTerm(t) &&
((attvar_record *)VarOfTerm(t))->sus_id == attvars_ext && ((attvar_record *)VarOfTerm(t))->sus_id == attvars_ext &&
!IsUnboundVar(((attvar_record *)VarOfTerm(t))->Done)); !IsUnboundVar(&((attvar_record *)VarOfTerm(t))->Done));
} }
#else #else

View File

@ -2373,7 +2373,7 @@ p_still_variant(void)
while ((link = *lp++)) { while ((link = *lp++)) {
Term t2 = Deref(old_h[link-1]); Term t2 = Deref(old_h[link-1]);
if (IsUnboundVar((CELL)(dbt->Contents+(link-1)))) { if (IsUnboundVar(dbt->Contents+(link-1))) {
if (IsVarTerm(t2)) { if (IsVarTerm(t2)) {
Yap_unify(t2,MkAtomTerm(AtomFoundVar)); Yap_unify(t2,MkAtomTerm(AtomFoundVar));
} else { } else {

View File

@ -1022,7 +1022,7 @@ check_global(void) {
ArityOfFunctor((Functor)ccurr));*/ ArityOfFunctor((Functor)ccurr));*/
vars[gc_func]++; vars[gc_func]++;
} }
else if (IsUnboundVar((CELL)current)) vars[gc_var]++; else if (IsUnboundVar(current)) vars[gc_var]++;
else vars[gc_ref]++; else vars[gc_ref]++;
} else if (IsApplTerm(ccurr)) { } else if (IsApplTerm(ccurr)) {
/* printf("%p: f->%p\n",current,RepAppl(ccurr)); */ /* printf("%p: f->%p\n",current,RepAppl(ccurr)); */

View File

@ -410,7 +410,8 @@ Yap_CopyTerm(Term inp) {
static Int static Int
p_copy_term(void) /* copy term t to a new instance */ p_copy_term(void) /* copy term t to a new instance */
{ {
return(Yap_unify(ARG2,CopyTerm(ARG1))); Term t = CopyTerm(ARG1);
return Yap_unify(ARG2,t);
} }
static int copy_complex_term_no_delays(register CELL *pt0, register CELL *pt0_end, CELL *ptf, CELL *HLow) static int copy_complex_term_no_delays(register CELL *pt0, register CELL *pt0_end, CELL *ptf, CELL *HLow)
@ -1734,7 +1735,7 @@ static int subsumes_complex(register CELL *pt0, register CELL *pt0_end, register
/* cell we created */ /* cell we created */
CELL *npt1 = (CELL *)*pt1; CELL *npt1 = (CELL *)*pt1;
/* shorten the chain */ /* shorten the chain */
if (IsVarTerm(*pt1) && IsUnboundVar(*pt1)) { if (IsVarTerm(*pt1) && IsUnboundVar(pt1)) {
RESET_VARIABLE(pt1); RESET_VARIABLE(pt1);
} else { } else {
*pt1 = *npt1; *pt1 = *npt1;

View File

@ -10,7 +10,7 @@
* File: Yap.h.m4 * * File: Yap.h.m4 *
* mods: * * mods: *
* comments: main header file for YAP * * comments: main header file for YAP *
* version: $Id: Yap.h.m4,v 1.65 2004-09-17 19:34:52 vsc Exp $ * * version: $Id: Yap.h.m4,v 1.66 2004-09-18 14:03:42 vsc Exp $ *
*************************************************************************/ *************************************************************************/
#include "config.h" #include "config.h"
@ -769,10 +769,10 @@ extern int Yap_output_msg;
Destructor(Term, VarOf, Term *, t, t) Destructor(Term, VarOf, Term *, t, t)
#if SBA #if SBA
Inline0(MkVarTerm, Term, (*H = 0, H++)) Inline0(MkVarTerm, Term, (*H = 0, H++))
Inline(IsUnboundVar, int, Term, t, t == 0) Inline(IsUnboundVar, int, Term *, t, *(t) == 0)
#else #else
Inline0(MkVarTerm, Term, (*H = (CELL) H, H++)) Inline0(MkVarTerm, Term, (*H = (CELL) H, H++))
Inline(IsUnboundVar, int, Term, t, *VarOfTerm(t) == (t)) Inline(IsUnboundVar, int, Term *, t, *(t) == (Term)(t))
#endif #endif
Inline(PtrOfTerm, CELL *, Term, t, *(CELL *)(t)) Inline(PtrOfTerm, CELL *, Term, t, *(CELL *)(t))

View File

@ -57,8 +57,8 @@
%'$wake_up_goal'([Module1|Continuation],G) :- %'$wake_up_goal'([Module1|Continuation],G) :-
% '$write'(4,vsc_woke:G+[Module1|Continuation]:' % '$write'(4,vsc_woke:G+[Module1|Continuation]:'
%'), fail. %'), fail.
'$wake_up_goal'([Module1|Continuation], LG0) :- '$wake_up_goal'([Module1|Continuation], LG) :-
'$sort'(LG0,LG), %write(waking:LG),nl,
'$execute_woken_system_goals'(LG), '$execute_woken_system_goals'(LG),
'$do_continuation'(Continuation, Module1). '$do_continuation'(Continuation, Module1).
@ -95,7 +95,6 @@
'$execute_woken_system_goal'('$att_do'(V,New)) :- '$execute_woken_system_goal'('$att_do'(V,New)) :-
( '$frozen_goals'(V, Goals) -> ( '$frozen_goals'(V, Goals) ->
'$call_atts'(V,New), '$call_atts'(V,New),
% write(vsc:Goals),nl,
'$execute_frozen_goals'(Goals) '$execute_frozen_goals'(Goals)
; ;
'$call_atts'(V,New) '$call_atts'(V,New)
@ -706,9 +705,15 @@ call_residue(Goal,Residue) :-
'$process_when'(G, NG). '$process_when'(G, NG).
'$process_when'(G, G). '$process_when'(G, G).
%'$freeze'(V,G) :-
% attributes:get_att(V, 0, Gs), write(G+Gs),nl,fail.
'$freeze'(V,G) :- '$freeze'(V,G) :-
attributes:update_att(V, 0, G). attributes:update_att(V, 0, G).
'$goal_in'(G,[G1|_]) :- G == G1, !.
'$goal_in'(G,[_|Gs]) :-
'$goal_in'(G,Gs).
'$frozen_goals'(V,Gs) :- '$frozen_goals'(V,Gs) :-
var(V), var(V),
attributes:get_att(V, 0, Gs), nonvar(Gs). attributes:get_att(V, 0, Gs), nonvar(Gs).