store tabling_mode info in the table_entry data structure
git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1329 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
parent
937887d3df
commit
9a85c9c0ff
@ -5,7 +5,7 @@
|
||||
|
||||
Copyright: R. Rocha and NCC - University of Porto, Portugal
|
||||
File: opt.preds.c
|
||||
version: $Id: opt.preds.c,v 1.17 2005-06-03 18:28:11 ricroc Exp $
|
||||
version: $Id: opt.preds.c,v 1.18 2005-06-04 08:05:27 ricroc Exp $
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
@ -490,7 +490,7 @@ int p_do_table(void) {
|
||||
static
|
||||
int p_do_tabling_mode(void) {
|
||||
Term t, mod, s;
|
||||
PredEntry *pe;
|
||||
tab_ent_ptr tab_ent;
|
||||
|
||||
mod = Deref(ARG2);
|
||||
if (IsVarTerm(mod) || !IsAtomTerm(mod)) {
|
||||
@ -499,20 +499,20 @@ int p_do_tabling_mode(void) {
|
||||
t = Deref(ARG1);
|
||||
if (IsAtomTerm(t)) {
|
||||
Atom at = AtomOfTerm(t);
|
||||
pe = RepPredProp(PredPropByAtom(at, mod));
|
||||
tab_ent = RepPredProp(PredPropByAtom(at, mod))->TableOfPred;
|
||||
} else if (IsApplTerm(t)) {
|
||||
Functor func = FunctorOfTerm(t);
|
||||
pe = RepPredProp(PredPropByFunc(func, mod));
|
||||
tab_ent = RepPredProp(PredPropByFunc(func, mod))->TableOfPred;
|
||||
} else {
|
||||
return (FALSE);
|
||||
}
|
||||
s = Deref(ARG3);
|
||||
if (IsVarTerm(s)) {
|
||||
Term sa;
|
||||
if (pe->PredFlags & LocalSchedPredFlag) {
|
||||
sa = MkAtomTerm(Yap_LookupAtom("local"));
|
||||
} else {
|
||||
if (TabEnt_mode(tab_ent) == batched) {
|
||||
sa = MkAtomTerm(Yap_LookupAtom("batched"));
|
||||
} else {
|
||||
sa = MkAtomTerm(Yap_LookupAtom("local"));
|
||||
}
|
||||
Bind((CELL *)s, sa);
|
||||
return(TRUE);
|
||||
@ -520,12 +520,12 @@ int p_do_tabling_mode(void) {
|
||||
if (IsAtomTerm(s)) {
|
||||
char *sa;
|
||||
sa = RepAtom(AtomOfTerm(s))->StrOfAE;
|
||||
if (strcmp(sa, "local") == 0) {
|
||||
pe->PredFlags |= LocalSchedPredFlag;
|
||||
if (strcmp(sa,"batched") == 0) {
|
||||
TabEnt_mode(tab_ent) = batched;
|
||||
return(TRUE);
|
||||
}
|
||||
if (strcmp(sa,"batched") == 0) {
|
||||
pe->PredFlags &= ~LocalSchedPredFlag;
|
||||
if (strcmp(sa, "local") == 0) {
|
||||
TabEnt_mode(tab_ent) = local;
|
||||
return(TRUE);
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
Copyright: R. Rocha and NCC - University of Porto, Portugal
|
||||
File: tab.insts.i
|
||||
version: $Id: tab.insts.i,v 1.14 2005-06-03 08:19:18 ricroc Exp $
|
||||
version: $Id: tab.insts.i,v 1.15 2005-06-04 08:05:27 ricroc Exp $
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
#else
|
||||
#define TABLING_ERRORS_check_stack
|
||||
#endif /* TABLING_ERRORS */
|
||||
#define store_generator_node(ARITY, AP, SG_FR) \
|
||||
#define store_generator_node(TAB_ENT, SG_FR, ARITY, AP) \
|
||||
{ register int subs_arity = *YENV; \
|
||||
register CELL *pt_args; \
|
||||
register choiceptr gcp; \
|
||||
@ -52,7 +52,7 @@
|
||||
/*if (SgFr_abolish(SG_FR) == 0) {*/ \
|
||||
if (subs_arity == 0 || \
|
||||
(yap_flags[TABLING_MODE_FLAG] != TABLING_MODE_LOCAL && \
|
||||
(!(PREG->u.ld.p->PredFlags & LocalSchedPredFlag) || \
|
||||
(TabEnt_mode(TAB_ENT) == batched || \
|
||||
yap_flags[TABLING_MODE_FLAG] == TABLING_MODE_BATCHED))) { \
|
||||
\
|
||||
\
|
||||
@ -240,7 +240,7 @@
|
||||
/* subgoal new or abolished */
|
||||
init_subgoal_frame(sg_fr);
|
||||
UNLOCK(SgFr_lock(sg_fr));
|
||||
store_generator_node(PREG->u.ld.s, COMPLETION, sg_fr);
|
||||
store_generator_node(tab_ent, sg_fr, PREG->u.ld.s, COMPLETION);
|
||||
PREG = PREG->u.ld.d; /* PREG = NEXTOP(PREG,ld); */
|
||||
PREFETCH_OP(PREG);
|
||||
allocate_environment();
|
||||
@ -310,7 +310,7 @@
|
||||
/* subgoal new or abolished */
|
||||
init_subgoal_frame(sg_fr);
|
||||
UNLOCK(SgFr_lock(sg_fr));
|
||||
store_generator_node(PREG->u.ld.s, PREG->u.ld.d, sg_fr);
|
||||
store_generator_node(tab_ent, sg_fr, PREG->u.ld.s, PREG->u.ld.d);
|
||||
PREG = NEXTOP(PREG, ld);
|
||||
PREFETCH_OP(PREG);
|
||||
allocate_environment();
|
||||
@ -380,7 +380,7 @@
|
||||
/* subgoal new or abolished */
|
||||
init_subgoal_frame(sg_fr);
|
||||
UNLOCK(SgFr_lock(sg_fr));
|
||||
store_generator_node(PREG->u.ld.s, NEXTOP(PREG,ld), sg_fr);
|
||||
store_generator_node(tab_ent, sg_fr, PREG->u.ld.s, NEXTOP(PREG,ld));
|
||||
PREG = PREG->u.ld.d;
|
||||
PREFETCH_OP(PREG);
|
||||
allocate_environment();
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
Copyright: R. Rocha and NCC - University of Porto, Portugal
|
||||
File: tab.structs.h
|
||||
version: $Id: tab.structs.h,v 1.5 2005-05-31 08:24:24 ricroc Exp $
|
||||
version: $Id: tab.structs.h,v 1.6 2005-06-04 08:05:27 ricroc Exp $
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
@ -17,12 +17,17 @@ typedef struct table_entry {
|
||||
#ifdef YAPOR
|
||||
lockvar lock;
|
||||
#endif /* YAPOR */
|
||||
enum {
|
||||
batched = 0,
|
||||
local = 1
|
||||
} tabling_mode;
|
||||
struct subgoal_trie_node *subgoal_trie;
|
||||
struct subgoal_hash *hash_chain;
|
||||
struct table_entry *next;
|
||||
} *tab_ent_ptr;
|
||||
|
||||
#define TabEnt_lock(X) ((X)->lock)
|
||||
#define TabEnt_mode(X) ((X)->tabling_mode)
|
||||
#define TabEnt_subgoal_trie(X) ((X)->subgoal_trie)
|
||||
#define TabEnt_hash_chain(X) ((X)->hash_chain)
|
||||
#define TabEnt_next(X) ((X)->next)
|
||||
@ -118,9 +123,9 @@ typedef struct subgoal_frame {
|
||||
struct answer_trie_node *last_answer;
|
||||
struct answer_hash *hash_chain;
|
||||
enum {
|
||||
start = 0,
|
||||
start = 0,
|
||||
evaluating = 1,
|
||||
complete = 2,
|
||||
complete = 2,
|
||||
executable = 3
|
||||
} state_flag;
|
||||
int abolish_operations;
|
||||
|
Reference in New Issue
Block a user