2001-04-09 20:54:03 +01:00
|
|
|
/*************************************************************************
|
|
|
|
* *
|
|
|
|
* YAP Prolog %W% %G%
|
|
|
|
* *
|
|
|
|
* Yap Prolog was developed at NCCUP - Universidade do Porto *
|
|
|
|
* *
|
|
|
|
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
|
|
|
|
* *
|
|
|
|
**************************************************************************
|
|
|
|
* *
|
|
|
|
* File: index.h *
|
|
|
|
* Last rev: *
|
|
|
|
* mods: *
|
|
|
|
* comments: indexation info *
|
|
|
|
* *
|
|
|
|
*************************************************************************/
|
|
|
|
|
2003-04-30 18:46:05 +01:00
|
|
|
/* allowed types for clauses */
|
|
|
|
typedef enum clause_type_enum {
|
|
|
|
pair_clause = 0x01,
|
|
|
|
struct_clause = 0x02,
|
|
|
|
atom_clause = 0x04,
|
|
|
|
int_clause = 0x08,
|
|
|
|
flt_clause = 0x10,
|
|
|
|
lgint_clause = 0x20,
|
|
|
|
dbref_clause = 0x40
|
|
|
|
} clause_type;
|
2001-04-09 20:54:03 +01:00
|
|
|
|
|
|
|
/* Four types of Clauses */
|
2003-04-30 18:46:05 +01:00
|
|
|
#define MaxOptions 4
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2003-04-30 18:46:05 +01:00
|
|
|
/* Minimum number of clauses needed to build an hash table */
|
|
|
|
/* must be a power of two */
|
|
|
|
#define MIN_HASH_ENTRIES 4
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2003-04-30 18:46:05 +01:00
|
|
|
#define HASH_SHIFT 6
|
2001-04-09 20:54:03 +01:00
|
|
|
|
|
|
|
/* Intermediate Data structures,
|
|
|
|
used to build the indexing code */
|
|
|
|
|
|
|
|
/* Used to store all important information about a clause */
|
|
|
|
typedef struct StructClauseDef {
|
2003-04-30 18:46:05 +01:00
|
|
|
Term Tag; /* if nonvar or nonlist, first argument */
|
|
|
|
yamop *Code; /* start of code for clause */
|
|
|
|
yamop *CurrentCode; /* start of code for clause */
|
2003-08-27 14:37:10 +01:00
|
|
|
union {
|
|
|
|
yamop *WorkPC; /* start of code for clause */
|
|
|
|
Term t_ptr;
|
2004-10-22 17:53:20 +01:00
|
|
|
CELL *c_sreg;
|
2014-02-18 09:44:01 +00:00
|
|
|
} ucd;
|
2003-04-30 18:46:05 +01:00
|
|
|
} ClauseDef;
|
2001-04-09 20:54:03 +01:00
|
|
|
|
|
|
|
|
|
|
|
/* Relevant information for groups */
|
|
|
|
typedef struct {
|
2003-04-30 18:46:05 +01:00
|
|
|
ClauseDef *FirstClause;
|
|
|
|
ClauseDef *LastClause;
|
|
|
|
UInt VarClauses;
|
|
|
|
UInt AtomClauses;
|
|
|
|
UInt PairClauses;
|
|
|
|
UInt StructClauses;
|
|
|
|
UInt TestClauses;
|
|
|
|
} GroupDef;
|
2001-04-09 20:54:03 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
2003-04-30 18:46:05 +01:00
|
|
|
/* switch_on_cons */
|
|
|
|
typedef struct {
|
|
|
|
Term Tag;
|
2007-05-02 12:01:41 +01:00
|
|
|
union {
|
|
|
|
UInt Label;
|
|
|
|
yamop *labp;
|
2014-02-18 09:44:01 +00:00
|
|
|
} u_a;
|
2003-04-30 18:46:05 +01:00
|
|
|
} AtomSwiEntry;
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2003-04-30 18:46:05 +01:00
|
|
|
/* switch_on_func */
|
|
|
|
typedef struct {
|
|
|
|
Functor Tag;
|
2007-05-02 12:01:41 +01:00
|
|
|
union {
|
|
|
|
UInt Label;
|
|
|
|
yamop *labp;
|
2014-02-18 09:44:01 +00:00
|
|
|
} u_f;
|
2003-04-30 18:46:05 +01:00
|
|
|
} FuncSwiEntry;
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2003-04-30 18:46:05 +01:00
|
|
|
/* switch_on_type */
|
|
|
|
typedef struct {
|
|
|
|
UInt PairEntry;
|
|
|
|
UInt ConstEntry;
|
|
|
|
UInt FuncEntry;
|
|
|
|
UInt VarEntry;
|
|
|
|
} TypeSwitch;
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2003-04-30 18:46:05 +01:00
|
|
|
#define MAX_REG_COPIES 32
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2003-08-27 14:37:10 +01:00
|
|
|
typedef struct {
|
|
|
|
Int pos;
|
|
|
|
Term val;
|
2003-11-12 12:33:31 +00:00
|
|
|
Term extra;
|
2003-08-27 14:37:10 +01:00
|
|
|
} istack_entry;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
pc_entry,
|
|
|
|
block_entry
|
|
|
|
} add2index_entries;
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
add2index_entries flag;
|
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
yamop**pi_pc;
|
|
|
|
yamop *code, *current_code, *work_pc;
|
|
|
|
Term tag;
|
|
|
|
} pce;
|
|
|
|
struct {
|
|
|
|
ClauseUnion *block;
|
|
|
|
yamop **entry_code;
|
|
|
|
} cle;
|
2014-02-18 09:44:01 +00:00
|
|
|
} uip;
|
2003-08-27 14:37:10 +01:00
|
|
|
} path_stack_entry;
|
|
|
|
|
|
|
|
#define MAX_ISTACK_DEPTH 32
|
|
|
|
|
2003-09-15 02:25:29 +01:00
|
|
|
typedef enum {
|
|
|
|
REFRESH,
|
|
|
|
RECORDA,
|
|
|
|
RECORDZ
|
|
|
|
} expand_values;
|