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)
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))
62#define next_trie_instruction(NODE) \
63 PREG = (yamop *) TrNode_child(NODE); \
67#define next_instruction(CONDITION, NODE) \
69 PREG = (yamop *) TrNode_child(NODE); \
71 PREG = (yamop *) CPREG; \
77#define copy_aux_stack() \
78 { arity_t size = 3 + heap_arity + subs_arity + vars_arity; \
80 memcpy(TOP_STACK, aux_stack, size * sizeof(CELL *)); \
81 aux_stack = TOP_STACK; \
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); \
90 store_yaam_reg_cpdepth(cp); \
95 cp->cp_ap = (yamop *) AP; \
100 TABLING_ERROR_CHECKING_STACK; \
104#define restore_trie_node(AP) \
105 HR = HBREG = PROTECT_FROZEN_H(B); \
106 restore_yaam_reg_cpdepth(B); \
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)); \
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); \
120 TABLING_close_alt(B); \
123 HBREG = PROTECT_FROZEN_H(B); \
124 SET_BB(PROTECT_FROZEN_B(B)); \
125 if ((choiceptr) TOP_STACK == B_FZ) { \
130#define pop_trie_node() \
131 if (SCH_top_shared_cp(B)) { \
132 restore_trie_node(NULL); \
134 really_pop_trie_node(); \
137#define pop_trie_node() \
138 really_pop_trie_node()
147#define aux_stack_null_instr() \
148 next_trie_instruction(node)
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; \
161 next_trie_instruction(node)
169#define aux_stack_term_instr() \
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); \
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); \
181#define aux_stack_term_in_pair_instr() \
183 Bind_Global((CELL *) aux_stack[HEAP_ENTRY(1)], AbsPair(HR)); \
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; \
190 Bind_Global(HR, TrNode_entry(node)); \
191 TOP_STACK[HEAP_ENTRY(1)] = (CELL) (HR + 1); \
193 next_trie_instruction(node)
201#define aux_stack_new_pair_instr() \
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; \
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; \
212 TOP_STACK[HEAP_ENTRY(1)] = (CELL) HR; \
213 TOP_STACK[HEAP_ENTRY(2)] = (CELL) (HR + 1); \
215 next_trie_instruction(node)
217#ifdef TRIE_COMPACT_PAIRS
218#define aux_stack_pair_instr() \
220 Bind_Global((CELL *) aux_stack[HEAP_ENTRY(1)], AbsPair(HR)); \
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; \
227 TOP_STACK[HEAP_ENTRY(1)] = (CELL) HR; \
228 Bind_Global(HR + 1, TermNil); \
230 next_trie_instruction(node)
232#define aux_stack_pair_instr() \
233 aux_stack_new_pair_instr()
242#define aux_stack_appl_instr() \
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; \
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; \
255 for (i = 1; i <= func_arity; i++) \
256 TOP_STACK[HEAP_ENTRY(i)] = (CELL) (HR + i); \
258 HR += 1 + func_arity; \
259 next_trie_instruction(node)
261#define aux_stack_appl_in_pair_instr() \
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; \
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; \
272 TOP_STACK[HEAP_ENTRY(func_arity + 1)] = (CELL) (HR + 1); \
273 Bind_Global(HR, AbsAppl(HR + 2)); \
277 for (i = 1; i <= func_arity; i++) \
278 TOP_STACK[HEAP_ENTRY(i)] = (CELL) (HR + i); \
280 HR += 1 + func_arity; \
281 next_trie_instruction(node)
289#define aux_stack_var_instr() \
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); \
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); \
310#define aux_stack_var_in_pair_instr() \
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)]; \
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); \
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); \
330 next_trie_instruction(node)
338#define aux_stack_val_instr() \
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); \
346 RESET_VARIABLE(aux_sub); \
347 Bind_Local((CELL *) aux_var, aux_sub); \
348 aux_stack[VARS_ENTRY(var_index + 1)] = aux_sub; \
350 TOP_STACK = &aux_stack[1]; \
351 TOP_STACK[HEAP_ARITY_ENTRY] = heap_arity - 1; \
352 next_instruction(heap_arity - 1 || subs_arity, node); \
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); \
364 Bind_Local((CELL *) aux_var, aux_sub); \
365 aux_stack[VARS_ENTRY(var_index + 1)] = aux_sub; \
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; \
375 Bind_Local((CELL *) aux_sub, aux_var); \
378 next_instruction(subs_arity - 1, node); \
381#define aux_stack_val_in_pair_instr() \
383 Bind_Global((CELL *) aux_stack[HEAP_ENTRY(1)], AbsPair(HR)); \
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; \
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); \
396 RESET_VARIABLE(aux_sub); \
397 Bind_Local((CELL *) aux_var, aux_sub); \
398 aux_stack[VARS_ENTRY(var_index + 1)] = aux_sub; \
401 TOP_STACK[HEAP_ENTRY(1)] = (CELL) (HR + 1); \
403 next_trie_instruction(node)
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];
418 aux_stack_var_instr();
422 PBOp(trie_trust_var, e)
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];
430 aux_stack_var_instr();
434 PBOp(trie_try_var, e)
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];
441 store_trie_node(TrNode_next(node));
442 aux_stack_var_instr();
446 PBOp(trie_retry_var, e)
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];
453 restore_trie_node(TrNode_next(node));
454 aux_stack_var_instr();
458 PBOp(trie_do_var_in_pair, e)
459#ifdef TRIE_COMPACT_PAIRS
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];
466 aux_stack_var_in_pair_instr();
468 Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil,
"trie_do_var_in_pair: invalid instruction");
473 PBOp(trie_trust_var_in_pair, e)
474#ifdef TRIE_COMPACT_PAIRS
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];
482 aux_stack_var_in_pair_instr();
484 Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil,
"trie_trust_var_in_pair: invalid instruction");
489 PBOp(trie_try_var_in_pair, e)
490#ifdef TRIE_COMPACT_PAIRS
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];
497 store_trie_node(TrNode_next(node));
498 aux_stack_var_in_pair_instr();
500 Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil,
"trie_try_var_in_pair: invalid instruction");
505 PBOp(trie_retry_var_in_pair, e)
506#ifdef TRIE_COMPACT_PAIRS
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];
513 restore_trie_node(TrNode_next(node));
514 aux_stack_var_in_pair_instr();
516 Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil,
"trie_retry_var_in_pair: invalid instruction");
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));
529 aux_stack_val_instr();
533 PBOp(trie_trust_val, e)
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));
542 aux_stack_val_instr();
546 PBOp(trie_try_val, e)
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));
554 store_trie_node(TrNode_next(node));
555 aux_stack_val_instr();
559 PBOp(trie_retry_val, e)
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));
567 restore_trie_node(TrNode_next(node));
568 aux_stack_val_instr();
572 PBOp(trie_do_val_in_pair, e)
573#ifdef TRIE_COMPACT_PAIRS
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));
581 aux_stack_val_in_pair_instr();
583 Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil,
"trie_do_val_in_pair: invalid instruction");
588 PBOp(trie_trust_val_in_pair, e)
589#ifdef TRIE_COMPACT_PAIRS
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));
598 aux_stack_val_in_pair_instr();
600 Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil,
"trie_trust_val_in_pair: invalid instruction");
605 PBOp(trie_try_val_in_pair, e)
606#ifdef TRIE_COMPACT_PAIRS
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));
614 store_trie_node(TrNode_next(node));
615 aux_stack_val_in_pair_instr();
617 Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil,
"trie_try_val_in_pair: invalid instruction");
622 PBOp(trie_retry_val_in_pair, e)
623#ifdef TRIE_COMPACT_PAIRS
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));
631 restore_trie_node(TrNode_next(node));
632 aux_stack_val_in_pair_instr();
634 Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil,
"trie_retry_val_in_pair: invalid instruction");
639 PBOp(trie_do_atom, e)
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);
647 aux_stack_term_instr();
651 PBOp(trie_trust_atom, e)
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);
660 aux_stack_term_instr();
664 PBOp(trie_try_atom, e)
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);
672 store_trie_node(TrNode_next(node));
673 aux_stack_term_instr();
677 PBOp(trie_retry_atom, e)
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);
685 restore_trie_node(TrNode_next(node));
686 aux_stack_term_instr();
690 PBOp(trie_do_atom_in_pair, e)
691#ifdef TRIE_COMPACT_PAIRS
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];
698 aux_stack_term_in_pair_instr();
700 Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil,
"trie_do_atom_in_pair: invalid instruction");
705 PBOp(trie_trust_atom_in_pair, e)
706#ifdef TRIE_COMPACT_PAIRS
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];
714 aux_stack_term_in_pair_instr();
716 Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil,
"trie_trust_atom_in_pair: invalid instruction");
721 PBOp(trie_try_atom_in_pair, e)
722#ifdef TRIE_COMPACT_PAIRS
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];
729 store_trie_node(TrNode_next(node));
730 aux_stack_term_in_pair_instr();
732 Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil,
"trie_try_atom_in_pair: invalid instruction");
737 PBOp(trie_retry_atom_in_pair, e)
738#ifdef TRIE_COMPACT_PAIRS
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];
745 restore_trie_node(TrNode_next(node));
746 aux_stack_term_in_pair_instr();
748 Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil,
"trie_retry_atom_in_pair: invalid instruction");
753 PBOp(trie_do_null, e)
756 aux_stack_null_instr();
760 PBOp(trie_trust_null, e)
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];
768 aux_stack_null_instr();
772 PBOp(trie_try_null, e)
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];
779 store_trie_node(TrNode_next(node));
780 aux_stack_null_instr();
784 PBOp(trie_retry_null, e)
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];
791 restore_trie_node(TrNode_next(node));
792 aux_stack_null_instr();
796 PBOp(trie_do_null_in_pair, e)
797#ifdef TRIE_COMPACT_PAIRS
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];
804 aux_stack_new_pair_instr();
806 Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil,
"trie_do_null_in_pair: invalid instruction");
811 PBOp(trie_trust_null_in_pair, e)
812#ifdef TRIE_COMPACT_PAIRS
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];
820 aux_stack_new_pair_instr();
822 Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil,
"trie_trust_null_in_pair: invalid instruction");
827 PBOp(trie_try_null_in_pair, e)
828#ifdef TRIE_COMPACT_PAIRS
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];
835 store_trie_node(TrNode_next(node));
836 aux_stack_new_pair_instr();
838 Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil,
"trie_try_null_in_pair: invalid instruction");
843 PBOp(trie_retry_null_in_pair, e)
844#ifdef TRIE_COMPACT_PAIRS
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];
851 restore_trie_node(TrNode_next(node));
852 aux_stack_new_pair_instr();
854 Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil,
"trie_retry_null_in_pair: invalid instruction");
859 PBOp(trie_do_pair, e)
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];
866 aux_stack_pair_instr();
870 PBOp(trie_trust_pair, e)
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];
878 aux_stack_pair_instr();
882 PBOp(trie_try_pair, e)
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];
889 store_trie_node(TrNode_next(node));
890 aux_stack_pair_instr();
894 PBOp(trie_retry_pair, e)
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];
901 restore_trie_node(TrNode_next(node));
902 aux_stack_pair_instr();
906 PBOp(trie_do_appl, e)
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];
913 arity_t func_arity = ArityOfFunctor(func);
915 aux_stack_appl_instr();
919 PBOp(trie_trust_appl, e)
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];
926 arity_t func_arity = ArityOfFunctor(func);
929 aux_stack_appl_instr();
933 PBOp(trie_try_appl, e)
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];
940 arity_t func_arity = ArityOfFunctor(func);
942 store_trie_node(TrNode_next(node));
943 aux_stack_appl_instr();
947 PBOp(trie_retry_appl, e)
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];
954 arity_t func_arity = ArityOfFunctor(func);
956 restore_trie_node(TrNode_next(node));
957 aux_stack_appl_instr();
961 PBOp(trie_do_appl_in_pair, e)
962#ifdef TRIE_COMPACT_PAIRS
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];
969 arity_t func_arity = ArityOfFunctor(func);
971 aux_stack_appl_in_pair_instr();
973 Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil,
"trie_do_appl_in_pair: invalid instruction");
978 PBOp(trie_trust_appl_in_pair, e)
979#ifdef TRIE_COMPACT_PAIRS
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];
986 arity_t func_arity = ArityOfFunctor(func);
989 aux_stack_appl_in_pair_instr();
991 Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil,
"trie_trust_appl_in_pair: invalid instruction");
996 PBOp(trie_try_appl_in_pair, e)
997#ifdef TRIE_COMPACT_PAIRS
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];
1004 arity_t func_arity = ArityOfFunctor(func);
1006 store_trie_node(TrNode_next(node));
1007 aux_stack_appl_in_pair_instr();
1009 Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil,
"trie_try_appl_in_pair: invalid instruction");
1014 PBOp(trie_retry_appl_in_pair, e)
1015#ifdef TRIE_COMPACT_PAIRS
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];
1022 arity_t func_arity = ArityOfFunctor(func);
1024 restore_trie_node(TrNode_next(node));
1025 aux_stack_appl_in_pair_instr();
1027 Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil,
"trie_retry_appl_in_pair: invalid instruction");
1032 PBOp(trie_do_extension, e)
1034 register CELL *aux_stack = TOP_STACK;
1035 arity_t heap_arity = aux_stack[HEAP_ARITY_ENTRY];
1037 aux_stack_extension_instr();
1041 PBOp(trie_trust_extension, e)
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];
1049 aux_stack_extension_instr();
1053 PBOp(trie_try_extension, e)
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];
1060 store_trie_node(TrNode_next(node));
1061 aux_stack_extension_instr();
1065 PBOp(trie_retry_extension, e)
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];
1072 restore_trie_node(TrNode_next(node));
1073 aux_stack_extension_instr();
1077 PBOp(trie_do_double, e)
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];
1085 Term ts[SIZEOF_DOUBLE/SIZEOF_INT_P];
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)];
1093 TOP_STACK = aux_stack = &aux_stack[4];
1095 td.ts[0] = aux_stack[HEAP_ENTRY(1)];
1097 TOP_STACK = aux_stack = &aux_stack[2];
1099 TOP_STACK[HEAP_ARITY_ENTRY] = heap_arity;
1100 t = MkFloatTerm(td.dbl);
1101 aux_stack_term_instr();
1105 BOp(trie_trust_double, e)
1106 Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil,
"trie_trust_double: invalid instruction");
1110 BOp(trie_try_double, e)
1111 Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil,
"trie_try_double: invalid instruction");
1115 BOp(trie_retry_double, e)
1116 Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil,
"trie_retry_double: invalid instruction");
1120 PBOp(trie_do_longint, e)
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)]);
1129 TOP_STACK = aux_stack = &aux_stack[2];
1130 TOP_STACK[HEAP_ARITY_ENTRY] = heap_arity;
1131 aux_stack_term_instr();
1135 BOp(trie_trust_longint, e)
1136 Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil,
"trie_trust_longint: invalid instruction");
1140 BOp(trie_try_longint, e)
1141 Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil,
"trie_try_longint: invalid instruction");
1145 BOp(trie_retry_longint, e)
1146 Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil,
"trie_retry_longint: invalid instruction");
1150 PBOp(trie_do_bigint, e)
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)]);
1159 TOP_STACK = aux_stack = &aux_stack[2];
1160 TOP_STACK[HEAP_ARITY_ENTRY] = heap_arity;
1161 aux_stack_term_instr();
1165 BOp(trie_trust_bigint, e)
1166 Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil,
"trie_trust_bigint: invalid instruction");
1170 BOp(trie_try_bigint, e)
1171 Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil,
"trie_try_bigint: invalid instruction");
1175 BOp(trie_retry_bigint, e)
1176 Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil,
"trie_retry_bigint: invalid instruction");
1181 PBOp(trie_do_gterm, e)
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];
1188 TOP_STACK = exec_substitution((
gt_node_ptr)TrNode_entry(node), aux_stack);
1189 next_instruction(subs_arity - 1 , node);
1193 PBOp(trie_trust_gterm, e)
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];
1201 TOP_STACK = exec_substitution((
gt_node_ptr)TrNode_entry(node), aux_stack);
1202 next_instruction(subs_arity - 1 , node);
1206 PBOp(trie_try_gterm, e)
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];
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);
1219 PBOp(trie_retry_gterm, e)
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];
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);