YAP 7.1.0
tab.tries.insts.h
1/************************************************************************
2** **
3** The YapTab/YapOr/OPTYap systems **
4** **
5** YapTab extends the Yap Prolog engine to support sequential tabling **
6** YapOr extends the Yap Prolog engine to support or-parallelism **
7** OPTYap extends the Yap Prolog engine to support or-parallel tabling **
8** **
9** **
10** Yap Prolog was developed at University of Porto, Portugal **
11** **
12************************************************************************/
13
14/************************************************************************
15** Trie instructions: auxiliary stack organization **
16*************************************************************************
17 -------------------
18 | ha = heap_arity |
19 ------------------- --
20 | heap ptr 1 | |
21 ------------------- |
22 | ... | -- heap_arity (0 if in global trie)
23 ------------------- |
24 | heap ptr ha | |
25 ------------------- --
26 | va = vars_arity |
27 ------------------- --
28 | var ptr va | |
29 ------------------- |
30 | ... | -- vars_arity
31 ------------------- |
32 | var ptr 1 | |
33 ------------------- --
34 | sa = subs_arity |
35 ------------------- --
36 | subs ptr sa | |
37 ------------------- |
38 | ... | -- subs_arity
39 ------------------- |
40 | subs ptr 1 | |
41 ------------------- --
42************************************************************************/
43
44
45
46/************************************************************************
47** Trie instructions: macros **
48************************************************************************/
49
50#define TOP_STACK YENV
51
52#define HEAP_ARITY_ENTRY (0)
53#define VARS_ARITY_ENTRY (1 + heap_arity)
54#define SUBS_ARITY_ENTRY (1 + heap_arity + 1 + vars_arity)
55
56/* macros 'HEAP_ENTRY', 'VARS_ENTRY' and 'SUBS_ENTRY' **
57** assume that INDEX starts at 1 (and not at 0 !!!) */
58#define HEAP_ENTRY(INDEX) (HEAP_ARITY_ENTRY + (INDEX))
59#define VARS_ENTRY(INDEX) (VARS_ARITY_ENTRY + 1 + vars_arity - (INDEX))
60#define SUBS_ENTRY(INDEX) (SUBS_ARITY_ENTRY + 1 + subs_arity - (INDEX))
61
62#define next_trie_instruction(NODE) \
63 PREG = (yamop *) TrNode_child(NODE); \
64 PREFETCH_OP(PREG); \
65 GONext()
66
67#define next_instruction(CONDITION, NODE) \
68 if (CONDITION) { \
69 PREG = (yamop *) TrNode_child(NODE); \
70 } else { /* procceed */ \
71 PREG = (yamop *) CPREG; \
72 TOP_STACK = ENV; \
73 } \
74 PREFETCH_OP(PREG); \
75 GONext()
76
77#define copy_aux_stack() \
78 { arity_t size = 3 + heap_arity + subs_arity + vars_arity; \
79 TOP_STACK -= size; \
80 memcpy(TOP_STACK, aux_stack, size * sizeof(CELL *)); \
81 aux_stack = TOP_STACK; \
82 }/* macros 'store_trie_node', 'restore_trie_node' and 'pop_trie_node' **
83** do not include 'set_cut' because trie instructions are cut safe */
84
85#define store_trie_node(AP) \
86 { register choiceptr cp; \
87 TOP_STACK = (CELL *) (NORM_CP(TOP_STACK) - 1); \
88 cp = NORM_CP(TOP_STACK); \
89 HBREG = HR; \
90 store_yaam_reg_cpdepth(cp); \
91 cp->cp_tr = TR; \
92 cp->cp_h = HR; \
93 cp->cp_b = B; \
94 cp->cp_cp = CPREG; \
95 cp->cp_ap = (yamop *) AP; \
96 cp->cp_env= ENV; \
97 B = cp; \
98 YAPOR_SET_LOAD(B); \
99 SET_BB(B); \
100 TABLING_ERROR_CHECKING_STACK; \
101 } \
102 copy_aux_stack()
103
104#define restore_trie_node(AP) \
105 HR = HBREG = PROTECT_FROZEN_H(B); \
106 restore_yaam_reg_cpdepth(B); \
107 CPREG = B->cp_cp; \
108 ENV = B->cp_env; \
109 YAPOR_update_alternative(PREG, (yamop *) AP) \
110 B->cp_ap = (yamop *) AP; \
111 TOP_STACK = (CELL *) PROTECT_FROZEN_B(B); \
112 SET_BB(NORM_CP(TOP_STACK)); \
113 copy_aux_stack()
114
115#define really_pop_trie_node() \
116 TOP_STACK = (CELL *) PROTECT_FROZEN_B((B + 1)); \
117 HR = PROTECT_FROZEN_H(B); \
118 pop_yaam_reg_cpdepth(B); \
119 CPREG = B->cp_cp; \
120 TABLING_close_alt(B); \
121 ENV = B->cp_env; \
122 B = B->cp_b; \
123 HBREG = PROTECT_FROZEN_H(B); \
124 SET_BB(PROTECT_FROZEN_B(B)); \
125 if ((choiceptr) TOP_STACK == B_FZ) { \
126 copy_aux_stack(); \
127 }
128
129#ifdef YAPOR
130#define pop_trie_node() \
131 if (SCH_top_shared_cp(B)) { \
132 restore_trie_node(NULL); \
133 } else { \
134 really_pop_trie_node(); \
135 }
136#else
137#define pop_trie_node() \
138 really_pop_trie_node()
139#endif /* YAPOR */
140
141
142
143/************************************************************************
144** aux_stack_null_instr **
145************************************************************************/
146
147#define aux_stack_null_instr() \
148 next_trie_instruction(node)
149
150
151
152/************************************************************************
153** aux_stack_extension_instr **
154************************************************************************/
155
156#define aux_stack_extension_instr() \
157 TOP_STACK = &aux_stack[-2]; \
158 TOP_STACK[HEAP_ARITY_ENTRY] = heap_arity + 2; \
159 TOP_STACK[HEAP_ENTRY(1)] = TrNode_entry(node); \
160 TOP_STACK[HEAP_ENTRY(2)] = 0; /* extension mark */ \
161 next_trie_instruction(node)
162
163
164
165/************************************************************************
166** aux_stack_term_(in_pair_)instr **
167************************************************************************/
168
169#define aux_stack_term_instr() \
170 if (heap_arity) { \
171 Bind_Global((CELL *) aux_stack[HEAP_ENTRY(1)], t); \
172 TOP_STACK = &aux_stack[1]; \
173 TOP_STACK[HEAP_ARITY_ENTRY] = heap_arity - 1; \
174 next_instruction(heap_arity - 1 || subs_arity, node); \
175 } else { \
176 YapBind((CELL *) aux_stack[SUBS_ENTRY(1)], t); \
177 aux_stack[SUBS_ARITY_ENTRY] = subs_arity - 1; \
178 next_instruction(subs_arity - 1, node); \
179 }
180
181#define aux_stack_term_in_pair_instr() \
182 if (heap_arity) { \
183 Bind_Global((CELL *) aux_stack[HEAP_ENTRY(1)], AbsPair(HR)); \
184 } else { \
185 YapBind((CELL *) aux_stack[SUBS_ENTRY(1)], AbsPair(HR)); \
186 aux_stack[SUBS_ARITY_ENTRY] = subs_arity - 1; \
187 TOP_STACK = &aux_stack[-1]; \
188 TOP_STACK[HEAP_ARITY_ENTRY] = 1; \
189 } \
190 Bind_Global(HR, TrNode_entry(node)); \
191 TOP_STACK[HEAP_ENTRY(1)] = (CELL) (HR + 1); \
192 HR += 2; \
193 next_trie_instruction(node)
194
195
196
197/************************************************************************
198** aux_stack_(new_)pair_instr **
199************************************************************************/
200
201#define aux_stack_new_pair_instr() /* for term 'CompactPairInit' */ \
202 if (heap_arity) { \
203 Bind_Global((CELL *) aux_stack[HEAP_ENTRY(1)], AbsPair(HR)); \
204 TOP_STACK = &aux_stack[-1]; \
205 TOP_STACK[HEAP_ARITY_ENTRY] = heap_arity + 1; \
206 } else { \
207 YapBind((CELL *) aux_stack[SUBS_ENTRY(1)], AbsPair(HR)); \
208 aux_stack[SUBS_ARITY_ENTRY] = subs_arity - 1; \
209 TOP_STACK = &aux_stack[-2]; \
210 TOP_STACK[HEAP_ARITY_ENTRY] = 2; \
211 } \
212 TOP_STACK[HEAP_ENTRY(1)] = (CELL) HR; \
213 TOP_STACK[HEAP_ENTRY(2)] = (CELL) (HR + 1); \
214 HR += 2; \
215 next_trie_instruction(node)
216
217#ifdef TRIE_COMPACT_PAIRS
218#define aux_stack_pair_instr() /* for term 'CompactPairEndList' */ \
219 if (heap_arity) { \
220 Bind_Global((CELL *) aux_stack[HEAP_ENTRY(1)], AbsPair(HR)); \
221 } else { \
222 YapBind((CELL *) aux_stack[SUBS_ENTRY(1)], AbsPair(HR)); \
223 aux_stack[SUBS_ARITY_ENTRY] = subs_arity - 1; \
224 TOP_STACK = &aux_stack[-1]; \
225 TOP_STACK[HEAP_ARITY_ENTRY] = 1; \
226 } \
227 TOP_STACK[HEAP_ENTRY(1)] = (CELL) HR; \
228 Bind_Global(HR + 1, TermNil); \
229 HR += 2; \
230 next_trie_instruction(node)
231#else
232#define aux_stack_pair_instr() \
233 aux_stack_new_pair_instr()
234#endif /* TRIE_COMPACT_PAIRS */
235
236
237
238/************************************************************************
239** aux_stack_appl_(in_pair_)instr **
240************************************************************************/
241
242#define aux_stack_appl_instr() \
243 if (heap_arity) { \
244 Bind_Global((CELL *) aux_stack[HEAP_ENTRY(1)], AbsAppl(HR)); \
245 TOP_STACK = &aux_stack[-func_arity + 1]; \
246 TOP_STACK[HEAP_ARITY_ENTRY] = heap_arity + func_arity - 1; \
247 } else { \
248 YapBind((CELL *) aux_stack[SUBS_ENTRY(1)], AbsAppl(HR)); \
249 aux_stack[SUBS_ARITY_ENTRY] = subs_arity - 1; \
250 TOP_STACK = &aux_stack[-func_arity]; \
251 TOP_STACK[HEAP_ARITY_ENTRY] = func_arity; \
252 } \
253 *HR = (CELL) func; \
254 { arity_t i; \
255 for (i = 1; i <= func_arity; i++) \
256 TOP_STACK[HEAP_ENTRY(i)] = (CELL) (HR + i); \
257 } \
258 HR += 1 + func_arity; \
259 next_trie_instruction(node)
260
261#define aux_stack_appl_in_pair_instr() \
262 if (heap_arity) { \
263 Bind_Global((CELL *) aux_stack[HEAP_ENTRY(1)], AbsPair(HR)); \
264 TOP_STACK = &aux_stack[-func_arity]; \
265 TOP_STACK[HEAP_ARITY_ENTRY] = heap_arity + func_arity; \
266 } else { \
267 YapBind((CELL *) aux_stack[SUBS_ENTRY(1)], AbsPair(HR)); \
268 aux_stack[SUBS_ARITY_ENTRY] = subs_arity - 1; \
269 TOP_STACK = &aux_stack[-func_arity - 1]; \
270 TOP_STACK[HEAP_ARITY_ENTRY] = func_arity + 1; \
271 } \
272 TOP_STACK[HEAP_ENTRY(func_arity + 1)] = (CELL) (HR + 1); \
273 Bind_Global(HR, AbsAppl(HR + 2)); \
274 HR += 2; \
275 *HR = (CELL) func; \
276 { arity_t i; \
277 for (i = 1; i <= func_arity; i++) \
278 TOP_STACK[HEAP_ENTRY(i)] = (CELL) (HR + i); \
279 } \
280 HR += 1 + func_arity; \
281 next_trie_instruction(node)
282
283
284
285/************************************************************************
286** aux_stack_var_(in_pair_)instr **
287************************************************************************/
288
289#define aux_stack_var_instr() \
290 if (heap_arity) { \
291 arity_t i; \
292 CELL var = aux_stack[HEAP_ENTRY(1)]; \
293 RESET_VARIABLE(var); \
294 TOP_STACK[HEAP_ARITY_ENTRY] = heap_arity - 1; \
295 for (i = 2; i <= heap_arity; i++) \
296 TOP_STACK[HEAP_ENTRY(i - 1)] = aux_stack[HEAP_ENTRY(i)]; \
297 aux_stack[VARS_ARITY_ENTRY - 1] = vars_arity + 1; \
298 aux_stack[VARS_ENTRY(vars_arity + 1)] = var; \
299 next_instruction(heap_arity - 1 || subs_arity, node); \
300 } else { \
301 CELL var = aux_stack[SUBS_ENTRY(1)]; \
302 aux_stack[SUBS_ARITY_ENTRY] = subs_arity - 1; \
303 TOP_STACK = &aux_stack[-1]; \
304 TOP_STACK[HEAP_ARITY_ENTRY] = 0; \
305 aux_stack[VARS_ARITY_ENTRY - 1] = vars_arity + 1; \
306 aux_stack[VARS_ENTRY(vars_arity + 1)] = var; \
307 next_instruction(subs_arity - 1, node); \
308 }
309
310#define aux_stack_var_in_pair_instr() \
311 if (heap_arity) { \
312 arity_t i; \
313 Bind_Global((CELL *) aux_stack[HEAP_ENTRY(1)], AbsPair(HR)); \
314 TOP_STACK = &aux_stack[-1]; \
315 TOP_STACK[HEAP_ARITY_ENTRY] = heap_arity; \
316 TOP_STACK[HEAP_ENTRY(1)] = (CELL) (HR + 1); \
317 for (i = 2; i <= heap_arity; i++) \
318 TOP_STACK[HEAP_ENTRY(i)] = aux_stack[HEAP_ENTRY(i)]; \
319 } else { \
320 YapBind((CELL *) aux_stack[SUBS_ENTRY(1)], AbsPair(HR)); \
321 aux_stack[SUBS_ARITY_ENTRY] = subs_arity - 1; \
322 TOP_STACK = &aux_stack[-2]; \
323 TOP_STACK[HEAP_ARITY_ENTRY] = 1; \
324 TOP_STACK[HEAP_ENTRY(1)] = (CELL) (HR + 1); \
325 } \
326 aux_stack[VARS_ARITY_ENTRY - 1] = vars_arity + 1; \
327 aux_stack[VARS_ENTRY(vars_arity + 1)] = (CELL) HR; \
328 RESET_VARIABLE((CELL) HR); \
329 HR += 2; \
330 next_trie_instruction(node)
331
332
333
334/************************************************************************
335** aux_stack_val_(in_pair_)instr **
336************************************************************************/
337
338#define aux_stack_val_instr() \
339 if (heap_arity) { \
340 CELL aux_sub, aux_var; \
341 aux_sub = aux_stack[HEAP_ENTRY(1)]; \
342 aux_var = aux_stack[VARS_ENTRY(var_index + 1)]; \
343 if (aux_sub > aux_var) { \
344 Bind_Global((CELL *) aux_sub, aux_var); \
345 } else { \
346 RESET_VARIABLE(aux_sub); \
347 Bind_Local((CELL *) aux_var, aux_sub); \
348 aux_stack[VARS_ENTRY(var_index + 1)] = aux_sub; \
349 } \
350 TOP_STACK = &aux_stack[1]; \
351 TOP_STACK[HEAP_ARITY_ENTRY] = heap_arity - 1; \
352 next_instruction(heap_arity - 1 || subs_arity, node); \
353 } else { \
354 CELL aux_sub, aux_var; \
355 aux_sub = aux_stack[SUBS_ENTRY(1)]; \
356 aux_stack[SUBS_ARITY_ENTRY] = subs_arity - 1; \
357 aux_var = aux_stack[VARS_ENTRY(var_index + 1)]; \
358 if (aux_sub > aux_var) { \
359 if ((CELL *) aux_sub <= HR) { \
360 Bind_Global((CELL *) aux_sub, aux_var); \
361 } else if ((CELL *) aux_var <= HR) { \
362 Bind_Local((CELL *) aux_sub, aux_var); \
363 } else { \
364 Bind_Local((CELL *) aux_var, aux_sub); \
365 aux_stack[VARS_ENTRY(var_index + 1)] = aux_sub; \
366 } \
367 } else { \
368 if ((CELL *) aux_var <= HR) { \
369 Bind_Global((CELL *) aux_var, aux_sub); \
370 aux_stack[VARS_ENTRY(var_index + 1)] = aux_sub; \
371 } else if ((CELL *) aux_sub <= HR) { \
372 Bind_Local((CELL *) aux_var, aux_sub); \
373 aux_stack[VARS_ENTRY(var_index + 1)] = aux_sub; \
374 } else { \
375 Bind_Local((CELL *) aux_sub, aux_var); \
376 } \
377 } \
378 next_instruction(subs_arity - 1, node); \
379 }
380
381#define aux_stack_val_in_pair_instr() \
382 if (heap_arity) { \
383 Bind_Global((CELL *) aux_stack[HEAP_ENTRY(1)], AbsPair(HR)); \
384 } else { \
385 YapBind((CELL *) aux_stack[SUBS_ENTRY(1)], AbsPair(HR)); \
386 aux_stack[SUBS_ARITY_ENTRY] = subs_arity - 1; \
387 TOP_STACK = &aux_stack[-1]; \
388 TOP_STACK[HEAP_ARITY_ENTRY] = 1; \
389 } \
390 { CELL aux_sub, aux_var; \
391 aux_sub = (CELL) HR; \
392 aux_var = aux_stack[VARS_ENTRY(var_index + 1)]; \
393 if (aux_sub > aux_var) { \
394 Bind_Global((CELL *) aux_sub, aux_var); \
395 } else { \
396 RESET_VARIABLE(aux_sub); \
397 Bind_Local((CELL *) aux_var, aux_sub); \
398 aux_stack[VARS_ENTRY(var_index + 1)] = aux_sub; \
399 } \
400 } \
401 TOP_STACK[HEAP_ENTRY(1)] = (CELL) (HR + 1); \
402 HR += 2; \
403 next_trie_instruction(node)
404
405
406
407/************************************************************************
408** Trie instructions **
409************************************************************************/
410
411 PBOp(trie_do_var, e)
412 register ans_node_ptr node = (ans_node_ptr) PREG;
413 register CELL *aux_stack = TOP_STACK;
414 arity_t heap_arity = aux_stack[HEAP_ARITY_ENTRY];
415 arity_t vars_arity = aux_stack[VARS_ARITY_ENTRY];
416 arity_t subs_arity = aux_stack[SUBS_ARITY_ENTRY];
417
418 aux_stack_var_instr();
419 ENDPBOp();
420
421
422 PBOp(trie_trust_var, e)
423 register ans_node_ptr node = (ans_node_ptr) PREG;
424 register CELL *aux_stack = (CELL *) (B + 1);
425 arity_t heap_arity = aux_stack[HEAP_ARITY_ENTRY];
426 arity_t vars_arity = aux_stack[VARS_ARITY_ENTRY];
427 arity_t subs_arity = aux_stack[SUBS_ARITY_ENTRY];
428
429 pop_trie_node();
430 aux_stack_var_instr();
431 ENDPBOp();
432
433
434 PBOp(trie_try_var, e)
435 register ans_node_ptr node = (ans_node_ptr) PREG;
436 register CELL *aux_stack = TOP_STACK;
437 arity_t heap_arity = aux_stack[HEAP_ARITY_ENTRY];
438 arity_t vars_arity = aux_stack[VARS_ARITY_ENTRY];
439 arity_t subs_arity = aux_stack[SUBS_ARITY_ENTRY];
440
441 store_trie_node(TrNode_next(node));
442 aux_stack_var_instr();
443 ENDPBOp();
444
445
446 PBOp(trie_retry_var, e)
447 register ans_node_ptr node = (ans_node_ptr) PREG;
448 register CELL *aux_stack = (CELL *) (B + 1);
449 arity_t heap_arity = aux_stack[HEAP_ARITY_ENTRY];
450 arity_t vars_arity = aux_stack[VARS_ARITY_ENTRY];
451 arity_t subs_arity = aux_stack[SUBS_ARITY_ENTRY];
452
453 restore_trie_node(TrNode_next(node));
454 aux_stack_var_instr();
455 ENDPBOp();
456
457
458 PBOp(trie_do_var_in_pair, e)
459#ifdef TRIE_COMPACT_PAIRS
460 register ans_node_ptr node = (ans_node_ptr) PREG;
461 register CELL *aux_stack = TOP_STACK;
462 arity_t heap_arity = aux_stack[HEAP_ARITY_ENTRY];
463 arity_t vars_arity = aux_stack[VARS_ARITY_ENTRY];
464 arity_t subs_arity = aux_stack[SUBS_ARITY_ENTRY];
465
466 aux_stack_var_in_pair_instr();
467#else
468 Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "trie_do_var_in_pair: invalid instruction");
469#endif /* TRIE_COMPACT_PAIRS */
470 ENDPBOp();
471
472
473 PBOp(trie_trust_var_in_pair, e)
474#ifdef TRIE_COMPACT_PAIRS
475 register ans_node_ptr node = (ans_node_ptr) PREG;
476 register CELL *aux_stack = (CELL *) (B + 1);
477 arity_t heap_arity = aux_stack[HEAP_ARITY_ENTRY];
478 arity_t vars_arity = aux_stack[VARS_ARITY_ENTRY];
479 arity_t subs_arity = aux_stack[SUBS_ARITY_ENTRY];
480
481 pop_trie_node();
482 aux_stack_var_in_pair_instr();
483#else
484 Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "trie_trust_var_in_pair: invalid instruction");
485#endif /* TRIE_COMPACT_PAIRS */
486 ENDPBOp();
487
488
489 PBOp(trie_try_var_in_pair, e)
490#ifdef TRIE_COMPACT_PAIRS
491 register ans_node_ptr node = (ans_node_ptr) PREG;
492 register CELL *aux_stack = TOP_STACK;
493 arity_t heap_arity = aux_stack[HEAP_ARITY_ENTRY];
494 arity_t vars_arity = aux_stack[VARS_ARITY_ENTRY];
495 arity_t subs_arity = aux_stack[SUBS_ARITY_ENTRY];
496
497 store_trie_node(TrNode_next(node));
498 aux_stack_var_in_pair_instr();
499#else
500 Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "trie_try_var_in_pair: invalid instruction");
501#endif /* TRIE_COMPACT_PAIRS */
502 ENDPBOp();
503
504
505 PBOp(trie_retry_var_in_pair, e)
506#ifdef TRIE_COMPACT_PAIRS
507 register ans_node_ptr node = (ans_node_ptr) PREG;
508 register CELL *aux_stack = (CELL *) (B + 1);
509 arity_t heap_arity = aux_stack[HEAP_ARITY_ENTRY];
510 arity_t vars_arity = aux_stack[VARS_ARITY_ENTRY];
511 arity_t subs_arity = aux_stack[SUBS_ARITY_ENTRY];
512
513 restore_trie_node(TrNode_next(node));
514 aux_stack_var_in_pair_instr();
515#else
516 Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "trie_retry_var_in_pair: invalid instruction");
517#endif /* TRIE_COMPACT_PAIRS */
518 ENDPBOp();
519
520
521 PBOp(trie_do_val, e)
522 register ans_node_ptr node = (ans_node_ptr) PREG;
523 register CELL *aux_stack = TOP_STACK;
524 arity_t heap_arity = aux_stack[HEAP_ARITY_ENTRY];
525 arity_t vars_arity = aux_stack[VARS_ARITY_ENTRY];
526 arity_t subs_arity = aux_stack[SUBS_ARITY_ENTRY];
527 int var_index = VarIndexOfTableTerm(TrNode_entry(node));
528
529 aux_stack_val_instr();
530 ENDPBOp();
531
532
533 PBOp(trie_trust_val, e)
534 register ans_node_ptr node = (ans_node_ptr) PREG;
535 register CELL *aux_stack = (CELL *) (B + 1);
536 arity_t heap_arity = aux_stack[HEAP_ARITY_ENTRY];
537 arity_t vars_arity = aux_stack[VARS_ARITY_ENTRY];
538 arity_t subs_arity = aux_stack[SUBS_ARITY_ENTRY];
539 int var_index = VarIndexOfTableTerm(TrNode_entry(node));
540
541 pop_trie_node();
542 aux_stack_val_instr();
543 ENDPBOp();
544
545
546 PBOp(trie_try_val, e)
547 register ans_node_ptr node = (ans_node_ptr) PREG;
548 register CELL *aux_stack = TOP_STACK;
549 arity_t heap_arity = aux_stack[HEAP_ARITY_ENTRY];
550 arity_t vars_arity = aux_stack[VARS_ARITY_ENTRY];
551 arity_t subs_arity = aux_stack[SUBS_ARITY_ENTRY];
552 int var_index = VarIndexOfTableTerm(TrNode_entry(node));
553
554 store_trie_node(TrNode_next(node));
555 aux_stack_val_instr();
556 ENDPBOp();
557
558
559 PBOp(trie_retry_val, e)
560 register ans_node_ptr node = (ans_node_ptr) PREG;
561 register CELL *aux_stack = (CELL *) (B + 1);
562 arity_t heap_arity = aux_stack[HEAP_ARITY_ENTRY];
563 arity_t vars_arity = aux_stack[VARS_ARITY_ENTRY];
564 arity_t subs_arity = aux_stack[SUBS_ARITY_ENTRY];
565 int var_index = VarIndexOfTableTerm(TrNode_entry(node));
566
567 restore_trie_node(TrNode_next(node));
568 aux_stack_val_instr();
569 ENDPBOp();
570
571
572 PBOp(trie_do_val_in_pair, e)
573#ifdef TRIE_COMPACT_PAIRS
574 register ans_node_ptr node = (ans_node_ptr) PREG;
575 register CELL *aux_stack = TOP_STACK;
576 arity_t heap_arity = aux_stack[HEAP_ARITY_ENTRY];
577 arity_t vars_arity = aux_stack[VARS_ARITY_ENTRY];
578 arity_t subs_arity = aux_stack[SUBS_ARITY_ENTRY];
579 int var_index = VarIndexOfTableTerm(TrNode_entry(node));
580
581 aux_stack_val_in_pair_instr();
582#else
583 Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "trie_do_val_in_pair: invalid instruction");
584#endif /* TRIE_COMPACT_PAIRS */
585 ENDPBOp();
586
587
588 PBOp(trie_trust_val_in_pair, e)
589#ifdef TRIE_COMPACT_PAIRS
590 register ans_node_ptr node = (ans_node_ptr) PREG;
591 register CELL *aux_stack = (CELL *) (B + 1);
592 arity_t heap_arity = aux_stack[HEAP_ARITY_ENTRY];
593 arity_t vars_arity = aux_stack[VARS_ARITY_ENTRY];
594 arity_t subs_arity = aux_stack[SUBS_ARITY_ENTRY];
595 int var_index = VarIndexOfTableTerm(TrNode_entry(node));
596
597 pop_trie_node();
598 aux_stack_val_in_pair_instr();
599#else
600 Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "trie_trust_val_in_pair: invalid instruction");
601#endif /* TRIE_COMPACT_PAIRS */
602 ENDPBOp();
603
604
605 PBOp(trie_try_val_in_pair, e)
606#ifdef TRIE_COMPACT_PAIRS
607 register ans_node_ptr node = (ans_node_ptr) PREG;
608 register CELL *aux_stack = TOP_STACK;
609 arity_t heap_arity = aux_stack[HEAP_ARITY_ENTRY];
610 arity_t vars_arity = aux_stack[VARS_ARITY_ENTRY];
611 arity_t subs_arity = aux_stack[SUBS_ARITY_ENTRY];
612 int var_index = VarIndexOfTableTerm(TrNode_entry(node));
613
614 store_trie_node(TrNode_next(node));
615 aux_stack_val_in_pair_instr();
616#else
617 Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "trie_try_val_in_pair: invalid instruction");
618#endif /* TRIE_COMPACT_PAIRS */
619 ENDPBOp();
620
621
622 PBOp(trie_retry_val_in_pair, e)
623#ifdef TRIE_COMPACT_PAIRS
624 register ans_node_ptr node = (ans_node_ptr) PREG;
625 register CELL *aux_stack = (CELL *) (B + 1);
626 arity_t heap_arity = aux_stack[HEAP_ARITY_ENTRY];
627 arity_t vars_arity = aux_stack[VARS_ARITY_ENTRY];
628 arity_t subs_arity = aux_stack[SUBS_ARITY_ENTRY];
629 int var_index = VarIndexOfTableTerm(TrNode_entry(node));
630
631 restore_trie_node(TrNode_next(node));
632 aux_stack_val_in_pair_instr();
633#else
634 Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "trie_retry_val_in_pair: invalid instruction");
635#endif /* TRIE_COMPACT_PAIRS */
636 ENDPBOp();
637
638
639 PBOp(trie_do_atom, e)
640 register ans_node_ptr node = (ans_node_ptr) PREG;
641 register CELL *aux_stack = TOP_STACK;
642 arity_t heap_arity = aux_stack[HEAP_ARITY_ENTRY];
643 arity_t vars_arity = aux_stack[VARS_ARITY_ENTRY];
644 arity_t subs_arity = aux_stack[SUBS_ARITY_ENTRY];
645 Term t = TrNode_entry(node);
646
647 aux_stack_term_instr();
648 ENDPBOp();
649
650
651 PBOp(trie_trust_atom, e)
652 register ans_node_ptr node = (ans_node_ptr) PREG;
653 register CELL *aux_stack = (CELL *) (B + 1);
654 arity_t heap_arity = aux_stack[HEAP_ARITY_ENTRY];
655 arity_t vars_arity = aux_stack[VARS_ARITY_ENTRY];
656 arity_t subs_arity = aux_stack[SUBS_ARITY_ENTRY];
657 Term t = TrNode_entry(node);
658
659 pop_trie_node();
660 aux_stack_term_instr();
661 ENDPBOp();
662
663
664 PBOp(trie_try_atom, e)
665 register ans_node_ptr node = (ans_node_ptr) PREG;
666 register CELL *aux_stack = TOP_STACK;
667 arity_t heap_arity = aux_stack[HEAP_ARITY_ENTRY];
668 arity_t vars_arity = aux_stack[VARS_ARITY_ENTRY];
669 arity_t subs_arity = aux_stack[SUBS_ARITY_ENTRY];
670 Term t = TrNode_entry(node);
671
672 store_trie_node(TrNode_next(node));
673 aux_stack_term_instr();
674 ENDPBOp();
675
676
677 PBOp(trie_retry_atom, e)
678 register ans_node_ptr node = (ans_node_ptr) PREG;
679 register CELL *aux_stack = (CELL *) (B + 1);
680 arity_t heap_arity = aux_stack[HEAP_ARITY_ENTRY];
681 arity_t vars_arity = aux_stack[VARS_ARITY_ENTRY];
682 arity_t subs_arity = aux_stack[SUBS_ARITY_ENTRY];
683 Term t = TrNode_entry(node);
684
685 restore_trie_node(TrNode_next(node));
686 aux_stack_term_instr();
687 ENDPBOp();
688
689
690 PBOp(trie_do_atom_in_pair, e)
691#ifdef TRIE_COMPACT_PAIRS
692 register ans_node_ptr node = (ans_node_ptr) PREG;
693 register CELL *aux_stack = TOP_STACK;
694 arity_t heap_arity = aux_stack[HEAP_ARITY_ENTRY];
695 arity_t vars_arity = aux_stack[VARS_ARITY_ENTRY];
696 arity_t subs_arity = aux_stack[SUBS_ARITY_ENTRY];
697
698 aux_stack_term_in_pair_instr();
699#else
700 Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "trie_do_atom_in_pair: invalid instruction");
701#endif /* TRIE_COMPACT_PAIRS */
702 ENDPBOp();
703
704
705 PBOp(trie_trust_atom_in_pair, e)
706#ifdef TRIE_COMPACT_PAIRS
707 register ans_node_ptr node = (ans_node_ptr) PREG;
708 register CELL *aux_stack = (CELL *) (B + 1);
709 arity_t heap_arity = aux_stack[HEAP_ARITY_ENTRY];
710 arity_t vars_arity = aux_stack[VARS_ARITY_ENTRY];
711 arity_t subs_arity = aux_stack[SUBS_ARITY_ENTRY];
712
713 pop_trie_node();
714 aux_stack_term_in_pair_instr();
715#else
716 Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "trie_trust_atom_in_pair: invalid instruction");
717#endif /* TRIE_COMPACT_PAIRS */
718 ENDPBOp();
719
720
721 PBOp(trie_try_atom_in_pair, e)
722#ifdef TRIE_COMPACT_PAIRS
723 register ans_node_ptr node = (ans_node_ptr) PREG;
724 register CELL *aux_stack = TOP_STACK;
725 arity_t heap_arity = aux_stack[HEAP_ARITY_ENTRY];
726 arity_t vars_arity = aux_stack[VARS_ARITY_ENTRY];
727 arity_t subs_arity = aux_stack[SUBS_ARITY_ENTRY];
728
729 store_trie_node(TrNode_next(node));
730 aux_stack_term_in_pair_instr();
731#else
732 Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "trie_try_atom_in_pair: invalid instruction");
733#endif /* TRIE_COMPACT_PAIRS */
734 ENDPBOp();
735
736
737 PBOp(trie_retry_atom_in_pair, e)
738#ifdef TRIE_COMPACT_PAIRS
739 register ans_node_ptr node = (ans_node_ptr) PREG;
740 register CELL *aux_stack = (CELL *) (B + 1);
741 arity_t heap_arity = aux_stack[HEAP_ARITY_ENTRY];
742 arity_t vars_arity = aux_stack[VARS_ARITY_ENTRY];
743 arity_t subs_arity = aux_stack[SUBS_ARITY_ENTRY];
744
745 restore_trie_node(TrNode_next(node));
746 aux_stack_term_in_pair_instr();
747#else
748 Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "trie_retry_atom_in_pair: invalid instruction");
749#endif /* TRIE_COMPACT_PAIRS */
750 ENDPBOp();
751
752
753 PBOp(trie_do_null, e)
754 register ans_node_ptr node = (ans_node_ptr) PREG;
755
756 aux_stack_null_instr();
757 ENDPBOp();
758
759
760 PBOp(trie_trust_null, e)
761 register ans_node_ptr node = (ans_node_ptr) PREG;
762 register CELL *aux_stack = (CELL *) (B + 1);
763 arity_t heap_arity = aux_stack[HEAP_ARITY_ENTRY];
764 arity_t vars_arity = aux_stack[VARS_ARITY_ENTRY];
765 arity_t subs_arity = aux_stack[SUBS_ARITY_ENTRY];
766
767 pop_trie_node();
768 aux_stack_null_instr();
769 ENDPBOp();
770
771
772 PBOp(trie_try_null, e)
773 register ans_node_ptr node = (ans_node_ptr) PREG;
774 register CELL *aux_stack = TOP_STACK;
775 arity_t heap_arity = aux_stack[HEAP_ARITY_ENTRY];
776 arity_t vars_arity = aux_stack[VARS_ARITY_ENTRY];
777 arity_t subs_arity = aux_stack[SUBS_ARITY_ENTRY];
778
779 store_trie_node(TrNode_next(node));
780 aux_stack_null_instr();
781 ENDPBOp();
782
783
784 PBOp(trie_retry_null, e)
785 register ans_node_ptr node = (ans_node_ptr) PREG;
786 register CELL *aux_stack = (CELL *) (B + 1);
787 arity_t heap_arity = aux_stack[HEAP_ARITY_ENTRY];
788 arity_t vars_arity = aux_stack[VARS_ARITY_ENTRY];
789 arity_t subs_arity = aux_stack[SUBS_ARITY_ENTRY];
790
791 restore_trie_node(TrNode_next(node));
792 aux_stack_null_instr();
793 ENDPBOp();
794
795
796 PBOp(trie_do_null_in_pair, e)
797#ifdef TRIE_COMPACT_PAIRS
798 register ans_node_ptr node = (ans_node_ptr) PREG;
799 register CELL *aux_stack = TOP_STACK;
800 arity_t heap_arity = aux_stack[HEAP_ARITY_ENTRY];
801 arity_t vars_arity = aux_stack[VARS_ARITY_ENTRY];
802 arity_t subs_arity = aux_stack[SUBS_ARITY_ENTRY];
803
804 aux_stack_new_pair_instr();
805#else
806 Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "trie_do_null_in_pair: invalid instruction");
807#endif /* TRIE_COMPACT_PAIRS */
808 ENDPBOp();
809
810
811 PBOp(trie_trust_null_in_pair, e)
812#ifdef TRIE_COMPACT_PAIRS
813 register ans_node_ptr node = (ans_node_ptr) PREG;
814 register CELL *aux_stack = (CELL *) (B + 1);
815 arity_t heap_arity = aux_stack[HEAP_ARITY_ENTRY];
816 arity_t vars_arity = aux_stack[VARS_ARITY_ENTRY];
817 arity_t subs_arity = aux_stack[SUBS_ARITY_ENTRY];
818
819 pop_trie_node();
820 aux_stack_new_pair_instr();
821#else
822 Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "trie_trust_null_in_pair: invalid instruction");
823#endif /* TRIE_COMPACT_PAIRS */
824 ENDPBOp();
825
826
827 PBOp(trie_try_null_in_pair, e)
828#ifdef TRIE_COMPACT_PAIRS
829 register ans_node_ptr node = (ans_node_ptr) PREG;
830 register CELL *aux_stack = TOP_STACK;
831 arity_t heap_arity = aux_stack[HEAP_ARITY_ENTRY];
832 arity_t vars_arity = aux_stack[VARS_ARITY_ENTRY];
833 arity_t subs_arity = aux_stack[SUBS_ARITY_ENTRY];
834
835 store_trie_node(TrNode_next(node));
836 aux_stack_new_pair_instr();
837#else
838 Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "trie_try_null_in_pair: invalid instruction");
839#endif /* TRIE_COMPACT_PAIRS */
840 ENDPBOp();
841
842
843 PBOp(trie_retry_null_in_pair, e)
844#ifdef TRIE_COMPACT_PAIRS
845 register ans_node_ptr node = (ans_node_ptr) PREG;
846 register CELL *aux_stack = (CELL *) (B + 1);
847 arity_t heap_arity = aux_stack[HEAP_ARITY_ENTRY];
848 arity_t vars_arity = aux_stack[VARS_ARITY_ENTRY];
849 arity_t subs_arity = aux_stack[SUBS_ARITY_ENTRY];
850
851 restore_trie_node(TrNode_next(node));
852 aux_stack_new_pair_instr();
853#else
854 Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "trie_retry_null_in_pair: invalid instruction");
855#endif /* TRIE_COMPACT_PAIRS */
856 ENDPBOp();
857
858
859 PBOp(trie_do_pair, e)
860 register ans_node_ptr node = (ans_node_ptr) PREG;
861 register CELL *aux_stack = TOP_STACK;
862 arity_t heap_arity = aux_stack[HEAP_ARITY_ENTRY];
863 arity_t vars_arity = aux_stack[VARS_ARITY_ENTRY];
864 arity_t subs_arity = aux_stack[SUBS_ARITY_ENTRY];
865
866 aux_stack_pair_instr();
867 ENDPBOp();
868
869
870 PBOp(trie_trust_pair, e)
871 register ans_node_ptr node = (ans_node_ptr) PREG;
872 register CELL *aux_stack = (CELL *) (B + 1);
873 arity_t heap_arity = aux_stack[HEAP_ARITY_ENTRY];
874 arity_t vars_arity = aux_stack[VARS_ARITY_ENTRY];
875 arity_t subs_arity = aux_stack[SUBS_ARITY_ENTRY];
876
877 pop_trie_node();
878 aux_stack_pair_instr();
879 ENDPBOp();
880
881
882 PBOp(trie_try_pair, e)
883 register ans_node_ptr node = (ans_node_ptr) PREG;
884 register CELL *aux_stack = TOP_STACK;
885 arity_t heap_arity = aux_stack[HEAP_ARITY_ENTRY];
886 arity_t vars_arity = aux_stack[VARS_ARITY_ENTRY];
887 arity_t subs_arity = aux_stack[SUBS_ARITY_ENTRY];
888
889 store_trie_node(TrNode_next(node));
890 aux_stack_pair_instr();
891 ENDPBOp();
892
893
894 PBOp(trie_retry_pair, e)
895 register ans_node_ptr node = (ans_node_ptr) PREG;
896 register CELL *aux_stack = (CELL *) (B + 1);
897 arity_t heap_arity = aux_stack[HEAP_ARITY_ENTRY];
898 arity_t vars_arity = aux_stack[VARS_ARITY_ENTRY];
899 arity_t subs_arity = aux_stack[SUBS_ARITY_ENTRY];
900
901 restore_trie_node(TrNode_next(node));
902 aux_stack_pair_instr();
903 ENDPBOp();
904
905
906 PBOp(trie_do_appl, e)
907 register ans_node_ptr node = (ans_node_ptr) PREG;
908 register CELL *aux_stack = TOP_STACK;
909 arity_t heap_arity = aux_stack[HEAP_ARITY_ENTRY];
910 arity_t vars_arity = aux_stack[VARS_ARITY_ENTRY];
911 arity_t subs_arity = aux_stack[SUBS_ARITY_ENTRY];
912 Functor func = (Functor) RepAppl(TrNode_entry(node));
913 arity_t func_arity = ArityOfFunctor(func);
914
915 aux_stack_appl_instr();
916 ENDPBOp();
917
918
919 PBOp(trie_trust_appl, e)
920 register ans_node_ptr node = (ans_node_ptr) PREG;
921 register CELL *aux_stack = (CELL *) (B + 1);
922 arity_t heap_arity = aux_stack[HEAP_ARITY_ENTRY];
923 arity_t vars_arity = aux_stack[VARS_ARITY_ENTRY];
924 arity_t subs_arity = aux_stack[SUBS_ARITY_ENTRY];
925 Functor func = (Functor) RepAppl(TrNode_entry(node));
926 arity_t func_arity = ArityOfFunctor(func);
927
928 pop_trie_node();
929 aux_stack_appl_instr();
930 ENDPBOp();
931
932
933 PBOp(trie_try_appl, e)
934 register ans_node_ptr node = (ans_node_ptr) PREG;
935 register CELL *aux_stack = TOP_STACK;
936 arity_t heap_arity = aux_stack[HEAP_ARITY_ENTRY];
937 arity_t vars_arity = aux_stack[VARS_ARITY_ENTRY];
938 arity_t subs_arity = aux_stack[SUBS_ARITY_ENTRY];
939 Functor func = (Functor) RepAppl(TrNode_entry(node));
940 arity_t func_arity = ArityOfFunctor(func);
941
942 store_trie_node(TrNode_next(node));
943 aux_stack_appl_instr();
944 ENDPBOp();
945
946
947 PBOp(trie_retry_appl, e)
948 register ans_node_ptr node = (ans_node_ptr) PREG;
949 register CELL *aux_stack = (CELL *) (B + 1);
950 arity_t heap_arity = aux_stack[HEAP_ARITY_ENTRY];
951 arity_t vars_arity = aux_stack[VARS_ARITY_ENTRY];
952 arity_t subs_arity = aux_stack[SUBS_ARITY_ENTRY];
953 Functor func = (Functor) RepAppl(TrNode_entry(node));
954 arity_t func_arity = ArityOfFunctor(func);
955
956 restore_trie_node(TrNode_next(node));
957 aux_stack_appl_instr();
958 ENDPBOp();
959
960
961 PBOp(trie_do_appl_in_pair, e)
962#ifdef TRIE_COMPACT_PAIRS
963 register ans_node_ptr node = (ans_node_ptr) PREG;
964 register CELL *aux_stack = TOP_STACK;
965 arity_t heap_arity = aux_stack[HEAP_ARITY_ENTRY];
966 arity_t vars_arity = aux_stack[VARS_ARITY_ENTRY];
967 arity_t subs_arity = aux_stack[SUBS_ARITY_ENTRY];
968 Functor func = (Functor) RepAppl(TrNode_entry(node));
969 arity_t func_arity = ArityOfFunctor(func);
970
971 aux_stack_appl_in_pair_instr();
972#else
973 Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "trie_do_appl_in_pair: invalid instruction");
974#endif /* TRIE_COMPACT_PAIRS */
975 ENDPBOp();
976
977
978 PBOp(trie_trust_appl_in_pair, e)
979#ifdef TRIE_COMPACT_PAIRS
980 register ans_node_ptr node = (ans_node_ptr) PREG;
981 register CELL *aux_stack = (CELL *) (B + 1);
982 arity_t heap_arity = aux_stack[HEAP_ARITY_ENTRY];
983 arity_t vars_arity = aux_stack[VARS_ARITY_ENTRY];
984 arity_t subs_arity = aux_stack[SUBS_ARITY_ENTRY];
985 Functor func = (Functor) RepAppl(TrNode_entry(node));
986 arity_t func_arity = ArityOfFunctor(func);
987
988 pop_trie_node();
989 aux_stack_appl_in_pair_instr();
990#else
991 Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "trie_trust_appl_in_pair: invalid instruction");
992#endif /* TRIE_COMPACT_PAIRS */
993 ENDPBOp();
994
995
996 PBOp(trie_try_appl_in_pair, e)
997#ifdef TRIE_COMPACT_PAIRS
998 register ans_node_ptr node = (ans_node_ptr) PREG;
999 register CELL *aux_stack = TOP_STACK;
1000 arity_t heap_arity = aux_stack[HEAP_ARITY_ENTRY];
1001 arity_t vars_arity = aux_stack[VARS_ARITY_ENTRY];
1002 arity_t subs_arity = aux_stack[SUBS_ARITY_ENTRY];
1003 Functor func = (Functor) RepAppl(TrNode_entry(node));
1004 arity_t func_arity = ArityOfFunctor(func);
1005
1006 store_trie_node(TrNode_next(node));
1007 aux_stack_appl_in_pair_instr();
1008#else
1009 Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "trie_try_appl_in_pair: invalid instruction");
1010#endif /* TRIE_COMPACT_PAIRS */
1011 ENDPBOp();
1012
1013
1014 PBOp(trie_retry_appl_in_pair, e)
1015#ifdef TRIE_COMPACT_PAIRS
1016 register ans_node_ptr node = (ans_node_ptr) PREG;
1017 register CELL *aux_stack = (CELL *) (B + 1);
1018 arity_t heap_arity = aux_stack[HEAP_ARITY_ENTRY];
1019 arity_t vars_arity = aux_stack[VARS_ARITY_ENTRY];
1020 arity_t subs_arity = aux_stack[SUBS_ARITY_ENTRY];
1021 Functor func = (Functor) RepAppl(TrNode_entry(node));
1022 arity_t func_arity = ArityOfFunctor(func);
1023
1024 restore_trie_node(TrNode_next(node));
1025 aux_stack_appl_in_pair_instr();
1026#else
1027 Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "trie_retry_appl_in_pair: invalid instruction");
1028#endif /* TRIE_COMPACT_PAIRS */
1029 ENDPBOp();
1030
1031
1032 PBOp(trie_do_extension, e)
1033 register ans_node_ptr node = (ans_node_ptr) PREG;
1034 register CELL *aux_stack = TOP_STACK;
1035 arity_t heap_arity = aux_stack[HEAP_ARITY_ENTRY];
1036
1037 aux_stack_extension_instr();
1038 ENDPBOp();
1039
1040
1041 PBOp(trie_trust_extension, e)
1042 register ans_node_ptr node = (ans_node_ptr) PREG;
1043 register CELL *aux_stack = (CELL *) (B + 1);
1044 arity_t heap_arity = aux_stack[HEAP_ARITY_ENTRY];
1045 arity_t vars_arity = aux_stack[VARS_ARITY_ENTRY];
1046 arity_t subs_arity = aux_stack[SUBS_ARITY_ENTRY];
1047
1048 pop_trie_node();
1049 aux_stack_extension_instr();
1050 ENDPBOp();
1051
1052
1053 PBOp(trie_try_extension, e)
1054 register ans_node_ptr node = (ans_node_ptr) PREG;
1055 register CELL *aux_stack = TOP_STACK;
1056 arity_t heap_arity = aux_stack[HEAP_ARITY_ENTRY];
1057 arity_t vars_arity = aux_stack[VARS_ARITY_ENTRY];
1058 arity_t subs_arity = aux_stack[SUBS_ARITY_ENTRY];
1059
1060 store_trie_node(TrNode_next(node));
1061 aux_stack_extension_instr();
1062 ENDPBOp();
1063
1064
1065 PBOp(trie_retry_extension, e)
1066 register ans_node_ptr node = (ans_node_ptr) PREG;
1067 register CELL *aux_stack = (CELL *) (B + 1);
1068 arity_t heap_arity = aux_stack[HEAP_ARITY_ENTRY];
1069 arity_t vars_arity = aux_stack[VARS_ARITY_ENTRY];
1070 arity_t subs_arity = aux_stack[SUBS_ARITY_ENTRY];
1071
1072 restore_trie_node(TrNode_next(node));
1073 aux_stack_extension_instr();
1074 ENDPBOp();
1075
1076
1077 PBOp(trie_do_double, e)
1078 register ans_node_ptr node = (ans_node_ptr) PREG;
1079 register CELL *aux_stack = TOP_STACK;
1080 arity_t heap_arity = aux_stack[HEAP_ARITY_ENTRY];
1081 arity_t vars_arity = aux_stack[VARS_ARITY_ENTRY];
1082 arity_t subs_arity = aux_stack[SUBS_ARITY_ENTRY];
1083 volatile union {
1084 Float dbl;
1085 Term ts[SIZEOF_DOUBLE/SIZEOF_INT_P];
1086 } td;
1087 Term t;
1088
1089#if SIZEOF_DOUBLE == 2 * SIZEOF_INT_P
1090 td.ts[0] = aux_stack[HEAP_ENTRY(1)];
1091 td.ts[1] = aux_stack[HEAP_ENTRY(3)]; /* jump the first extension mark */
1092 heap_arity -= 4;
1093 TOP_STACK = aux_stack = &aux_stack[4]; /* jump until the second extension mark */
1094#else /* SIZEOF_DOUBLE == SIZEOF_INT_P */
1095 td.ts[0] = aux_stack[HEAP_ENTRY(1)];
1096 heap_arity -= 2;
1097 TOP_STACK = aux_stack = &aux_stack[2]; /* jump until the extension mark */
1098#endif /* SIZEOF_DOUBLE x SIZEOF_INT_P */
1099 TOP_STACK[HEAP_ARITY_ENTRY] = heap_arity;
1100 t = MkFloatTerm(td.dbl);
1101 aux_stack_term_instr();
1102 ENDPBOp();
1103
1104
1105 BOp(trie_trust_double, e)
1106 Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "trie_trust_double: invalid instruction");
1107 ENDBOp();
1108
1109
1110 BOp(trie_try_double, e)
1111 Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "trie_try_double: invalid instruction");
1112 ENDBOp();
1113
1114
1115 BOp(trie_retry_double, e)
1116 Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "trie_retry_double: invalid instruction");
1117 ENDBOp();
1118
1119
1120 PBOp(trie_do_longint, e)
1121 register ans_node_ptr node = (ans_node_ptr) PREG;
1122 register CELL *aux_stack = TOP_STACK;
1123 arity_t heap_arity = aux_stack[HEAP_ARITY_ENTRY];
1124 arity_t vars_arity = aux_stack[VARS_ARITY_ENTRY];
1125 arity_t subs_arity = aux_stack[SUBS_ARITY_ENTRY];
1126 Term t = MkLongIntTerm(aux_stack[HEAP_ENTRY(1)]);
1127
1128 heap_arity -= 2;
1129 TOP_STACK = aux_stack = &aux_stack[2]; /* jump until the extension mark */
1130 TOP_STACK[HEAP_ARITY_ENTRY] = heap_arity;
1131 aux_stack_term_instr();
1132 ENDPBOp();
1133
1134
1135 BOp(trie_trust_longint, e)
1136 Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "trie_trust_longint: invalid instruction");
1137 ENDBOp();
1138
1139
1140 BOp(trie_try_longint, e)
1141 Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "trie_try_longint: invalid instruction");
1142 ENDBOp();
1143
1144
1145 BOp(trie_retry_longint, e)
1146 Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "trie_retry_longint: invalid instruction");
1147 ENDBOp();
1148
1149
1150 PBOp(trie_do_bigint, e)
1151 register ans_node_ptr node = (ans_node_ptr) PREG;
1152 register CELL *aux_stack = TOP_STACK;
1153 arity_t heap_arity = aux_stack[HEAP_ARITY_ENTRY];
1154 arity_t vars_arity = aux_stack[VARS_ARITY_ENTRY];
1155 arity_t subs_arity = aux_stack[SUBS_ARITY_ENTRY];
1156 Term t = AbsAppl((CELL*)aux_stack[HEAP_ENTRY(1)]);
1157
1158 heap_arity -= 2;
1159 TOP_STACK = aux_stack = &aux_stack[2]; /* jump until the extension mark */
1160 TOP_STACK[HEAP_ARITY_ENTRY] = heap_arity;
1161 aux_stack_term_instr();
1162 ENDPBOp();
1163
1164
1165 BOp(trie_trust_bigint, e)
1166 Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "trie_trust_bigint: invalid instruction");
1167 ENDBOp();
1168
1169
1170 BOp(trie_try_bigint, e)
1171 Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "trie_try_bigint: invalid instruction");
1172 ENDBOp();
1173
1174
1175 BOp(trie_retry_bigint, e)
1176 Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "trie_retry_bigint: invalid instruction");
1177 ENDBOp();
1178
1179
1180
1181 PBOp(trie_do_gterm, e)
1182 register ans_node_ptr node = (ans_node_ptr) PREG;
1183 register CELL *aux_stack = TOP_STACK;
1184 arity_t heap_arity = 0;
1185 arity_t vars_arity = aux_stack[VARS_ARITY_ENTRY];
1186 arity_t subs_arity = aux_stack[SUBS_ARITY_ENTRY];
1187
1188 TOP_STACK = exec_substitution((gt_node_ptr)TrNode_entry(node), aux_stack);
1189 next_instruction(subs_arity - 1 , node);
1190 ENDPBOp();
1191
1192
1193 PBOp(trie_trust_gterm, e)
1194 register ans_node_ptr node = (ans_node_ptr) PREG;
1195 register CELL *aux_stack = (CELL *) (B + 1);
1196 arity_t heap_arity = 0;
1197 arity_t vars_arity = aux_stack[VARS_ARITY_ENTRY];
1198 arity_t subs_arity = aux_stack[SUBS_ARITY_ENTRY];
1199
1200 pop_trie_node();
1201 TOP_STACK = exec_substitution((gt_node_ptr)TrNode_entry(node), aux_stack);
1202 next_instruction(subs_arity - 1 , node);
1203 ENDPBOp();
1204
1205
1206 PBOp(trie_try_gterm, e)
1207 register ans_node_ptr node = (ans_node_ptr) PREG;
1208 register CELL *aux_stack = TOP_STACK;
1209 arity_t heap_arity = 0;
1210 arity_t vars_arity = aux_stack[VARS_ARITY_ENTRY];
1211 arity_t subs_arity = aux_stack[SUBS_ARITY_ENTRY];
1212
1213 store_trie_node(TrNode_next(node));
1214 TOP_STACK = exec_substitution((gt_node_ptr)TrNode_entry(node), aux_stack);
1215 next_instruction(subs_arity - 1, node);
1216 ENDPBOp();
1217
1218
1219 PBOp(trie_retry_gterm, e)
1220 register ans_node_ptr node = (ans_node_ptr) PREG;
1221 register CELL *aux_stack = (CELL *) (B + 1);
1222 arity_t heap_arity = 0;
1223 arity_t vars_arity = aux_stack[VARS_ARITY_ENTRY];
1224 arity_t subs_arity = aux_stack[SUBS_ARITY_ENTRY];
1225
1226 restore_trie_node(TrNode_next(node));
1227 TOP_STACK = exec_substitution((gt_node_ptr)TrNode_entry(node), aux_stack);
1228 next_instruction(subs_arity - 1, node);
1229 ENDPBOp();