From 8f41517e241ab2fe876c0307004f0d594390e563 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Santos=20Costa=20II?= Date: Wed, 3 Mar 2010 19:08:17 +0000 Subject: [PATCH 1/2] del_attrs/1 (for SWI compatibility). --- C/attvar.c | 25 +++++++++++++++++++++++++ library/dialect/swi.yap | 3 +++ 2 files changed, 28 insertions(+) diff --git a/C/attvar.c b/C/attvar.c index 93447a08f..cd789b82b 100644 --- a/C/attvar.c +++ b/C/attvar.c @@ -357,6 +357,15 @@ DelAtts(attvar_record *attv, Term oatt) } } +static void +DelAllAtts(attvar_record *attv) +{ + if (RepAppl(attv->Atts) >= HB) + RESET_VARIABLE(&attv->Atts); + else + MaBind(&(attv->Atts), MkVarTerm()); +} + static void PutAtt(Int pos, Term atts, Term att) { @@ -638,6 +647,21 @@ p_del_atts(void) { } } +static Int +p_del_all_atts(void) { + /* receive a variable in ARG1 */ + Term inp = Deref(ARG1); + + /* if this is unbound, ok */ + if (IsVarTerm(inp) && IsAttachedTerm(inp)) { + attvar_record *attv; + + attv = (attvar_record *)VarOfTerm(inp); + DelAllAtts(attv); + } + return TRUE; +} + static Int p_get_att(void) { /* receive a variable in ARG1 */ @@ -1010,6 +1034,7 @@ void Yap_InitAttVarPreds(void) Yap_InitCPred("put_att_term", 2, p_put_att_term, 0); Yap_InitCPred("put_module_atts", 2, p_put_atts, 0); Yap_InitCPred("del_all_module_atts", 2, p_del_atts, 0); + Yap_InitCPred("del_all_atts", 1, p_del_all_atts, 0); Yap_InitCPred("rm_att", 4, p_rm_att, 0); Yap_InitCPred("bind_attvar", 1, p_bind_attvar, SafePredFlag); Yap_InitCPred("unbind_attvar", 1, p_unbind_attvar, SafePredFlag); diff --git a/library/dialect/swi.yap b/library/dialect/swi.yap index 1d2505c53..2edeb4692 100755 --- a/library/dialect/swi.yap +++ b/library/dialect/swi.yap @@ -284,6 +284,9 @@ prolog:del_attr(Var, Mod) :- functor(AttTerm, Mod, 2), attributes:del_all_module_atts(Var, AttTerm). +prolog:del_attrs(Var) :- + attributes:del_all_atts(Var). + prolog:get_attrs(AttVar, SWIAtts) :- get_all_swi_atts(AttVar,SWIAtts). From f4891180252a11b69256c76cc20dd6dc841af707 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Santos=20Costa=20II?= Date: Wed, 3 Mar 2010 19:08:59 +0000 Subject: [PATCH 2/2] small fix to consult. --- pl/consult.yap | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pl/consult.yap b/pl/consult.yap index d536a656a..9050c8248 100644 --- a/pl/consult.yap +++ b/pl/consult.yap @@ -172,9 +172,9 @@ consult(Fs) :- '$consult'(Fs,Module) :- '$access_yap_flags'(8, 2), % SICStus Prolog compatibility !, - '$load_files'(Module:Fs,[],Fs). + '$load_files'(Module:Fs,[],consult(Fs)). '$consult'(Fs, Module) :- - '$load_files'(Module:Fs,[consult(consult)],Fs). + '$load_files'(Module:Fs,[consult(consult)],consult(Fs)). reconsult(Fs) :- '$load_files'(Fs, [], reconsult(Fs)).