first steps to allow mavars with tabling
fix trailing for tabling with multiple get_cons git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1356 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
|
||||
Copyright: R. Rocha and NCC - University of Porto, Portugal
|
||||
File: opt.init.c
|
||||
version: $Id: opt.init.c,v 1.10 2005-08-04 15:45:55 ricroc Exp $
|
||||
version: $Id: opt.init.c,v 1.11 2005-08-05 14:55:03 vsc Exp $
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
@@ -31,9 +31,9 @@
|
||||
#include "opt.mavar.h"
|
||||
#endif /* !TABLING */
|
||||
#ifdef MULTI_ASSIGNMENT_VARIABLES
|
||||
ma_hash_entry ma_hash_table[MAVARS_HASH_SIZE];
|
||||
UInt timestamp; /* an unsigned int */
|
||||
ma_h_inner_struct *ma_h_top;
|
||||
ma_hash_entry Yap_ma_hash_table[MAVARS_HASH_SIZE];
|
||||
UInt Yap_timestamp; /* an unsigned int */
|
||||
ma_h_inner_struct *Yap_ma_h_top;
|
||||
#endif /* MULTI_ASSIGNMENT_VARIABLES */
|
||||
#endif /* TABLING || !ACOW */
|
||||
#ifdef ACOW
|
||||
|
@@ -5,7 +5,7 @@
|
||||
|
||||
Copyright: R. Rocha and NCC - University of Porto, Portugal
|
||||
File: opt.mavar.h
|
||||
version: $Id: opt.mavar.h,v 1.3 2005-05-31 08:24:24 ricroc Exp $
|
||||
version: $Id: opt.mavar.h,v 1.4 2005-08-05 14:55:03 vsc Exp $
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
@@ -31,17 +31,17 @@ typedef struct {
|
||||
struct ma_h_entry val;
|
||||
} ma_hash_entry;
|
||||
|
||||
extern ma_hash_entry ma_hash_table[MAVARS_HASH_SIZE];
|
||||
extern ma_hash_entry Yap_ma_hash_table[MAVARS_HASH_SIZE];
|
||||
|
||||
extern UInt timestamp; /* an unsigned int */
|
||||
extern UInt Yap_timestamp; /* an unsigned int */
|
||||
|
||||
OPT_MAVAR_STATIC unsigned int MAVAR_HASH(CELL *);
|
||||
OPT_MAVAR_STATIC struct ma_h_entry *ALLOC_NEW_MASPACE(void);
|
||||
OPT_MAVAR_STATIC int lookup_ma_var(CELL *);
|
||||
OPT_MAVAR_STATIC UInt NEW_MAHASH(ma_h_inner_struct *);
|
||||
OPT_MAVAR_STATIC unsigned int Yap_MAVAR_HASH(CELL *);
|
||||
OPT_MAVAR_STATIC struct ma_h_entry *Yap_ALLOC_NEW_MASPACE(void);
|
||||
OPT_MAVAR_STATIC int Yap_lookup_ma_var(CELL *);
|
||||
OPT_MAVAR_STATIC UInt Yap_NEW_MAHASH(ma_h_inner_struct *);
|
||||
|
||||
OPT_MAVAR_STATIC unsigned int
|
||||
MAVAR_HASH(CELL *addr) {
|
||||
Yap_MAVAR_HASH(CELL *addr) {
|
||||
#if SIZEOF_INT_P==8
|
||||
return((((unsigned int)((CELL)(addr)))>>3)%MAVARS_HASH_SIZE);
|
||||
#else
|
||||
@@ -49,56 +49,56 @@ MAVAR_HASH(CELL *addr) {
|
||||
#endif
|
||||
}
|
||||
|
||||
extern ma_h_inner_struct *ma_h_top;
|
||||
extern ma_h_inner_struct *Yap_ma_h_top;
|
||||
|
||||
OPT_MAVAR_STATIC struct ma_h_entry *
|
||||
ALLOC_NEW_MASPACE(void)
|
||||
Yap_ALLOC_NEW_MASPACE(void)
|
||||
{
|
||||
ma_h_inner_struct *new = ma_h_top;
|
||||
ma_h_top++;
|
||||
return(new);
|
||||
ma_h_inner_struct *new = Yap_ma_h_top;
|
||||
Yap_ma_h_top++;
|
||||
return new;
|
||||
}
|
||||
|
||||
OPT_MAVAR_STATIC int
|
||||
lookup_ma_var(CELL *addr) {
|
||||
unsigned int i = MAVAR_HASH(addr);
|
||||
Yap_lookup_ma_var(CELL *addr) {
|
||||
unsigned int i = Yap_MAVAR_HASH(addr);
|
||||
struct ma_h_entry *nptr, *optr;
|
||||
|
||||
if (ma_hash_table[i].timestmp != timestamp) {
|
||||
ma_hash_table[i].timestmp = timestamp;
|
||||
ma_hash_table[i].val.addr = addr;
|
||||
ma_hash_table[i].val.next = NULL;
|
||||
return(FALSE);
|
||||
if (Yap_ma_hash_table[i].timestmp != Yap_timestamp) {
|
||||
Yap_ma_hash_table[i].timestmp = Yap_timestamp;
|
||||
Yap_ma_hash_table[i].val.addr = addr;
|
||||
Yap_ma_hash_table[i].val.next = NULL;
|
||||
return FALSE;
|
||||
}
|
||||
if (ma_hash_table[i].val.addr == addr)
|
||||
return(TRUE);
|
||||
optr = &(ma_hash_table[i].val);
|
||||
nptr = ma_hash_table[i].val.next;
|
||||
if (Yap_ma_hash_table[i].val.addr == addr)
|
||||
return TRUE;
|
||||
optr = &(Yap_ma_hash_table[i].val);
|
||||
nptr = Yap_ma_hash_table[i].val.next;
|
||||
while (nptr != NULL) {
|
||||
if (nptr->addr == addr) {
|
||||
return(TRUE);
|
||||
return TRUE;
|
||||
}
|
||||
optr = nptr;
|
||||
nptr = nptr->next;
|
||||
}
|
||||
nptr = ALLOC_NEW_MASPACE();
|
||||
nptr = Yap_ALLOC_NEW_MASPACE();
|
||||
nptr->addr = addr;
|
||||
nptr->next = optr;
|
||||
return(FALSE);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
OPT_MAVAR_STATIC UInt
|
||||
NEW_MAHASH(ma_h_inner_struct *top) {
|
||||
UInt time = ++timestamp;
|
||||
Yap_NEW_MAHASH(ma_h_inner_struct *top) {
|
||||
UInt time = ++Yap_timestamp;
|
||||
if (time == 0) {
|
||||
unsigned int i;
|
||||
/* damn, we overflowed */
|
||||
for (i = 0; i < MAVARS_HASH_SIZE; i++)
|
||||
ma_hash_table[i].timestmp = 0;
|
||||
time = ++timestamp;
|
||||
Yap_ma_hash_table[i].timestmp = 0;
|
||||
time = ++Yap_timestamp;
|
||||
}
|
||||
ma_h_top = top;
|
||||
return(time);
|
||||
Yap_ma_h_top = top;
|
||||
return time;
|
||||
}
|
||||
|
||||
#endif /* MULTI_ASSIGNMENT_VARIABLES */
|
||||
|
@@ -5,7 +5,7 @@
|
||||
|
||||
Copyright: R. Rocha and NCC - University of Porto, Portugal
|
||||
File: tab.insts.i
|
||||
version: $Id: tab.insts.i,v 1.19 2005-08-04 15:45:55 ricroc Exp $
|
||||
version: $Id: tab.insts.i,v 1.20 2005-08-05 14:55:03 vsc Exp $
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
@@ -358,7 +358,7 @@
|
||||
tab_ent_ptr tab_ent;
|
||||
sg_fr_ptr sg_fr;
|
||||
|
||||
check_trail();
|
||||
check_trail(TR);
|
||||
tab_ent = PREG->u.ld.te;
|
||||
sg_fr = subgoal_search(PREG, &YENV);
|
||||
LOCK(SgFr_lock(sg_fr));
|
||||
@@ -468,7 +468,7 @@
|
||||
tab_ent_ptr tab_ent;
|
||||
sg_fr_ptr sg_fr;
|
||||
|
||||
check_trail();
|
||||
check_trail(TR);
|
||||
tab_ent = PREG->u.ld.te;
|
||||
sg_fr = subgoal_search(PREG, &YENV);
|
||||
LOCK(SgFr_lock(sg_fr));
|
||||
@@ -578,7 +578,7 @@
|
||||
tab_ent_ptr tab_ent;
|
||||
sg_fr_ptr sg_fr;
|
||||
|
||||
check_trail();
|
||||
check_trail(TR);
|
||||
tab_ent = PREG->u.ld.te;
|
||||
sg_fr = subgoal_search(PREG, &YENV);
|
||||
LOCK(SgFr_lock(sg_fr));
|
||||
|
@@ -5,7 +5,7 @@
|
||||
|
||||
Copyright: R. Rocha and NCC - University of Porto, Portugal
|
||||
File: tab.macros.h
|
||||
version: $Id: tab.macros.h,v 1.18 2005-08-04 15:45:55 ricroc Exp $
|
||||
version: $Id: tab.macros.h,v 1.19 2005-08-05 14:55:03 vsc Exp $
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
@@ -417,7 +417,7 @@ void rebind_variables(tr_fr_ptr rebind_tr, tr_fr_ptr end_tr) {
|
||||
TABLING_ERROR_MESSAGE("rebind_tr < end_tr (function rebind_variables)");
|
||||
#endif /* TABLING_ERRORS */
|
||||
/* rebind loop */
|
||||
NEW_MAHASH((ma_h_inner_struct *)H);
|
||||
Yap_NEW_MAHASH((ma_h_inner_struct *)H);
|
||||
while (rebind_tr != end_tr) {
|
||||
CELL ref = (CELL) TrailTerm(--rebind_tr);
|
||||
/* check for global or local variables */
|
||||
@@ -439,7 +439,7 @@ void rebind_variables(tr_fr_ptr rebind_tr, tr_fr_ptr end_tr) {
|
||||
#ifdef MULTI_ASSIGNMENT_VARIABLES
|
||||
} else {
|
||||
CELL *cell_ptr = RepAppl(ref);
|
||||
if (!lookup_ma_var(cell_ptr)) {
|
||||
if (!Yap_lookup_ma_var(cell_ptr)) {
|
||||
/* first time we found the variable, let's put the new value */
|
||||
*cell_ptr = TrailVal(rebind_tr);
|
||||
}
|
||||
|
Reference in New Issue
Block a user