1 /*************************************************************************
2 *									 *
3 *	 YAP Prolog 	%W% %G%
4 *									 *
5 *	Yap Prolog was developed at NCCUP - Universidade do Porto	 *
6 *									 *
7 * Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997	 *
8 *									 *
9 **************************************************************************
10 *									 *
11 * File:		index.h							 *
12 * Last rev:								 *
13 * mods:									 *
14 * comments:	indexation info						 *
15 *									 *
16 *************************************************************************/
17 
18 /* allowed types for clauses */
19 typedef enum clause_type_enum {
20   pair_clause       = 0x01,
21   struct_clause     = 0x02,
22   atom_clause       = 0x04,
23   int_clause        = 0x08,
24   flt_clause        = 0x10,
25   lgint_clause      = 0x20,
26   dbref_clause      = 0x40
27 } clause_type;
28 
29 /* Four types of Clauses */
30 #define MaxOptions	4
31 
32 /* Minimum number of clauses needed to build an hash table */
33 /* must be a power of two */
34 #define	MIN_HASH_ENTRIES	4
35 
36 #define HASH_SHIFT 6
37 
38 /* Intermediate Data structures,
39    used to build the indexing code */
40 
41 /* Used to store all important information about a clause */
42 typedef struct StructClauseDef {
43   Term Tag;		/* if nonvar or nonlist, first argument */
44   yamop *Code;		/* start of code for clause */
45   yamop *CurrentCode;		/* start of code for clause */
46   union {
47     yamop *WorkPC;		/* start of code for clause */
48     Term   t_ptr;
49     CELL  *c_sreg;
50   } u;
51 } ClauseDef;
52 
53 
54 /* Relevant information for groups */
55 typedef struct {
56   ClauseDef *FirstClause;
57   ClauseDef *LastClause;
58   UInt  VarClauses;
59   UInt  AtomClauses;
60   UInt  PairClauses;
61   UInt  StructClauses;
62   UInt  TestClauses;
63 } GroupDef;
64 
65 
66 
67 /* switch_on_cons */
68 typedef struct {
69   Term  Tag;
70   union {
71     UInt  Label;
72     yamop *labp;
73   } u;
74 } AtomSwiEntry;
75 
76 /* switch_on_func */
77 typedef struct {
78   Functor  Tag;
79   union {
80     UInt  Label;
81     yamop *labp;
82   } u;
83 } FuncSwiEntry;
84 
85 /* switch_on_type */
86 typedef struct {
87   UInt  PairEntry;
88   UInt  ConstEntry;
89   UInt  FuncEntry;
90   UInt  VarEntry;
91 } TypeSwitch;
92 
93 #define MAX_REG_COPIES 32
94 
95 typedef struct {
96   Int pos;
97   Term val;
98   Term  extra;
99 } istack_entry;
100 
101 typedef enum {
102   pc_entry,
103   block_entry
104 } add2index_entries;
105 
106 
107 typedef struct {
108   add2index_entries flag;
109   union {
110     struct {
111       yamop**pi_pc;
112       yamop *code, *current_code, *work_pc;
113       Term tag;
114     } pce;
115     struct {
116       ClauseUnion *block;
117       yamop **entry_code;
118     } cle;
119   } u;
120 } path_stack_entry;
121 
122 #define MAX_ISTACK_DEPTH 32
123 
124 typedef enum {
125   REFRESH,
126   RECORDA,
127   RECORDZ
128 } expand_values;
129