new indexing algorithm
git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@822 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
107
H/clause.h
107
H/clause.h
@@ -32,54 +32,13 @@ typedef union CONSULT_OBJ {
|
||||
#define ASSEMBLING_CLAUSE 0
|
||||
#define ASSEMBLING_INDEX 1
|
||||
|
||||
/* This information is put at the start of every clause */
|
||||
|
||||
#define VarCl 0x0000 /* The clause's first argument is a var */
|
||||
#define ListCl 0x0001 /* The clause's first argument is a list */
|
||||
#define ApplCl 0x0002 /* The clause's first argument is an Appl */
|
||||
#define AtCl 0x0003 /* The clause's first argument is a const */
|
||||
|
||||
/* If the firs argument is a list, then we care about what
|
||||
we have in its head */
|
||||
#define FHeadVar 0x0000 /* The head of the first argument is a var */
|
||||
#define FHeadList 0x0004 /* The head of the first argument is a list */
|
||||
#define FHeadAppl 0x0008 /* The head of the first argument ia an Appl */
|
||||
#define FHeadCons 0x000c /* The head of the first argument is a cons */
|
||||
|
||||
/* If the first argument is a variable, then it may be tipified later */
|
||||
#define FIsVar 0x0010 /* ... :- var(X)... */
|
||||
#define FIsAtom 0x0020 /* ... :- atom(X) .... */
|
||||
#define FIsNum 0x0040 /* ... :- integer(X) ...
|
||||
... :- number(X) ... */
|
||||
#define FIsPrimi 0x0080 /* ... :- atomic(X) ...
|
||||
... :- primitive(X) ... */
|
||||
|
||||
#define FirstArgOfClType(X) ((X) & 0x03 )
|
||||
#define HeadOfClType(X) ( ((X) >> 2) & 0x03 )
|
||||
|
||||
#define KindOfArg(X) FirstArgOfClType(ClauseCodeToClause(X)->ClFlags)
|
||||
#define KindOfListArg(X) HeadOfClType(ClauseCodeToClause(X)->ClFlags)
|
||||
#define KindOfBipArg(X) ClauseCodeToClause(X)->ClFlags
|
||||
|
||||
#define NextClause(X) (((yamop *)X)->u.ld.d)
|
||||
|
||||
#define PredFirstClause 0
|
||||
#define PredMiddleClause 1
|
||||
#define PredLastClause 2
|
||||
|
||||
typedef struct clause_struct {
|
||||
/* This info is used by the indexing algorithm and by the dynamic clauses.
|
||||
It is either the value of the first arg for static clauses or a pointer
|
||||
to the previous clause */
|
||||
union {
|
||||
CELL ClValue; /* indexable clause */
|
||||
yamop *ClPrevious; /* immediate update clause */
|
||||
CODEADDR ClInfo; /* indexing code for log. sem. */
|
||||
yamop *ClVarChain; /* log. sem. indexing code */
|
||||
struct clause_struct *NextCl; /* dead clause */
|
||||
} u;
|
||||
/* the actual owner of the clause */
|
||||
Atom Owner;
|
||||
typedef struct logic_upd_clause {
|
||||
/* A set of flags describing info on the clause */
|
||||
CELL ClFlags;
|
||||
#if defined(YAPOR) || defined(THREADS)
|
||||
@@ -87,6 +46,10 @@ typedef struct clause_struct {
|
||||
lockvar ClLock;
|
||||
UInt ref_count;
|
||||
#endif
|
||||
union {
|
||||
yamop *ClVarChain; /* indexing code for log. sem. */
|
||||
} u;
|
||||
/* extra clause information for logical update indices and facts */
|
||||
union {
|
||||
/* extra clause information for logical update semantics, rules with envs */
|
||||
yamop *ClExt;
|
||||
@@ -95,14 +58,58 @@ typedef struct clause_struct {
|
||||
} u2;
|
||||
/* The instructions, at least one of the form sl */
|
||||
yamop ClCode[MIN_ARRAY];
|
||||
} Clause;
|
||||
Atom Owner;
|
||||
} LogUpdClause;
|
||||
|
||||
#define ClauseCodeToClause(p) ((Clause *)((CODEADDR)(p)-(CELL)(((Clause *)NULL)->ClCode)))
|
||||
#define ClauseFlagsToClause(p) ((Clause *)((CODEADDR)(p)-(CELL)(&(((Clause *)NULL)->ClFlags))))
|
||||
typedef struct dynamic_clause {
|
||||
/* A set of flags describing info on the clause */
|
||||
CELL ClFlags;
|
||||
#if defined(YAPOR) || defined(THREADS)
|
||||
/* A lock for manipulating the clause */
|
||||
lockvar ClLock;
|
||||
UInt ref_count;
|
||||
#endif
|
||||
Atom Owner;
|
||||
yamop *ClPrevious; /* immediate update clause */
|
||||
/* The instructions, at least one of the form sl */
|
||||
yamop ClCode[MIN_ARRAY];
|
||||
} DynamicClause;
|
||||
|
||||
#define DynamicFlags(X) (ClauseCodeToClause(X)->ClFlags)
|
||||
typedef struct static_clause {
|
||||
/* A set of flags describing info on the clause */
|
||||
CELL ClFlags;
|
||||
Atom Owner;
|
||||
/* The instructions, at least one of the form sl */
|
||||
yamop ClCode[MIN_ARRAY];
|
||||
} StaticClause;
|
||||
|
||||
#define DynamicLock(X) (ClauseCodeToClause(X)->ClLock)
|
||||
typedef struct dead_clause {
|
||||
CELL ClFlags;
|
||||
struct dead_clause *NextCl; /* dead clause */
|
||||
#if defined(YAPOR) || defined(THREADS)
|
||||
/* A lock for manipulating the clause */
|
||||
lockvar ClLock;
|
||||
UInt ref_count;
|
||||
#endif
|
||||
} DeadClause;
|
||||
|
||||
typedef union clause_obj {
|
||||
struct logic_upd_clause luc;
|
||||
struct dynamic_clause ic;
|
||||
struct static_clause sc;
|
||||
} ClauseUnion;
|
||||
|
||||
#define ClauseCodeToDynamicClause(p) ((DynamicClause *)((CODEADDR)(p)-(CELL)(((DynamicClause *)NULL)->ClCode)))
|
||||
#define ClauseCodeToStaticClause(p) ((StaticClause *)((CODEADDR)(p)-(CELL)(((StaticClause *)NULL)->ClCode)))
|
||||
#define ClauseCodeToLogUpdClause(p) ((LogUpdClause *)((CODEADDR)(p)-(CELL)(((LogUpdClause *)NULL)->ClCode)))
|
||||
|
||||
#define ClauseFlagsToDynamicClause(p) ((DynamicClause *)(p))
|
||||
#define ClauseFlagsToLogUpdClause(p) ((LogUpdClause *)(p))
|
||||
#define ClauseFlagsToStaticClause(p) ((StaticClause *)(p))
|
||||
|
||||
#define DynamicFlags(X) (ClauseCodeToDynamicClause(X)->ClFlags)
|
||||
|
||||
#define DynamicLock(X) (ClauseCodeToDynamicClause(X)->ClLock)
|
||||
|
||||
#if defined(YAPOR) || defined(THREADS)
|
||||
#define INIT_CLREF_COUNT(X) (X)->ref_count = 0
|
||||
@@ -120,14 +127,16 @@ typedef struct clause_struct {
|
||||
wamreg STD_PROTO(Yap_emit_x,(CELL));
|
||||
wamreg STD_PROTO(Yap_compile_cmp_flags,(PredEntry *));
|
||||
void STD_PROTO(Yap_InitComma,(void));
|
||||
wamreg STD_PROTO(Yap_regnotoreg,(UInt));
|
||||
|
||||
/* cdmgr.c */
|
||||
void STD_PROTO(Yap_RemoveLogUpdIndex,(Clause *));
|
||||
void STD_PROTO(Yap_RemoveLogUpdIndex,(LogUpdClause *));
|
||||
void STD_PROTO(Yap_IPred,(PredEntry *));
|
||||
void STD_PROTO(Yap_addclause,(Term,yamop *,int,int));
|
||||
|
||||
/* dbase.c */
|
||||
void STD_PROTO(Yap_ErCl,(Clause *));
|
||||
void STD_PROTO(Yap_ErCl,(DynamicClause *));
|
||||
void STD_PROTO(Yap_ErLogUpdCl,(LogUpdClause *));
|
||||
|
||||
/* exec.c */
|
||||
Term STD_PROTO(Yap_cp_as_integer,(choiceptr));
|
||||
|
Reference in New Issue
Block a user