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:
parent
2144835fe5
commit
2e2df1a64f
@ -684,7 +684,7 @@ p_create_array(void)
|
||||
ArrayEntry *app = (ArrayEntry *) pp;
|
||||
|
||||
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",
|
||||
ae->StrOfAE);
|
||||
else {
|
||||
@ -781,7 +781,7 @@ p_create_static_array(void)
|
||||
return(FALSE);
|
||||
return (TRUE);
|
||||
} 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);
|
||||
if (pp == NULL)
|
||||
return(FALSE);
|
||||
|
16
C/attvar.c
16
C/attvar.c
@ -98,7 +98,7 @@ CopyAttVar(CELL *orig, CELL ***to_visit_ptr, CELL *res)
|
||||
to_visit[0] = vt-1;
|
||||
to_visit[1] = vt;
|
||||
to_visit[2] = newv->Atts+2*j+1;
|
||||
to_visit[3] = vt;
|
||||
to_visit[3] = (CELL *)vt[-1];
|
||||
to_visit += 4;
|
||||
}
|
||||
} else if (IsVarTerm(t) && IsAtomicTerm(t)) {
|
||||
@ -161,7 +161,7 @@ WakeAttVar(CELL* pt1, CELL reg2)
|
||||
return;
|
||||
}
|
||||
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 */
|
||||
if (!Yap_unify(susp2->Value, (CELL)pt1)) {
|
||||
AddFailToQueue();
|
||||
@ -176,7 +176,7 @@ WakeAttVar(CELL* pt1, CELL reg2)
|
||||
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 */
|
||||
if (!Yap_unify(attv->Value, reg2)) {
|
||||
AddFailToQueue();
|
||||
@ -283,7 +283,7 @@ static Int
|
||||
UpdateAtt(attvar_record *attv, Int i, Term tatt) {
|
||||
Int pos = i*2;
|
||||
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]);
|
||||
} else {
|
||||
tatt = MkPairTerm(tatt, TermNil);
|
||||
@ -390,7 +390,7 @@ static Int
|
||||
GetAtt(attvar_record *attv, int i) {
|
||||
Int pos = i *2;
|
||||
#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]));
|
||||
#endif
|
||||
return(attv->Atts[pos+1]);
|
||||
@ -404,7 +404,7 @@ FreeAtt(attvar_record *attv, int i) {
|
||||
|
||||
static Int
|
||||
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 */
|
||||
if (!IsVarTerm(attv->Value)) {
|
||||
Bind_Global(&(attv->Done), attv->Value);
|
||||
@ -450,7 +450,7 @@ AllAttVars(Term t) {
|
||||
return(t);
|
||||
} else {
|
||||
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));
|
||||
else return(MkPairTerm(t,AllAttVars(attv->NS)));
|
||||
}
|
||||
@ -665,7 +665,7 @@ p_attvar_bound(void)
|
||||
return(IsVarTerm(t) &&
|
||||
IsAttachedTerm(t) &&
|
||||
((attvar_record *)VarOfTerm(t))->sus_id == attvars_ext &&
|
||||
!IsUnboundVar(((attvar_record *)VarOfTerm(t))->Done));
|
||||
!IsUnboundVar(&((attvar_record *)VarOfTerm(t))->Done));
|
||||
}
|
||||
|
||||
#else
|
||||
|
@ -2373,7 +2373,7 @@ p_still_variant(void)
|
||||
|
||||
while ((link = *lp++)) {
|
||||
Term t2 = Deref(old_h[link-1]);
|
||||
if (IsUnboundVar((CELL)(dbt->Contents+(link-1)))) {
|
||||
if (IsUnboundVar(dbt->Contents+(link-1))) {
|
||||
if (IsVarTerm(t2)) {
|
||||
Yap_unify(t2,MkAtomTerm(AtomFoundVar));
|
||||
} else {
|
||||
|
@ -1022,7 +1022,7 @@ check_global(void) {
|
||||
ArityOfFunctor((Functor)ccurr));*/
|
||||
vars[gc_func]++;
|
||||
}
|
||||
else if (IsUnboundVar((CELL)current)) vars[gc_var]++;
|
||||
else if (IsUnboundVar(current)) vars[gc_var]++;
|
||||
else vars[gc_ref]++;
|
||||
} else if (IsApplTerm(ccurr)) {
|
||||
/* printf("%p: f->%p\n",current,RepAppl(ccurr)); */
|
||||
|
@ -410,7 +410,8 @@ Yap_CopyTerm(Term inp) {
|
||||
static Int
|
||||
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)
|
||||
@ -1734,7 +1735,7 @@ static int subsumes_complex(register CELL *pt0, register CELL *pt0_end, register
|
||||
/* cell we created */
|
||||
CELL *npt1 = (CELL *)*pt1;
|
||||
/* shorten the chain */
|
||||
if (IsVarTerm(*pt1) && IsUnboundVar(*pt1)) {
|
||||
if (IsVarTerm(*pt1) && IsUnboundVar(pt1)) {
|
||||
RESET_VARIABLE(pt1);
|
||||
} else {
|
||||
*pt1 = *npt1;
|
||||
|
@ -10,7 +10,7 @@
|
||||
* File: Yap.h.m4 *
|
||||
* mods: *
|
||||
* 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"
|
||||
@ -769,10 +769,10 @@ extern int Yap_output_msg;
|
||||
Destructor(Term, VarOf, Term *, t, t)
|
||||
#if SBA
|
||||
Inline0(MkVarTerm, Term, (*H = 0, H++))
|
||||
Inline(IsUnboundVar, int, Term, t, t == 0)
|
||||
Inline(IsUnboundVar, int, Term *, t, *(t) == 0)
|
||||
#else
|
||||
Inline0(MkVarTerm, Term, (*H = (CELL) H, H++))
|
||||
Inline(IsUnboundVar, int, Term, t, *VarOfTerm(t) == (t))
|
||||
Inline(IsUnboundVar, int, Term *, t, *(t) == (Term)(t))
|
||||
#endif
|
||||
Inline(PtrOfTerm, CELL *, Term, t, *(CELL *)(t))
|
||||
|
||||
|
@ -57,8 +57,8 @@
|
||||
%'$wake_up_goal'([Module1|Continuation],G) :-
|
||||
% '$write'(4,vsc_woke:G+[Module1|Continuation]:'
|
||||
%'), fail.
|
||||
'$wake_up_goal'([Module1|Continuation], LG0) :-
|
||||
'$sort'(LG0,LG),
|
||||
'$wake_up_goal'([Module1|Continuation], LG) :-
|
||||
%write(waking:LG),nl,
|
||||
'$execute_woken_system_goals'(LG),
|
||||
'$do_continuation'(Continuation, Module1).
|
||||
|
||||
@ -95,7 +95,6 @@
|
||||
'$execute_woken_system_goal'('$att_do'(V,New)) :-
|
||||
( '$frozen_goals'(V, Goals) ->
|
||||
'$call_atts'(V,New),
|
||||
% write(vsc:Goals),nl,
|
||||
'$execute_frozen_goals'(Goals)
|
||||
;
|
||||
'$call_atts'(V,New)
|
||||
@ -706,9 +705,15 @@ call_residue(Goal,Residue) :-
|
||||
'$process_when'(G, NG).
|
||||
'$process_when'(G, G).
|
||||
|
||||
%'$freeze'(V,G) :-
|
||||
% attributes:get_att(V, 0, Gs), write(G+Gs),nl,fail.
|
||||
'$freeze'(V,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) :-
|
||||
var(V),
|
||||
attributes:get_att(V, 0, Gs), nonvar(Gs).
|
||||
|
Reference in New Issue
Block a user