UDI patch: make it work with YAP.
This commit is contained in:
parent
ad2d073184
commit
94ebb90719
@ -778,7 +778,7 @@ Yap_BuildMegaClause(PredEntry *ap)
|
|||||||
#ifdef TABLING
|
#ifdef TABLING
|
||||||
|TabledPredFlag
|
|TabledPredFlag
|
||||||
#endif /* TABLING */
|
#endif /* TABLING */
|
||||||
) ||
|
|UDIPredFlag) ||
|
||||||
ap->cs.p_code.FirstClause == NULL ||
|
ap->cs.p_code.FirstClause == NULL ||
|
||||||
ap->cs.p_code.NOfClauses < 16) {
|
ap->cs.p_code.NOfClauses < 16) {
|
||||||
return;
|
return;
|
||||||
|
@ -54,6 +54,7 @@ Yap_ClauseListExtend(clause_list_t cl, void * clause, void *pred)
|
|||||||
{
|
{
|
||||||
PredEntry *ap = (PredEntry *)pred;
|
PredEntry *ap = (PredEntry *)pred;
|
||||||
|
|
||||||
|
/* fprintf(stderr,"cl=%p\n",clause); */
|
||||||
if (cl->end != H)
|
if (cl->end != H)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (cl->n == 0) {
|
if (cl->n == 0) {
|
||||||
@ -80,7 +81,7 @@ Yap_ClauseListExtend(clause_list_t cl, void * clause, void *pred)
|
|||||||
code_p = NEXTOP(code_p,Otapl);
|
code_p = NEXTOP(code_p,Otapl);
|
||||||
code_p->opc = Yap_opcode(_trust);
|
code_p->opc = Yap_opcode(_trust);
|
||||||
code_p->u.Otapl.d = clause;
|
code_p->u.Otapl.d = clause;
|
||||||
code_p->u.Otapl.s = 0;
|
code_p->u.Otapl.s = ap->ArityOfPE;
|
||||||
code_p->u.Otapl.p = ap;
|
code_p->u.Otapl.p = ap;
|
||||||
#ifdef TABLING
|
#ifdef TABLING
|
||||||
code_p->u.Otapl.te = ap->TableOfPred;
|
code_p->u.Otapl.te = ap->TableOfPred;
|
||||||
|
@ -4024,6 +4024,7 @@ expand_index(struct intermediates *cint) {
|
|||||||
ipc = NEXTOP(ipc,e);
|
ipc = NEXTOP(ipc,e);
|
||||||
break;
|
break;
|
||||||
case _user_switch:
|
case _user_switch:
|
||||||
|
labp = &(ipc->u.lp.l);
|
||||||
ipc = ipc->u.lp.l;
|
ipc = ipc->u.lp.l;
|
||||||
break;
|
break;
|
||||||
/* instructions type e */
|
/* instructions type e */
|
||||||
|
@ -4032,6 +4032,8 @@ Yap_InitCPreds(void)
|
|||||||
#if defined MYDDAS_TOP_LEVEL && defined MYDDAS_MYSQL // && defined HAVE_LIBREADLINE
|
#if defined MYDDAS_TOP_LEVEL && defined MYDDAS_MYSQL // && defined HAVE_LIBREADLINE
|
||||||
Yap_InitMYDDAS_TopLevelPreds();
|
Yap_InitMYDDAS_TopLevelPreds();
|
||||||
#endif
|
#endif
|
||||||
|
Yap_udi_init();
|
||||||
|
|
||||||
Yap_InitUserCPreds();
|
Yap_InitUserCPreds();
|
||||||
Yap_InitUtilCPreds();
|
Yap_InitUtilCPreds();
|
||||||
Yap_InitSortPreds();
|
Yap_InitSortPreds();
|
||||||
|
16
C/udi.c
16
C/udi.c
@ -3,6 +3,8 @@
|
|||||||
#include "clause.h"
|
#include "clause.h"
|
||||||
#include "udi.h"
|
#include "udi.h"
|
||||||
|
|
||||||
|
#include "rtree_udi.h"
|
||||||
|
|
||||||
/* we can have this stactic because it is written once */
|
/* we can have this stactic because it is written once */
|
||||||
static struct udi_control_block RtreeCmd;
|
static struct udi_control_block RtreeCmd;
|
||||||
|
|
||||||
@ -53,6 +55,7 @@ p_new_udi(void)
|
|||||||
Atom udi_t;
|
Atom udi_t;
|
||||||
void *info;
|
void *info;
|
||||||
|
|
||||||
|
fprintf(stderr,"new pred babe\n");
|
||||||
/* get the predicate from the spec, copied from cdmgr.c */
|
/* get the predicate from the spec, copied from cdmgr.c */
|
||||||
if (IsVarTerm(spec)) {
|
if (IsVarTerm(spec)) {
|
||||||
Yap_Error(INSTANTIATION_ERROR,spec,"new user index/1");
|
Yap_Error(INSTANTIATION_ERROR,spec,"new user index/1");
|
||||||
@ -77,8 +80,10 @@ p_new_udi(void)
|
|||||||
spec = ArgOfTerm(2, spec);
|
spec = ArgOfTerm(2, spec);
|
||||||
fun = FunctorOfTerm(spec);
|
fun = FunctorOfTerm(spec);
|
||||||
}
|
}
|
||||||
p = RepPredProp(Yap_GetPredPropByFunc(fun, tmod));
|
p = RepPredProp(PredPropByFunc(fun, tmod));
|
||||||
}
|
}
|
||||||
|
if (!p)
|
||||||
|
return FALSE;
|
||||||
/* boring, boring, boring! */
|
/* boring, boring, boring! */
|
||||||
if ((p->PredFlags & (DynamicPredFlag|LogUpdatePredFlag|UserCPredFlag|CArgsPredFlag|NumberDBPredFlag|AtomDBPredFlag|TestPredFlag|AsmPredFlag|CPredFlag|BinaryPredFlag)) ||
|
if ((p->PredFlags & (DynamicPredFlag|LogUpdatePredFlag|UserCPredFlag|CArgsPredFlag|NumberDBPredFlag|AtomDBPredFlag|TestPredFlag|AsmPredFlag|CPredFlag|BinaryPredFlag)) ||
|
||||||
(p->ModuleOfPred == PROLOG_MODULE)) {
|
(p->ModuleOfPred == PROLOG_MODULE)) {
|
||||||
@ -147,8 +152,9 @@ Yap_udi_init(void)
|
|||||||
{
|
{
|
||||||
UdiControlBlocks = NULL;
|
UdiControlBlocks = NULL;
|
||||||
/* to be filled in by David */
|
/* to be filled in by David */
|
||||||
RtreeCmd.init = NULL;
|
RtreeCmd.init = RtreeUdiInit;
|
||||||
RtreeCmd.insert = NULL;
|
RtreeCmd.insert = RtreeUdiInsert;
|
||||||
RtreeCmd.search = NULL;
|
RtreeCmd.search = RtreeUdiSearch;
|
||||||
Yap_InitCPred("$init_udi", 2, p_new_udi, 0);
|
RtreeCmd.destroy = RtreeUdiDestroy;
|
||||||
|
Yap_InitCPred("$udi_init", 2, p_new_udi, 0);
|
||||||
}
|
}
|
||||||
|
11
Makefile.in
11
Makefile.in
@ -101,6 +101,7 @@ INTERFACE_HEADERS = \
|
|||||||
$(srcdir)/include/c_interface.h \
|
$(srcdir)/include/c_interface.h \
|
||||||
$(srcdir)/include/clause_list.h \
|
$(srcdir)/include/clause_list.h \
|
||||||
$(srcdir)/include/udi.h \
|
$(srcdir)/include/udi.h \
|
||||||
|
$(srcdir)/include/rtree_udi.h \
|
||||||
$(srcdir)/include/yap_structs.h \
|
$(srcdir)/include/yap_structs.h \
|
||||||
$(srcdir)/include/YapInterface.h \
|
$(srcdir)/include/YapInterface.h \
|
||||||
$(srcdir)/include/SWI-Prolog.h \
|
$(srcdir)/include/SWI-Prolog.h \
|
||||||
@ -175,6 +176,8 @@ C_SOURCES= \
|
|||||||
$(srcdir)/C/threads.c \
|
$(srcdir)/C/threads.c \
|
||||||
$(srcdir)/C/tracer.c $(srcdir)/C/unify.c $(srcdir)/C/userpreds.c \
|
$(srcdir)/C/tracer.c $(srcdir)/C/unify.c $(srcdir)/C/userpreds.c \
|
||||||
$(srcdir)/C/udi.c \
|
$(srcdir)/C/udi.c \
|
||||||
|
$(srcdir)/packages/udi/rtree.c \
|
||||||
|
$(srcdir)/packages/udi/rtree_udi.c \
|
||||||
$(srcdir)/C/utilpreds.c $(srcdir)/C/write.c $(srcdir)/console/yap.c \
|
$(srcdir)/C/utilpreds.c $(srcdir)/C/write.c $(srcdir)/console/yap.c \
|
||||||
$(srcdir)/C/ypsocks.c $(srcdir)/C/ypstdio.c \
|
$(srcdir)/C/ypsocks.c $(srcdir)/C/ypstdio.c \
|
||||||
$(srcdir)/BEAM/eam_am.c $(srcdir)/BEAM/eam_showcode.c \
|
$(srcdir)/BEAM/eam_am.c $(srcdir)/BEAM/eam_showcode.c \
|
||||||
@ -244,7 +247,7 @@ ENGINE_OBJECTS = \
|
|||||||
myddas_wkb2prolog.o modules.o other.o \
|
myddas_wkb2prolog.o modules.o other.o \
|
||||||
parser.o readutil.o save.o scanner.o sort.o stdpreds.o \
|
parser.o readutil.o save.o scanner.o sort.o stdpreds.o \
|
||||||
sysbits.o threads.o tracer.o \
|
sysbits.o threads.o tracer.o \
|
||||||
udi.o \
|
udi.o rtree.o rtree_udi.o\
|
||||||
unify.o userpreds.o utilpreds.o \
|
unify.o userpreds.o utilpreds.o \
|
||||||
write.o \
|
write.o \
|
||||||
yap2swi.o ypsocks.o ypstdio.o @MPI_OBJS@
|
yap2swi.o ypsocks.o ypstdio.o @MPI_OBJS@
|
||||||
@ -453,6 +456,12 @@ tracer.o: $(srcdir)/C/tracer.c
|
|||||||
udi.o: $(srcdir)/C/udi.c
|
udi.o: $(srcdir)/C/udi.c
|
||||||
$(CC) -c $(C_INTERF_FLAGS) $(srcdir)/C/udi.c -o $@
|
$(CC) -c $(C_INTERF_FLAGS) $(srcdir)/C/udi.c -o $@
|
||||||
|
|
||||||
|
rtree.o: $(srcdir)/packages/udi/rtree.c
|
||||||
|
$(CC) -c $(C_INTERF_FLAGS) $(srcdir)/packages/udi/rtree.c -o $@
|
||||||
|
|
||||||
|
rtree_udi.o: $(srcdir)/packages/udi/rtree_udi.c
|
||||||
|
$(CC) -c $(C_INTERF_FLAGS) $(srcdir)/packages/udi/rtree_udi.c -o $@
|
||||||
|
|
||||||
unify.o: $(srcdir)/C/unify.c
|
unify.o: $(srcdir)/C/unify.c
|
||||||
$(CC) -c $(CFLAGS) $(srcdir)/C/unify.c -o $@
|
$(CC) -c $(CFLAGS) $(srcdir)/C/unify.c -o $@
|
||||||
|
|
||||||
|
@ -26,9 +26,20 @@ yap indexing)
|
|||||||
typedef void *
|
typedef void *
|
||||||
(* Yap_UdiSearch)(void * control);
|
(* Yap_UdiSearch)(void * control);
|
||||||
|
|
||||||
|
/* chamada cada vez que um predicado indexado aparece no código
|
||||||
|
Returns:
|
||||||
|
NULL quando não há indexação usavel no predicado (fallback to
|
||||||
|
yap indexing)
|
||||||
|
FALSE
|
||||||
|
TRY_RETRY_TRUST quando há resultados positivos
|
||||||
|
*/
|
||||||
|
typedef int
|
||||||
|
(* Yap_UdiDestroy)(void * control);
|
||||||
|
|
||||||
typedef struct udi_control_block {
|
typedef struct udi_control_block {
|
||||||
Yap_UdiInit init;
|
Yap_UdiInit init;
|
||||||
Yap_UdiInsert insert;
|
Yap_UdiInsert insert;
|
||||||
Yap_UdiSearch search;
|
Yap_UdiSearch search;
|
||||||
|
Yap_UdiDestroy destroy;
|
||||||
} *UdiControlBlock;
|
} *UdiControlBlock;
|
||||||
|
|
||||||
|
@ -80,7 +80,8 @@ lists:append([H|T], L, [H|R]) :-
|
|||||||
'threads.yap',
|
'threads.yap',
|
||||||
'eam.yap',
|
'eam.yap',
|
||||||
'chtypes.yap',
|
'chtypes.yap',
|
||||||
'yapor.yap'].
|
'yapor.yap',
|
||||||
|
'udi.yap'].
|
||||||
|
|
||||||
:- dynamic prolog:'$user_defined_flag'/2.
|
:- dynamic prolog:'$user_defined_flag'/2.
|
||||||
|
|
||||||
|
@ -22,5 +22,5 @@
|
|||||||
******************/
|
******************/
|
||||||
|
|
||||||
udi(Pred) :-
|
udi(Pred) :-
|
||||||
'$new_udi'(rtree, Pred).
|
'$udi_init'(rtree, Pred).
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user