TABLING: new predicate 'is_tabled/1'.

git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1344 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
ricroc 2005-07-15 18:03:26 +00:00
parent 5ef65b053e
commit 6b3c81c56e
2 changed files with 42 additions and 2 deletions

View File

@ -236,6 +236,9 @@ yap_flag(tabling_mode,[]) :- !.
yap_flag(tabling_mode,[HOption|TOption]) :- !, yap_flag(tabling_mode,[HOption|TOption]) :- !,
yap_flag(tabling_mode,HOption), yap_flag(tabling_mode,HOption),
yap_flag(tabling_mode,TOption). yap_flag(tabling_mode,TOption).
yap_flag(tabling_mode,(Option1,Option2)) :- !,
yap_flag(tabling_mode,Option1),
yap_flag(tabling_mode,Option2).
yap_flag(tabling_mode,Option) :- yap_flag(tabling_mode,Option) :-
'$transl_to_tabling_mode'(Flag,Option), '$transl_to_tabling_mode'(Flag,Option),
'$set_yap_flags'(19,Flag). '$set_yap_flags'(19,Flag).

View File

@ -15,7 +15,7 @@
* * * *
*************************************************************************/ *************************************************************************/
:- meta_predicate table(:), tabling_mode(:), abolish_table(:), show_table(:), table_statistics(:). :- meta_predicate table(:), is_tabled(:), tabling_mode(:), abolish_table(:), show_table(:), table_statistics(:).
@ -60,6 +60,37 @@ table(Pred) :-
/**********************
* is_tabled/1 *
**********************/
is_tabled(Pred) :-
'$current_module'(Mod),
'$do_is_tabled'(Mod,Pred).
'$do_is_tabled'(Mod,Pred) :-
var(Pred), !,
'$do_error'(instantiation_error,is_tabled(Mod:Pred)).
'$do_is_tabled'(_,Mod:Pred) :- !,
'$do_is_tabled'(Mod,Pred).
'$do_is_tabled'(_,[]) :- !.
'$do_is_tabled'(Mod,[HPred|TPred]) :- !,
'$do_is_tabled'(Mod,HPred),
'$do_is_tabled'(Mod,TPred).
'$do_is_tabled'(Mod,(Pred1,Pred2)) :- !,
'$do_is_tabled'(Mod,Pred1),
'$do_is_tabled'(Mod,Pred2).
'$do_is_tabled'(Mod,PredName/PredArity) :-
atom(PredName),
integer(PredArity),
functor(PredFunctor,PredName,PredArity),
'$flags'(PredFunctor,Mod,Flags,Flags), !,
Flags /\ 0x000040 =\= 0.
'$do_is_tabled'(Mod,Pred) :-
'$do_error'(type_error(callable,Mod:Pred),is_tabled(Mod:Pred)).
/************************* /*************************
* tabling_mode/2 * * tabling_mode/2 *
*************************/ *************************/
@ -77,6 +108,9 @@ tabling_mode(Pred,Options) :-
'$do_tabling_mode'(Mod,[HPred|TPred],Options) :- !, '$do_tabling_mode'(Mod,[HPred|TPred],Options) :- !,
'$do_tabling_mode'(Mod,HPred,Options), '$do_tabling_mode'(Mod,HPred,Options),
'$do_tabling_mode'(Mod,TPred,Options). '$do_tabling_mode'(Mod,TPred,Options).
'$do_tabling_mode'(Mod,(Pred1,Pred2),Options) :- !,
'$do_tabling_mode'(Mod,Pred1,Options),
'$do_tabling_mode'(Mod,Pred2,Options).
'$do_tabling_mode'(Mod,PredName/PredArity,Options) :- '$do_tabling_mode'(Mod,PredName/PredArity,Options) :-
atom(PredName), atom(PredName),
integer(PredArity), integer(PredArity),
@ -95,6 +129,9 @@ tabling_mode(Pred,Options) :-
'$set_tabling_mode'(Mod,PredFunctor,[HOption|TOption]) :- !, '$set_tabling_mode'(Mod,PredFunctor,[HOption|TOption]) :- !,
'$set_tabling_mode'(Mod,PredFunctor,HOption), '$set_tabling_mode'(Mod,PredFunctor,HOption),
'$set_tabling_mode'(Mod,PredFunctor,TOption). '$set_tabling_mode'(Mod,PredFunctor,TOption).
'$set_tabling_mode'(Mod,PredFunctor,(Option1,Option2)) :- !,
'$set_tabling_mode'(Mod,PredFunctor,Option1),
'$set_tabling_mode'(Mod,PredFunctor,Option2).
'$set_tabling_mode'(Mod,PredFunctor,Option) :- '$set_tabling_mode'(Mod,PredFunctor,Option) :-
(Option = batched ; Option = local ; Option = exec_answers ; Option = load_answers), !, (Option = batched ; Option = local ; Option = exec_answers ; Option = load_answers), !,
'$c_tabling_mode'(Mod,PredFunctor,Option). '$c_tabling_mode'(Mod,PredFunctor,Option).