From 92f647556dded4f3dfd72e6013b3d9686aedc76d Mon Sep 17 00:00:00 2001 From: Vitor Santos Costa Date: Sat, 27 Nov 2010 10:20:52 +0000 Subject: [PATCH 1/5] prolog_to_os_filename is now built-in. --- library/dialect/swi.yap | 4 ---- 1 file changed, 4 deletions(-) diff --git a/library/dialect/swi.yap b/library/dialect/swi.yap index fea5696be..69474c30f 100755 --- a/library/dialect/swi.yap +++ b/library/dialect/swi.yap @@ -6,7 +6,6 @@ :- module(system, [concat_atom/2, concat_atom/3, setenv/2, - prolog_to_os_filename/2, is_absolute_file_name/1, read_clause/1, string/1, @@ -224,7 +223,6 @@ goal_expansion(rename_file(A,B),system:swi_rename_file(A,B)) :- swi_io. goal_expansion(is_absolute_file_name(A), is_absolute_file_name(A)) :- swi_io. goal_expansion(file_base_name(A,B),system:swi_file_base_name(A,B)) :- swi_io. goal_expansion(file_directory_name(A,B),system:swi_file_directory_name(A,B)) :- swi_io. -goal_expansion(prolog_to_os_filename(A,B),system:swi_prolog_to_os_filename(A,B)) :- swi_io. goal_expansion('$mark_executable'(A), system:'swi_is_absolute_file_name'(A)) :- swi_io. goal_expansion('$absolute_file_name'(A,B),system:'swi_$absolute_file_name'(A,B)) :- swi_io. @@ -281,8 +279,6 @@ concat_atom(List, New) :- setenv(X,Y) :- unix(putenv(X,Y)). -prolog_to_os_filename(X,X). - is_absolute_file_name(X) :- absolute_file_name(X,X). From c47419ed037758907981f754d6292154f45087ed Mon Sep 17 00:00:00 2001 From: Vitor Santos Costa Date: Sun, 28 Nov 2010 11:50:21 +0000 Subject: [PATCH 2/5] better support for YAP portability. --- packages/semweb/rdf_db.pl | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/packages/semweb/rdf_db.pl b/packages/semweb/rdf_db.pl index 449cc7bff..9ad5671e2 100644 --- a/packages/semweb/rdf_db.pl +++ b/packages/semweb/rdf_db.pl @@ -127,6 +127,10 @@ (rdf_meta)/1, % +Heads op(1150, fx, (rdf_meta)) ]). + +:- expects_dialect(swi). +:- assert(system:swi_io). + :- use_module(library(rdf)). :- use_module(library(lists)). :- use_module(library(shlib)). @@ -153,6 +157,16 @@ :- discontiguous term_expansion/2. +:- meta_predicate + rdf_transaction(0), + rdf_transaction(0, +), + rdf_monitor(1, +), + rdf_save(+, :), + rdf_load(+, :). + +:- thread_local + named_anon/2. % +Resource, -Id + /** Core RDF database @see Documentation for semweb package @@ -1369,16 +1383,6 @@ rdf_reset_db :- % file-url (=|file://path|=) or a stream wrapped % in a term stream(Out). -:- meta_predicate - rdf_transaction(0), - rdf_transaction(0, +), - rdf_monitor(1, +), - rdf_save(+, :), - rdf_load(+, :). - -:- thread_local - named_anon/2. % +Resource, -Id - rdf_save(File) :- rdf_save2(File, []). @@ -2183,3 +2187,7 @@ into(_, _) --> []. % TBD in_time(Triples, ParseTime) --> [ ' in ~2f sec; ~D triples'-[ParseTime, Triples] ]. + +:- retract(system:swi_io). + + From f4bda9b043ce59e574cda802d51a4aa113216afc Mon Sep 17 00:00:00 2001 From: Vitor Santos Costa Date: Sun, 28 Nov 2010 11:50:41 +0000 Subject: [PATCH 3/5] fix build compund term. --- library/yap2swi/yap2swi.c | 53 +++++++++++++++++++++++---------------- 1 file changed, 31 insertions(+), 22 deletions(-) diff --git a/library/yap2swi/yap2swi.c b/library/yap2swi/yap2swi.c index aff9330bb..d1cf2e9ec 100755 --- a/library/yap2swi/yap2swi.c +++ b/library/yap2swi/yap2swi.c @@ -1129,7 +1129,7 @@ X_API int PL_cons_functor(term_t d, functor_t f,...) { va_list ap; int arity, i; - Term *tmp = (Term *)SWI_buffers[0]; + Term *tmp, t; Functor ff = SWIFunctorToFunctor(f); if (IsAtomTerm((Term)ff)) { @@ -1137,46 +1137,55 @@ X_API int PL_cons_functor(term_t d, functor_t f,...) return TRUE; } arity = ArityOfFunctor(ff); - if (arity > SWI_TMP_BUF_SIZE/sizeof(YAP_CELL)) { - fprintf(stderr,"PL_cons_functor: arity too large (%d)\n", arity); - return FALSE; + while (Unsigned(H+arity) > Unsigned(ASP)-CreepFlag) { + if (!Yap_gc(0, ENV, CP)) { + return FALSE; + } + } + if (arity == 2 && ff == FunctorDot) { + t = Yap_MkNewPairTerm(); + tmp = RepPair(t); + } else { + t = Yap_MkNewApplTerm(ff, arity); + tmp = RepAppl(t)+1; } va_start (ap, f); for (i = 0; i < arity; i++) { - tmp[i] = Yap_GetFromSlot(va_arg(ap, term_t)); + Yap_unify(tmp[i],Yap_GetFromSlot(va_arg(ap, term_t))); } va_end (ap); - if (arity == 2 && ff == FunctorDot) - Yap_PutInSlot(d,MkPairTerm(tmp[0],tmp[1])); - else - Yap_PutInSlot(d,Yap_MkApplTerm(ff,arity,tmp)); - if (Unsigned(H) > Unsigned(ASP)-CreepFlag) { - if (!Yap_gc(0, ENV, CP)) { - return FALSE; - } - } + Yap_PutInSlot(d,t); return TRUE; } -X_API int PL_cons_functor_v(term_t d, functor_t f,term_t a0) +X_API int PL_cons_functor_v(term_t d, functor_t f, term_t a0) { - int arity; + int arity, i; + Term *tmp, t; Functor ff = SWIFunctorToFunctor(f); if (IsAtomTerm((Term)ff)) { - Yap_PutInSlot(d,(Term)ff); + Yap_PutInSlot(d, (YAP_Term)f); return TRUE; } arity = ArityOfFunctor(ff); - if (arity == 2 && ff == FunctorDot) - Yap_PutInSlot(d,MkPairTerm(Yap_GetFromSlot(a0),Yap_GetFromSlot(a0+1))); - else - Yap_PutInSlot(d,Yap_MkApplTerm(ff,arity,Yap_AddressFromSlot(a0))); - if (Unsigned(H) > Unsigned(ASP)-CreepFlag) { + while (Unsigned(H+arity) > Unsigned(ASP)-CreepFlag) { if (!Yap_gc(0, ENV, CP)) { return FALSE; } } + if (arity == 2 && ff == FunctorDot) { + t = Yap_MkNewPairTerm(); + tmp = RepPair(t); + } else { + t = Yap_MkNewApplTerm(ff, arity); + tmp = RepAppl(t)+1; + } + for (i = 0; i < arity; i++) { + Yap_unify(tmp[i],Yap_GetFromSlot(a0)); + a0++; + } + Yap_PutInSlot(d,t); return TRUE; } From 4aee4df719ff2fc422ac50d6caebf963fec34266 Mon Sep 17 00:00:00 2001 From: Vitor Santos Costa Date: Sun, 28 Nov 2010 11:51:31 +0000 Subject: [PATCH 4/5] single initialization for top frame. --- C/exec.c | 5 ----- OPTYap/opt.init.c | 4 ++++ 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/C/exec.c b/C/exec.c index 8ff00e4ce..7588b175b 100644 --- a/C/exec.c +++ b/C/exec.c @@ -1034,11 +1034,6 @@ init_stack(int arity, CELL *pt, int top, choiceptr saved_b) } B = (choiceptr)ASP; B--; -#ifdef TABLING - if (top && GLOBAL_root_dep_fr) { - DepFr_cons_cp(GLOBAL_root_dep_fr) = B; - } -#endif /* TABLING */ B->cp_h = H; B->cp_tr = TR; B->cp_cp = CP; diff --git a/OPTYap/opt.init.c b/OPTYap/opt.init.c index 1d94e2024..3d58b8098 100644 --- a/OPTYap/opt.init.c +++ b/OPTYap/opt.init.c @@ -239,6 +239,10 @@ void make_root_frames(void) { /* root dependency frame */ if (!GLOBAL_root_dep_fr) { new_dependency_frame(GLOBAL_root_dep_fr, FALSE, NULL, NULL, NULL, NULL, NULL); +#ifdef TABLING + fprintf(stderr,"saved_b=%p\n", B); + DepFr_cons_cp(GLOBAL_root_dep_fr) = B; +#endif /* TABLING */ } #endif /* TABLING */ } From 2db6020e80ef1fdb59c6f620855d79ca2153bb9d Mon Sep 17 00:00:00 2001 From: Vitor Santos Costa Date: Sun, 28 Nov 2010 11:52:56 +0000 Subject: [PATCH 5/5] remove debugging message. --- OPTYap/opt.init.c | 1 - 1 file changed, 1 deletion(-) diff --git a/OPTYap/opt.init.c b/OPTYap/opt.init.c index 3d58b8098..8d6dcc2d1 100644 --- a/OPTYap/opt.init.c +++ b/OPTYap/opt.init.c @@ -240,7 +240,6 @@ void make_root_frames(void) { if (!GLOBAL_root_dep_fr) { new_dependency_frame(GLOBAL_root_dep_fr, FALSE, NULL, NULL, NULL, NULL, NULL); #ifdef TABLING - fprintf(stderr,"saved_b=%p\n", B); DepFr_cons_cp(GLOBAL_root_dep_fr) = B; #endif /* TABLING */ }