2010-04-03 05:58:14 +01:00
|
|
|
/************************************************************************
|
|
|
|
** **
|
|
|
|
** The YapTab/YapOr/OPTYap systems **
|
|
|
|
** **
|
|
|
|
** YapTab extends the Yap Prolog engine to support sequential tabling **
|
|
|
|
** YapOr extends the Yap Prolog engine to support or-parallelism **
|
|
|
|
** OPTYap extends the Yap Prolog engine to support or-parallel tabling **
|
|
|
|
** **
|
|
|
|
** **
|
|
|
|
** Yap Prolog was developed at University of Porto, Portugal **
|
|
|
|
** **
|
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
** Trie instructions: auxiliary stack organization **
|
|
|
|
*************************************************************************
|
2010-04-15 01:09:59 +01:00
|
|
|
-------------------
|
|
|
|
| ha = heap_arity |
|
|
|
|
------------------- --
|
|
|
|
| heap ptr 1 | |
|
|
|
|
------------------- |
|
|
|
|
| ... | -- heap_arity (0 if GLOBAL_TRIE)
|
|
|
|
------------------- |
|
|
|
|
| heap ptr ha | |
|
|
|
|
------------------- --
|
|
|
|
| va = vars_arity |
|
|
|
|
------------------- --
|
|
|
|
| var ptr va | |
|
|
|
|
------------------- |
|
|
|
|
| ... | -- vars_arity
|
|
|
|
------------------- |
|
|
|
|
| var ptr 1 | |
|
|
|
|
------------------- --
|
|
|
|
| sa = subs_arity |
|
|
|
|
------------------- --
|
|
|
|
| subs ptr sa | |
|
|
|
|
------------------- |
|
|
|
|
| ... | -- subs_arity
|
|
|
|
------------------- |
|
|
|
|
| subs ptr 1 | |
|
|
|
|
------------------- --
|
2010-04-03 05:58:14 +01:00
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/************************************************************************
|
2010-04-15 01:09:59 +01:00
|
|
|
** Trie instructions: macros **
|
2010-04-03 05:58:14 +01:00
|
|
|
************************************************************************/
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2010-04-15 01:09:59 +01:00
|
|
|
#define TOP_STACK YENV
|
2009-06-17 17:14:16 +01:00
|
|
|
|
2010-04-15 01:09:59 +01:00
|
|
|
#define HEAP_ARITY_ENTRY (0)
|
|
|
|
#define VARS_ARITY_ENTRY (1 + heap_arity)
|
|
|
|
#define SUBS_ARITY_ENTRY (1 + heap_arity + 1 + vars_arity)
|
|
|
|
|
|
|
|
/* macros 'HEAP_ENTRY', 'VARS_ENTRY' and 'SUBS_ENTRY' **
|
|
|
|
** assume that INDEX starts at 1 (and not at 0 !!!) */
|
|
|
|
#define HEAP_ENTRY(INDEX) (HEAP_ARITY_ENTRY + (INDEX))
|
|
|
|
#define VARS_ENTRY(INDEX) (VARS_ARITY_ENTRY + 1 + vars_arity - (INDEX))
|
|
|
|
#define SUBS_ENTRY(INDEX) (SUBS_ARITY_ENTRY + 1 + subs_arity - (INDEX))
|
|
|
|
|
|
|
|
#define next_trie_instruction(NODE) \
|
|
|
|
PREG = (yamop *) TrNode_child(NODE); \
|
|
|
|
PREFETCH_OP(PREG); \
|
2001-04-09 20:54:03 +01:00
|
|
|
GONext()
|
|
|
|
|
2010-04-15 01:09:59 +01:00
|
|
|
#define next_instruction(CONDITION, NODE) \
|
|
|
|
if (CONDITION) { \
|
|
|
|
PREG = (yamop *) TrNode_child(NODE); \
|
|
|
|
} else { /* procceed */ \
|
|
|
|
PREG = (yamop *) CPREG; \
|
|
|
|
TOP_STACK = ENV; \
|
|
|
|
} \
|
|
|
|
PREFETCH_OP(PREG); \
|
2001-04-09 20:54:03 +01:00
|
|
|
GONext()
|
|
|
|
|
2010-04-15 01:09:59 +01:00
|
|
|
#define copy_aux_stack() \
|
|
|
|
{ int size = 3 + heap_arity + subs_arity + vars_arity; \
|
|
|
|
TOP_STACK -= size; \
|
|
|
|
memcpy(TOP_STACK, aux_stack, size * sizeof(CELL *)); \
|
|
|
|
aux_stack = TOP_STACK; \
|
|
|
|
}
|
|
|
|
|
|
|
|
/* macros 'store_trie_node', 'restore_trie_node' and 'pop_trie_node' **
|
|
|
|
** do not include 'set_cut' because trie instructions are cut safe */
|
|
|
|
|
|
|
|
#define store_trie_node(AP) \
|
|
|
|
{ register choiceptr cp; \
|
|
|
|
TOP_STACK = (CELL *) (NORM_CP(TOP_STACK) - 1); \
|
|
|
|
cp = NORM_CP(TOP_STACK); \
|
|
|
|
HBREG = H; \
|
|
|
|
store_yaam_reg_cpdepth(cp); \
|
|
|
|
cp->cp_tr = TR; \
|
|
|
|
cp->cp_h = H; \
|
|
|
|
cp->cp_b = B; \
|
|
|
|
cp->cp_cp = CPREG; \
|
|
|
|
cp->cp_ap = (yamop *) AP; \
|
|
|
|
cp->cp_env= ENV; \
|
|
|
|
B = cp; \
|
|
|
|
YAPOR_SET_LOAD(B); \
|
|
|
|
SET_BB(B); \
|
2010-04-18 04:59:11 +01:00
|
|
|
TABLING_ERROR_CHECKING_STACK; \
|
2010-04-15 01:09:59 +01:00
|
|
|
} \
|
|
|
|
copy_aux_stack()
|
|
|
|
|
|
|
|
#define restore_trie_node(AP) \
|
|
|
|
H = HBREG = PROTECT_FROZEN_H(B); \
|
|
|
|
restore_yaam_reg_cpdepth(B); \
|
|
|
|
CPREG = B->cp_cp; \
|
|
|
|
ENV = B->cp_env; \
|
|
|
|
YAPOR_update_alternative(PREG, (yamop *) AP) \
|
|
|
|
B->cp_ap = (yamop *) AP; \
|
|
|
|
TOP_STACK = (CELL *) PROTECT_FROZEN_B(B); \
|
|
|
|
SET_BB(NORM_CP(TOP_STACK)); \
|
|
|
|
copy_aux_stack()
|
|
|
|
|
|
|
|
#define really_pop_trie_node() \
|
|
|
|
TOP_STACK = (CELL *) PROTECT_FROZEN_B((B + 1)); \
|
|
|
|
H = PROTECT_FROZEN_H(B); \
|
|
|
|
pop_yaam_reg_cpdepth(B); \
|
|
|
|
CPREG = B->cp_cp; \
|
|
|
|
TABLING_close_alt(B); \
|
|
|
|
ENV = B->cp_env; \
|
|
|
|
B = B->cp_b; \
|
|
|
|
HBREG = PROTECT_FROZEN_H(B); \
|
|
|
|
SET_BB(PROTECT_FROZEN_B(B)); \
|
|
|
|
if ((choiceptr) TOP_STACK == B_FZ) { \
|
|
|
|
copy_aux_stack(); \
|
2009-06-17 17:14:16 +01:00
|
|
|
}
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2009-06-24 20:04:16 +01:00
|
|
|
#ifdef YAPOR
|
2010-04-15 01:09:59 +01:00
|
|
|
#define pop_trie_node() \
|
|
|
|
if (SCH_top_shared_cp(B)) { \
|
|
|
|
restore_trie_node(NULL); \
|
|
|
|
} else { \
|
|
|
|
really_pop_trie_node(); \
|
2009-06-24 20:04:16 +01:00
|
|
|
}
|
|
|
|
#else
|
2010-04-15 01:09:59 +01:00
|
|
|
#define pop_trie_node() \
|
|
|
|
really_pop_trie_node()
|
2009-06-24 20:04:16 +01:00
|
|
|
#endif /* YAPOR */
|
|
|
|
|
2001-04-09 20:54:03 +01:00
|
|
|
|
|
|
|
|
2010-04-03 05:58:14 +01:00
|
|
|
/************************************************************************
|
2010-04-15 01:09:59 +01:00
|
|
|
** aux_stack_null_instr **
|
2010-04-03 05:58:14 +01:00
|
|
|
************************************************************************/
|
2005-06-03 09:19:18 +01:00
|
|
|
|
2010-04-15 01:09:59 +01:00
|
|
|
#define aux_stack_null_instr() \
|
2005-06-03 09:19:18 +01:00
|
|
|
next_trie_instruction(node)
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-04-03 05:58:14 +01:00
|
|
|
/************************************************************************
|
2010-04-15 01:09:59 +01:00
|
|
|
** aux_stack_extension_instr **
|
2010-04-03 05:58:14 +01:00
|
|
|
************************************************************************/
|
2005-06-03 09:19:18 +01:00
|
|
|
|
2010-04-15 01:09:59 +01:00
|
|
|
#define aux_stack_extension_instr() \
|
|
|
|
TOP_STACK = &aux_stack[-2]; \
|
|
|
|
TOP_STACK[HEAP_ARITY_ENTRY] = heap_arity + 2; \
|
|
|
|
TOP_STACK[HEAP_ENTRY(1)] = TrNode_entry(node); \
|
|
|
|
TOP_STACK[HEAP_ENTRY(2)] = 0; /* extension mark */ \
|
2009-06-24 20:04:16 +01:00
|
|
|
next_trie_instruction(node)
|
2001-04-09 20:54:03 +01:00
|
|
|
|
|
|
|
|
2005-06-03 09:19:18 +01:00
|
|
|
|
2010-04-03 05:58:14 +01:00
|
|
|
/************************************************************************
|
2010-04-15 01:09:59 +01:00
|
|
|
** aux_stack_term_(in_pair_)instr **
|
2010-04-03 05:58:14 +01:00
|
|
|
************************************************************************/
|
2005-06-03 09:19:18 +01:00
|
|
|
|
2010-04-15 01:09:59 +01:00
|
|
|
#define aux_stack_term_instr() \
|
|
|
|
if (heap_arity) { \
|
|
|
|
Bind_Global((CELL *) aux_stack[HEAP_ENTRY(1)], t); \
|
|
|
|
TOP_STACK = &aux_stack[1]; \
|
|
|
|
TOP_STACK[HEAP_ARITY_ENTRY] = heap_arity - 1; \
|
|
|
|
next_instruction(heap_arity - 1 || subs_arity, node); \
|
|
|
|
} else { \
|
|
|
|
Bind((CELL *) aux_stack[SUBS_ENTRY(1)], t); \
|
|
|
|
aux_stack[SUBS_ARITY_ENTRY] = subs_arity - 1; \
|
|
|
|
next_instruction(subs_arity - 1, node); \
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
2009-06-24 20:04:16 +01:00
|
|
|
|
2010-04-15 01:09:59 +01:00
|
|
|
#define aux_stack_term_in_pair_instr() \
|
|
|
|
if (heap_arity) { \
|
|
|
|
Bind_Global((CELL *) aux_stack[HEAP_ENTRY(1)], AbsPair(H)); \
|
|
|
|
} else { \
|
|
|
|
Bind((CELL *) aux_stack[SUBS_ENTRY(1)], AbsPair(H)); \
|
|
|
|
aux_stack[SUBS_ARITY_ENTRY] = subs_arity - 1; \
|
|
|
|
TOP_STACK = &aux_stack[-1]; \
|
|
|
|
TOP_STACK[HEAP_ARITY_ENTRY] = 1; \
|
|
|
|
} \
|
|
|
|
Bind_Global(H, TrNode_entry(node)); \
|
|
|
|
TOP_STACK[HEAP_ENTRY(1)] = (CELL) (H + 1); \
|
|
|
|
H += 2; \
|
2009-07-05 05:14:08 +01:00
|
|
|
next_trie_instruction(node)
|
2001-04-09 20:54:03 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
2010-04-03 05:58:14 +01:00
|
|
|
/************************************************************************
|
2010-04-15 01:09:59 +01:00
|
|
|
** aux_stack_(new_)pair_instr **
|
2010-04-03 05:58:14 +01:00
|
|
|
************************************************************************/
|
2005-06-03 09:19:18 +01:00
|
|
|
|
2010-04-15 01:09:59 +01:00
|
|
|
#define aux_stack_new_pair_instr() /* for term 'CompactPairInit' */ \
|
|
|
|
if (heap_arity) { \
|
|
|
|
Bind_Global((CELL *) aux_stack[HEAP_ENTRY(1)], AbsPair(H)); \
|
|
|
|
TOP_STACK = &aux_stack[-1]; \
|
|
|
|
TOP_STACK[HEAP_ARITY_ENTRY] = heap_arity + 1; \
|
|
|
|
} else { \
|
|
|
|
Bind((CELL *) aux_stack[SUBS_ENTRY(1)], AbsPair(H)); \
|
|
|
|
aux_stack[SUBS_ARITY_ENTRY] = subs_arity - 1; \
|
|
|
|
TOP_STACK = &aux_stack[-2]; \
|
|
|
|
TOP_STACK[HEAP_ARITY_ENTRY] = 2; \
|
|
|
|
} \
|
|
|
|
TOP_STACK[HEAP_ENTRY(1)] = (CELL) H; \
|
|
|
|
TOP_STACK[HEAP_ENTRY(2)] = (CELL) (H + 1); \
|
|
|
|
H += 2; \
|
2009-06-24 20:04:16 +01:00
|
|
|
next_trie_instruction(node)
|
2005-06-03 09:19:18 +01:00
|
|
|
|
2009-07-05 05:14:08 +01:00
|
|
|
#ifdef TRIE_COMPACT_PAIRS
|
2010-04-15 01:09:59 +01:00
|
|
|
#define aux_stack_pair_instr() /* for term 'CompactPairEndList' */ \
|
|
|
|
if (heap_arity) { \
|
|
|
|
Bind_Global((CELL *) aux_stack[HEAP_ENTRY(1)], AbsPair(H)); \
|
|
|
|
} else { \
|
|
|
|
Bind((CELL *) aux_stack[SUBS_ENTRY(1)], AbsPair(H)); \
|
|
|
|
aux_stack[SUBS_ARITY_ENTRY] = subs_arity - 1; \
|
|
|
|
TOP_STACK = &aux_stack[-1]; \
|
|
|
|
TOP_STACK[HEAP_ARITY_ENTRY] = 1; \
|
|
|
|
} \
|
|
|
|
TOP_STACK[HEAP_ENTRY(1)] = (CELL) H; \
|
|
|
|
Bind_Global(H + 1, TermNil); \
|
|
|
|
H += 2; \
|
2009-06-24 20:04:16 +01:00
|
|
|
next_trie_instruction(node)
|
2009-07-05 05:14:08 +01:00
|
|
|
#else
|
2010-04-15 01:09:59 +01:00
|
|
|
#define aux_stack_pair_instr() \
|
|
|
|
aux_stack_new_pair_instr()
|
2009-07-05 05:14:08 +01:00
|
|
|
#endif /* TRIE_COMPACT_PAIRS */
|
2001-04-09 20:54:03 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
2010-04-03 05:58:14 +01:00
|
|
|
/************************************************************************
|
2010-04-15 01:09:59 +01:00
|
|
|
** aux_stack_appl_(in_pair_)instr **
|
2010-04-03 05:58:14 +01:00
|
|
|
************************************************************************/
|
2005-06-03 09:19:18 +01:00
|
|
|
|
2010-04-15 01:09:59 +01:00
|
|
|
#define aux_stack_appl_instr() \
|
|
|
|
if (heap_arity) { \
|
|
|
|
Bind_Global((CELL *) aux_stack[HEAP_ENTRY(1)], AbsAppl(H)); \
|
|
|
|
TOP_STACK = &aux_stack[-func_arity + 1]; \
|
|
|
|
TOP_STACK[HEAP_ARITY_ENTRY] = heap_arity + func_arity - 1; \
|
|
|
|
} else { \
|
|
|
|
Bind((CELL *) aux_stack[SUBS_ENTRY(1)], AbsAppl(H)); \
|
|
|
|
aux_stack[SUBS_ARITY_ENTRY] = subs_arity - 1; \
|
|
|
|
TOP_STACK = &aux_stack[-func_arity]; \
|
|
|
|
TOP_STACK[HEAP_ARITY_ENTRY] = func_arity; \
|
|
|
|
} \
|
|
|
|
*H = (CELL) func; \
|
|
|
|
{ int i; \
|
|
|
|
for (i = 1; i <= func_arity; i++) \
|
|
|
|
TOP_STACK[HEAP_ENTRY(i)] = (CELL) (H + i); \
|
|
|
|
} \
|
|
|
|
H += 1 + func_arity; \
|
2005-06-03 09:19:18 +01:00
|
|
|
next_trie_instruction(node)
|
2009-06-24 20:04:16 +01:00
|
|
|
|
2010-04-15 01:09:59 +01:00
|
|
|
#define aux_stack_appl_in_pair_instr() \
|
|
|
|
if (heap_arity) { \
|
|
|
|
Bind_Global((CELL *) aux_stack[HEAP_ENTRY(1)], AbsPair(H)); \
|
|
|
|
TOP_STACK = &aux_stack[-func_arity]; \
|
|
|
|
TOP_STACK[HEAP_ARITY_ENTRY] = heap_arity + func_arity; \
|
|
|
|
} else { \
|
|
|
|
Bind((CELL *) aux_stack[SUBS_ENTRY(1)], AbsPair(H)); \
|
|
|
|
aux_stack[SUBS_ARITY_ENTRY] = subs_arity - 1; \
|
|
|
|
TOP_STACK = &aux_stack[-func_arity - 1]; \
|
|
|
|
TOP_STACK[HEAP_ARITY_ENTRY] = func_arity + 1; \
|
|
|
|
} \
|
|
|
|
TOP_STACK[HEAP_ENTRY(func_arity + 1)] = (CELL) (H + 1); \
|
|
|
|
Bind_Global(H, AbsAppl(H + 2)); \
|
|
|
|
H += 2; \
|
|
|
|
*H = (CELL) func; \
|
|
|
|
{ int i; \
|
|
|
|
for (i = 1; i <= func_arity; i++) \
|
|
|
|
TOP_STACK[HEAP_ENTRY(i)] = (CELL) (H + i); \
|
|
|
|
} \
|
|
|
|
H += 1 + func_arity; \
|
2001-04-09 20:54:03 +01:00
|
|
|
next_trie_instruction(node)
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-04-03 05:58:14 +01:00
|
|
|
/************************************************************************
|
2010-04-15 01:09:59 +01:00
|
|
|
** aux_stack_var_(in_pair_)instr **
|
2010-04-03 05:58:14 +01:00
|
|
|
************************************************************************/
|
2005-07-06 20:34:12 +01:00
|
|
|
|
2010-04-15 01:09:59 +01:00
|
|
|
#define aux_stack_var_instr() \
|
|
|
|
if (heap_arity) { \
|
|
|
|
int i; \
|
|
|
|
CELL var = aux_stack[HEAP_ENTRY(1)]; \
|
|
|
|
RESET_VARIABLE(var); \
|
|
|
|
TOP_STACK[HEAP_ARITY_ENTRY] = heap_arity - 1; \
|
|
|
|
for (i = 2; i <= heap_arity; i++) \
|
|
|
|
TOP_STACK[HEAP_ENTRY(i - 1)] = aux_stack[HEAP_ENTRY(i)]; \
|
|
|
|
aux_stack[VARS_ARITY_ENTRY - 1] = vars_arity + 1; \
|
|
|
|
aux_stack[VARS_ENTRY(vars_arity + 1)] = var; \
|
|
|
|
next_instruction(heap_arity - 1 || subs_arity, node); \
|
|
|
|
} else { \
|
|
|
|
CELL var = aux_stack[SUBS_ENTRY(1)]; \
|
|
|
|
aux_stack[SUBS_ARITY_ENTRY] = subs_arity - 1; \
|
|
|
|
TOP_STACK = &aux_stack[-1]; \
|
|
|
|
TOP_STACK[HEAP_ARITY_ENTRY] = 0; \
|
|
|
|
aux_stack[VARS_ARITY_ENTRY - 1] = vars_arity + 1; \
|
|
|
|
aux_stack[VARS_ENTRY(vars_arity + 1)] = var; \
|
|
|
|
next_instruction(subs_arity - 1, node); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define aux_stack_var_in_pair_instr() \
|
|
|
|
if (heap_arity) { \
|
|
|
|
int i; \
|
|
|
|
Bind_Global((CELL *) aux_stack[HEAP_ENTRY(1)], AbsPair(H)); \
|
|
|
|
TOP_STACK = &aux_stack[-1]; \
|
|
|
|
TOP_STACK[HEAP_ARITY_ENTRY] = heap_arity; \
|
|
|
|
TOP_STACK[HEAP_ENTRY(1)] = (CELL) (H + 1); \
|
|
|
|
for (i = 2; i <= heap_arity; i++) \
|
|
|
|
TOP_STACK[HEAP_ENTRY(i)] = aux_stack[HEAP_ENTRY(i)]; \
|
|
|
|
} else { \
|
|
|
|
Bind((CELL *) aux_stack[SUBS_ENTRY(1)], AbsPair(H)); \
|
|
|
|
aux_stack[SUBS_ARITY_ENTRY] = subs_arity - 1; \
|
|
|
|
TOP_STACK = &aux_stack[-2]; \
|
|
|
|
TOP_STACK[HEAP_ARITY_ENTRY] = 1; \
|
|
|
|
TOP_STACK[HEAP_ENTRY(1)] = (CELL) (H + 1); \
|
|
|
|
} \
|
|
|
|
aux_stack[VARS_ARITY_ENTRY - 1] = vars_arity + 1; \
|
|
|
|
aux_stack[VARS_ENTRY(vars_arity + 1)] = (CELL) H; \
|
|
|
|
RESET_VARIABLE((CELL) H); \
|
|
|
|
H += 2; \
|
2005-07-06 20:34:12 +01:00
|
|
|
next_trie_instruction(node)
|
|
|
|
|
2005-06-03 09:19:18 +01:00
|
|
|
|
2005-07-06 20:34:12 +01:00
|
|
|
|
2010-04-03 05:58:14 +01:00
|
|
|
/************************************************************************
|
2010-04-15 01:09:59 +01:00
|
|
|
** aux_stack_val_(in_pair_)instr **
|
2010-04-03 05:58:14 +01:00
|
|
|
************************************************************************/
|
2005-07-06 20:34:12 +01:00
|
|
|
|
2010-04-15 01:09:59 +01:00
|
|
|
#define aux_stack_val_instr() \
|
|
|
|
if (heap_arity) { \
|
|
|
|
CELL aux_sub, aux_var; \
|
|
|
|
aux_sub = aux_stack[HEAP_ENTRY(1)]; \
|
|
|
|
aux_var = aux_stack[VARS_ENTRY(var_index + 1)]; \
|
|
|
|
if (aux_sub > aux_var) { \
|
|
|
|
Bind_Global((CELL *) aux_sub, aux_var); \
|
|
|
|
} else { \
|
|
|
|
RESET_VARIABLE(aux_sub); \
|
|
|
|
Bind_Local((CELL *) aux_var, aux_sub); \
|
|
|
|
aux_stack[VARS_ENTRY(var_index + 1)] = aux_sub; \
|
|
|
|
} \
|
|
|
|
TOP_STACK = &aux_stack[1]; \
|
|
|
|
TOP_STACK[HEAP_ARITY_ENTRY] = heap_arity - 1; \
|
|
|
|
next_instruction(heap_arity - 1 || subs_arity, node); \
|
|
|
|
} else { \
|
|
|
|
CELL aux_sub, aux_var; \
|
|
|
|
aux_sub = aux_stack[SUBS_ENTRY(1)]; \
|
|
|
|
aux_stack[SUBS_ARITY_ENTRY] = subs_arity - 1; \
|
|
|
|
aux_var = aux_stack[VARS_ENTRY(var_index + 1)]; \
|
|
|
|
if (aux_sub > aux_var) { \
|
|
|
|
if ((CELL *) aux_sub <= H) { \
|
|
|
|
Bind_Global((CELL *) aux_sub, aux_var); \
|
|
|
|
} else if ((CELL *) aux_var <= H) { \
|
|
|
|
Bind_Local((CELL *) aux_sub, aux_var); \
|
|
|
|
} else { \
|
|
|
|
Bind_Local((CELL *) aux_var, aux_sub); \
|
|
|
|
aux_stack[VARS_ENTRY(var_index + 1)] = aux_sub; \
|
|
|
|
} \
|
|
|
|
} else { \
|
|
|
|
if ((CELL *) aux_var <= H) { \
|
|
|
|
Bind_Global((CELL *) aux_var, aux_sub); \
|
|
|
|
aux_stack[VARS_ENTRY(var_index + 1)] = aux_sub; \
|
|
|
|
} else if ((CELL *) aux_sub <= H) { \
|
|
|
|
Bind_Local((CELL *) aux_var, aux_sub); \
|
|
|
|
aux_stack[VARS_ENTRY(var_index + 1)] = aux_sub; \
|
|
|
|
} else { \
|
|
|
|
Bind_Local((CELL *) aux_sub, aux_var); \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
next_instruction(subs_arity - 1, node); \
|
2009-06-24 20:04:16 +01:00
|
|
|
}
|
2005-06-03 09:19:18 +01:00
|
|
|
|
2010-04-15 01:09:59 +01:00
|
|
|
#define aux_stack_val_in_pair_instr() \
|
|
|
|
if (heap_arity) { \
|
|
|
|
Bind_Global((CELL *) aux_stack[HEAP_ENTRY(1)], AbsPair(H)); \
|
|
|
|
} else { \
|
|
|
|
Bind((CELL *) aux_stack[SUBS_ENTRY(1)], AbsPair(H)); \
|
|
|
|
aux_stack[SUBS_ARITY_ENTRY] = subs_arity - 1; \
|
|
|
|
TOP_STACK = &aux_stack[-1]; \
|
|
|
|
TOP_STACK[HEAP_ARITY_ENTRY] = 1; \
|
|
|
|
} \
|
|
|
|
{ CELL aux_sub, aux_var; \
|
|
|
|
aux_sub = (CELL) H; \
|
|
|
|
aux_var = aux_stack[VARS_ENTRY(var_index + 1)]; \
|
|
|
|
if (aux_sub > aux_var) { \
|
|
|
|
Bind_Global((CELL *) aux_sub, aux_var); \
|
|
|
|
} else { \
|
|
|
|
RESET_VARIABLE(aux_sub); \
|
|
|
|
Bind_Local((CELL *) aux_var, aux_sub); \
|
|
|
|
aux_stack[VARS_ENTRY(var_index + 1)] = aux_sub; \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
TOP_STACK[HEAP_ENTRY(1)] = (CELL) (H + 1); \
|
|
|
|
H += 2; \
|
|
|
|
next_trie_instruction(node)
|
|
|
|
|
2005-06-03 09:19:18 +01:00
|
|
|
|
|
|
|
|
2010-04-03 05:58:14 +01:00
|
|
|
/************************************************************************
|
|
|
|
** Trie instructions **
|
|
|
|
************************************************************************/
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2010-04-15 01:09:59 +01:00
|
|
|
PBOp(trie_do_var, e)
|
2005-06-03 09:19:18 +01:00
|
|
|
register ans_node_ptr node = (ans_node_ptr) PREG;
|
2010-04-15 01:09:59 +01:00
|
|
|
register CELL *aux_stack = TOP_STACK;
|
|
|
|
int heap_arity = aux_stack[HEAP_ARITY_ENTRY];
|
|
|
|
int vars_arity = aux_stack[VARS_ARITY_ENTRY];
|
|
|
|
int subs_arity = aux_stack[SUBS_ARITY_ENTRY];
|
2005-06-03 09:19:18 +01:00
|
|
|
|
2010-04-15 01:09:59 +01:00
|
|
|
aux_stack_var_instr();
|
2005-06-03 09:19:18 +01:00
|
|
|
ENDPBOp();
|
|
|
|
|
|
|
|
|
2010-04-15 01:09:59 +01:00
|
|
|
PBOp(trie_trust_var, e)
|
2005-06-03 09:19:18 +01:00
|
|
|
register ans_node_ptr node = (ans_node_ptr) PREG;
|
2010-04-15 01:09:59 +01:00
|
|
|
register CELL *aux_stack = (CELL *) (B + 1);
|
|
|
|
int heap_arity = aux_stack[HEAP_ARITY_ENTRY];
|
|
|
|
int vars_arity = aux_stack[VARS_ARITY_ENTRY];
|
|
|
|
int subs_arity = aux_stack[SUBS_ARITY_ENTRY];
|
2009-06-24 20:04:16 +01:00
|
|
|
|
|
|
|
pop_trie_node();
|
2010-04-15 01:09:59 +01:00
|
|
|
aux_stack_var_instr();
|
2005-06-03 09:19:18 +01:00
|
|
|
ENDPBOp();
|
|
|
|
|
|
|
|
|
2010-04-15 01:09:59 +01:00
|
|
|
PBOp(trie_try_var, e)
|
2001-04-09 20:54:03 +01:00
|
|
|
register ans_node_ptr node = (ans_node_ptr) PREG;
|
2010-04-15 01:09:59 +01:00
|
|
|
register CELL *aux_stack = TOP_STACK;
|
|
|
|
int heap_arity = aux_stack[HEAP_ARITY_ENTRY];
|
|
|
|
int vars_arity = aux_stack[VARS_ARITY_ENTRY];
|
|
|
|
int subs_arity = aux_stack[SUBS_ARITY_ENTRY];
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2008-09-05 18:34:26 +01:00
|
|
|
store_trie_node(TrNode_next(node));
|
2010-04-15 01:09:59 +01:00
|
|
|
aux_stack_var_instr();
|
2001-04-09 20:54:03 +01:00
|
|
|
ENDPBOp();
|
|
|
|
|
|
|
|
|
2010-04-15 01:09:59 +01:00
|
|
|
PBOp(trie_retry_var, e)
|
2001-04-09 20:54:03 +01:00
|
|
|
register ans_node_ptr node = (ans_node_ptr) PREG;
|
2010-04-15 01:09:59 +01:00
|
|
|
register CELL *aux_stack = (CELL *) (B + 1);
|
|
|
|
int heap_arity = aux_stack[HEAP_ARITY_ENTRY];
|
|
|
|
int vars_arity = aux_stack[VARS_ARITY_ENTRY];
|
|
|
|
int subs_arity = aux_stack[SUBS_ARITY_ENTRY];
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2008-09-05 18:34:26 +01:00
|
|
|
restore_trie_node(TrNode_next(node));
|
2010-04-15 01:09:59 +01:00
|
|
|
aux_stack_var_instr();
|
2001-04-09 20:54:03 +01:00
|
|
|
ENDPBOp();
|
|
|
|
|
|
|
|
|
2010-04-15 01:09:59 +01:00
|
|
|
PBOp(trie_do_var_in_pair, e)
|
2009-09-27 02:31:31 +01:00
|
|
|
#if defined(TRIE_COMPACT_PAIRS) && !defined(GLOBAL_TRIE)
|
2009-06-24 20:04:16 +01:00
|
|
|
register ans_node_ptr node = (ans_node_ptr) PREG;
|
2010-04-15 01:09:59 +01:00
|
|
|
register CELL *aux_stack = TOP_STACK;
|
|
|
|
int heap_arity = aux_stack[HEAP_ARITY_ENTRY];
|
|
|
|
int vars_arity = aux_stack[VARS_ARITY_ENTRY];
|
|
|
|
int subs_arity = aux_stack[SUBS_ARITY_ENTRY];
|
2009-06-24 20:04:16 +01:00
|
|
|
|
2010-04-15 01:09:59 +01:00
|
|
|
aux_stack_var_in_pair_instr();
|
2009-06-24 20:04:16 +01:00
|
|
|
#else
|
2010-04-15 01:09:59 +01:00
|
|
|
Yap_Error(INTERNAL_ERROR, TermNil, "trie_do_var_in_pair: invalid instruction");
|
|
|
|
#endif /* TRIE_COMPACT_PAIRS && ! GLOBAL_TRIE */
|
2009-06-24 20:04:16 +01:00
|
|
|
ENDPBOp();
|
|
|
|
|
|
|
|
|
2010-04-15 01:09:59 +01:00
|
|
|
PBOp(trie_trust_var_in_pair, e)
|
2009-09-27 02:31:31 +01:00
|
|
|
#if defined(TRIE_COMPACT_PAIRS) && !defined(GLOBAL_TRIE)
|
2009-06-24 20:04:16 +01:00
|
|
|
register ans_node_ptr node = (ans_node_ptr) PREG;
|
2010-04-15 01:09:59 +01:00
|
|
|
register CELL *aux_stack = (CELL *) (B + 1);
|
|
|
|
int heap_arity = aux_stack[HEAP_ARITY_ENTRY];
|
|
|
|
int vars_arity = aux_stack[VARS_ARITY_ENTRY];
|
|
|
|
int subs_arity = aux_stack[SUBS_ARITY_ENTRY];
|
2009-06-24 20:04:16 +01:00
|
|
|
|
|
|
|
pop_trie_node();
|
2010-04-15 01:09:59 +01:00
|
|
|
aux_stack_var_in_pair_instr();
|
2009-06-24 20:04:16 +01:00
|
|
|
#else
|
2010-04-15 01:09:59 +01:00
|
|
|
Yap_Error(INTERNAL_ERROR, TermNil, "trie_trust_var_in_pair: invalid instruction");
|
|
|
|
#endif /* TRIE_COMPACT_PAIRS && ! GLOBAL_TRIE */
|
2009-06-24 20:04:16 +01:00
|
|
|
ENDPBOp();
|
|
|
|
|
|
|
|
|
2010-04-15 01:09:59 +01:00
|
|
|
PBOp(trie_try_var_in_pair, e)
|
2009-09-27 02:31:31 +01:00
|
|
|
#if defined(TRIE_COMPACT_PAIRS) && !defined(GLOBAL_TRIE)
|
2009-06-24 20:04:16 +01:00
|
|
|
register ans_node_ptr node = (ans_node_ptr) PREG;
|
2010-04-15 01:09:59 +01:00
|
|
|
register CELL *aux_stack = TOP_STACK;
|
|
|
|
int heap_arity = aux_stack[HEAP_ARITY_ENTRY];
|
|
|
|
int vars_arity = aux_stack[VARS_ARITY_ENTRY];
|
|
|
|
int subs_arity = aux_stack[SUBS_ARITY_ENTRY];
|
2009-06-24 20:04:16 +01:00
|
|
|
|
|
|
|
store_trie_node(TrNode_next(node));
|
2010-04-15 01:09:59 +01:00
|
|
|
aux_stack_var_in_pair_instr();
|
2009-06-24 20:04:16 +01:00
|
|
|
#else
|
2010-04-15 01:09:59 +01:00
|
|
|
Yap_Error(INTERNAL_ERROR, TermNil, "trie_try_var_in_pair: invalid instruction");
|
|
|
|
#endif /* TRIE_COMPACT_PAIRS && ! GLOBAL_TRIE */
|
2009-06-24 20:04:16 +01:00
|
|
|
ENDPBOp();
|
|
|
|
|
|
|
|
|
2010-04-15 01:09:59 +01:00
|
|
|
PBOp(trie_retry_var_in_pair, e)
|
2009-09-27 02:31:31 +01:00
|
|
|
#if defined(TRIE_COMPACT_PAIRS) && !defined(GLOBAL_TRIE)
|
2009-06-24 20:04:16 +01:00
|
|
|
register ans_node_ptr node = (ans_node_ptr) PREG;
|
2010-04-15 01:09:59 +01:00
|
|
|
register CELL *aux_stack = (CELL *) (B + 1);
|
|
|
|
int heap_arity = aux_stack[HEAP_ARITY_ENTRY];
|
|
|
|
int vars_arity = aux_stack[VARS_ARITY_ENTRY];
|
|
|
|
int subs_arity = aux_stack[SUBS_ARITY_ENTRY];
|
2009-06-24 20:04:16 +01:00
|
|
|
|
|
|
|
restore_trie_node(TrNode_next(node));
|
2010-04-15 01:09:59 +01:00
|
|
|
aux_stack_var_in_pair_instr();
|
2009-06-24 20:04:16 +01:00
|
|
|
#else
|
2010-04-15 01:09:59 +01:00
|
|
|
Yap_Error(INTERNAL_ERROR, TermNil, "trie_retry_var_in_pair: invalid instruction");
|
|
|
|
#endif /* TRIE_COMPACT_PAIRS && ! GLOBAL_TRIE */
|
2009-06-24 20:04:16 +01:00
|
|
|
ENDPBOp();
|
|
|
|
|
|
|
|
|
2010-04-15 01:09:59 +01:00
|
|
|
PBOp(trie_do_val, e)
|
2001-04-09 20:54:03 +01:00
|
|
|
register ans_node_ptr node = (ans_node_ptr) PREG;
|
2010-04-15 01:09:59 +01:00
|
|
|
register CELL *aux_stack = TOP_STACK;
|
|
|
|
int heap_arity = aux_stack[HEAP_ARITY_ENTRY];
|
|
|
|
int vars_arity = aux_stack[VARS_ARITY_ENTRY];
|
|
|
|
int subs_arity = aux_stack[SUBS_ARITY_ENTRY];
|
|
|
|
int var_index = VarIndexOfTableTerm(TrNode_entry(node));
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2010-04-15 01:09:59 +01:00
|
|
|
aux_stack_val_instr();
|
2001-04-09 20:54:03 +01:00
|
|
|
ENDPBOp();
|
|
|
|
|
|
|
|
|
2010-04-15 01:09:59 +01:00
|
|
|
PBOp(trie_trust_val, e)
|
2001-04-09 20:54:03 +01:00
|
|
|
register ans_node_ptr node = (ans_node_ptr) PREG;
|
2010-04-15 01:09:59 +01:00
|
|
|
register CELL *aux_stack = (CELL *) (B + 1);
|
|
|
|
int heap_arity = aux_stack[HEAP_ARITY_ENTRY];
|
|
|
|
int vars_arity = aux_stack[VARS_ARITY_ENTRY];
|
|
|
|
int subs_arity = aux_stack[SUBS_ARITY_ENTRY];
|
|
|
|
int var_index = VarIndexOfTableTerm(TrNode_entry(node));
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2009-06-24 20:04:16 +01:00
|
|
|
pop_trie_node();
|
2010-04-15 01:09:59 +01:00
|
|
|
aux_stack_val_instr();
|
2001-04-09 20:54:03 +01:00
|
|
|
ENDPBOp();
|
|
|
|
|
|
|
|
|
2010-04-15 01:09:59 +01:00
|
|
|
PBOp(trie_try_val, e)
|
2001-04-09 20:54:03 +01:00
|
|
|
register ans_node_ptr node = (ans_node_ptr) PREG;
|
2010-04-15 01:09:59 +01:00
|
|
|
register CELL *aux_stack = TOP_STACK;
|
|
|
|
int heap_arity = aux_stack[HEAP_ARITY_ENTRY];
|
|
|
|
int vars_arity = aux_stack[VARS_ARITY_ENTRY];
|
|
|
|
int subs_arity = aux_stack[SUBS_ARITY_ENTRY];
|
|
|
|
int var_index = VarIndexOfTableTerm(TrNode_entry(node));
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2008-09-05 18:34:26 +01:00
|
|
|
store_trie_node(TrNode_next(node));
|
2010-04-15 01:09:59 +01:00
|
|
|
aux_stack_val_instr();
|
2001-04-09 20:54:03 +01:00
|
|
|
ENDPBOp();
|
|
|
|
|
|
|
|
|
2010-04-15 01:09:59 +01:00
|
|
|
PBOp(trie_retry_val, e)
|
2001-04-09 20:54:03 +01:00
|
|
|
register ans_node_ptr node = (ans_node_ptr) PREG;
|
2010-04-15 01:09:59 +01:00
|
|
|
register CELL *aux_stack = (CELL *) (B + 1);
|
|
|
|
int heap_arity = aux_stack[HEAP_ARITY_ENTRY];
|
|
|
|
int vars_arity = aux_stack[VARS_ARITY_ENTRY];
|
|
|
|
int subs_arity = aux_stack[SUBS_ARITY_ENTRY];
|
|
|
|
int var_index = VarIndexOfTableTerm(TrNode_entry(node));
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2008-09-05 18:34:26 +01:00
|
|
|
restore_trie_node(TrNode_next(node));
|
2010-04-15 01:09:59 +01:00
|
|
|
aux_stack_val_instr();
|
2001-04-09 20:54:03 +01:00
|
|
|
ENDPBOp();
|
|
|
|
|
|
|
|
|
2010-04-15 01:09:59 +01:00
|
|
|
PBOp(trie_do_val_in_pair, e)
|
2009-09-27 02:31:31 +01:00
|
|
|
#if defined(TRIE_COMPACT_PAIRS) && !defined(GLOBAL_TRIE)
|
2009-06-24 20:04:16 +01:00
|
|
|
register ans_node_ptr node = (ans_node_ptr) PREG;
|
2010-04-15 01:09:59 +01:00
|
|
|
register CELL *aux_stack = TOP_STACK;
|
|
|
|
int heap_arity = aux_stack[HEAP_ARITY_ENTRY];
|
|
|
|
int vars_arity = aux_stack[VARS_ARITY_ENTRY];
|
|
|
|
int subs_arity = aux_stack[SUBS_ARITY_ENTRY];
|
|
|
|
int var_index = VarIndexOfTableTerm(TrNode_entry(node));
|
2009-06-24 20:04:16 +01:00
|
|
|
|
2010-04-15 01:09:59 +01:00
|
|
|
aux_stack_val_in_pair_instr();
|
2009-06-24 20:04:16 +01:00
|
|
|
#else
|
2010-04-15 01:09:59 +01:00
|
|
|
Yap_Error(INTERNAL_ERROR, TermNil, "trie_do_val_in_pair: invalid instruction");
|
|
|
|
#endif /* TRIE_COMPACT_PAIRS && ! GLOBAL_TRIE */
|
2009-06-24 20:04:16 +01:00
|
|
|
ENDPBOp();
|
|
|
|
|
|
|
|
|
2010-04-15 01:09:59 +01:00
|
|
|
PBOp(trie_trust_val_in_pair, e)
|
2009-09-27 02:31:31 +01:00
|
|
|
#if defined(TRIE_COMPACT_PAIRS) && !defined(GLOBAL_TRIE)
|
2009-06-24 20:04:16 +01:00
|
|
|
register ans_node_ptr node = (ans_node_ptr) PREG;
|
2010-04-15 01:09:59 +01:00
|
|
|
register CELL *aux_stack = (CELL *) (B + 1);
|
|
|
|
int heap_arity = aux_stack[HEAP_ARITY_ENTRY];
|
|
|
|
int vars_arity = aux_stack[VARS_ARITY_ENTRY];
|
|
|
|
int subs_arity = aux_stack[SUBS_ARITY_ENTRY];
|
|
|
|
int var_index = VarIndexOfTableTerm(TrNode_entry(node));
|
2009-06-24 20:04:16 +01:00
|
|
|
|
|
|
|
pop_trie_node();
|
2010-04-15 01:09:59 +01:00
|
|
|
aux_stack_val_in_pair_instr();
|
2009-06-24 20:04:16 +01:00
|
|
|
#else
|
2010-04-15 01:09:59 +01:00
|
|
|
Yap_Error(INTERNAL_ERROR, TermNil, "trie_trust_val_in_pair: invalid instruction");
|
|
|
|
#endif /* TRIE_COMPACT_PAIRS && ! GLOBAL_TRIE */
|
2009-06-24 20:04:16 +01:00
|
|
|
ENDPBOp();
|
|
|
|
|
|
|
|
|
2010-04-15 01:09:59 +01:00
|
|
|
PBOp(trie_try_val_in_pair, e)
|
2009-09-27 02:31:31 +01:00
|
|
|
#if defined(TRIE_COMPACT_PAIRS) && !defined(GLOBAL_TRIE)
|
2009-06-24 20:04:16 +01:00
|
|
|
register ans_node_ptr node = (ans_node_ptr) PREG;
|
2010-04-15 01:09:59 +01:00
|
|
|
register CELL *aux_stack = TOP_STACK;
|
|
|
|
int heap_arity = aux_stack[HEAP_ARITY_ENTRY];
|
|
|
|
int vars_arity = aux_stack[VARS_ARITY_ENTRY];
|
|
|
|
int subs_arity = aux_stack[SUBS_ARITY_ENTRY];
|
|
|
|
int var_index = VarIndexOfTableTerm(TrNode_entry(node));
|
2009-06-24 20:04:16 +01:00
|
|
|
|
|
|
|
store_trie_node(TrNode_next(node));
|
2010-04-15 01:09:59 +01:00
|
|
|
aux_stack_val_in_pair_instr();
|
2009-06-24 20:04:16 +01:00
|
|
|
#else
|
2010-04-15 01:09:59 +01:00
|
|
|
Yap_Error(INTERNAL_ERROR, TermNil, "trie_try_val_in_pair: invalid instruction");
|
|
|
|
#endif /* TRIE_COMPACT_PAIRS && ! GLOBAL_TRIE */
|
2009-06-24 20:04:16 +01:00
|
|
|
ENDPBOp();
|
|
|
|
|
|
|
|
|
2010-04-15 01:09:59 +01:00
|
|
|
PBOp(trie_retry_val_in_pair, e)
|
2009-09-27 02:31:31 +01:00
|
|
|
#if defined(TRIE_COMPACT_PAIRS) && !defined(GLOBAL_TRIE)
|
2009-06-24 20:04:16 +01:00
|
|
|
register ans_node_ptr node = (ans_node_ptr) PREG;
|
2010-04-15 01:09:59 +01:00
|
|
|
register CELL *aux_stack = (CELL *) (B + 1);
|
|
|
|
int heap_arity = aux_stack[HEAP_ARITY_ENTRY];
|
|
|
|
int vars_arity = aux_stack[VARS_ARITY_ENTRY];
|
|
|
|
int subs_arity = aux_stack[SUBS_ARITY_ENTRY];
|
|
|
|
int var_index = VarIndexOfTableTerm(TrNode_entry(node));
|
2009-06-24 20:04:16 +01:00
|
|
|
|
|
|
|
restore_trie_node(TrNode_next(node));
|
2010-04-15 01:09:59 +01:00
|
|
|
aux_stack_val_in_pair_instr();
|
2009-06-24 20:04:16 +01:00
|
|
|
#else
|
2010-04-15 01:09:59 +01:00
|
|
|
Yap_Error(INTERNAL_ERROR, TermNil, "trie_retry_val_in_pair: invalid instruction");
|
|
|
|
#endif /* TRIE_COMPACT_PAIRS && ! GLOBAL_TRIE */
|
2009-06-24 20:04:16 +01:00
|
|
|
ENDPBOp();
|
|
|
|
|
|
|
|
|
2010-04-15 01:09:59 +01:00
|
|
|
PBOp(trie_do_atom, e)
|
2001-04-09 20:54:03 +01:00
|
|
|
register ans_node_ptr node = (ans_node_ptr) PREG;
|
2010-04-15 01:09:59 +01:00
|
|
|
register CELL *aux_stack = TOP_STACK;
|
|
|
|
int heap_arity = aux_stack[HEAP_ARITY_ENTRY];
|
|
|
|
int vars_arity = aux_stack[VARS_ARITY_ENTRY];
|
|
|
|
int subs_arity = aux_stack[SUBS_ARITY_ENTRY];
|
|
|
|
Term t = TrNode_entry(node);
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2010-04-15 01:09:59 +01:00
|
|
|
aux_stack_term_instr();
|
2001-04-09 20:54:03 +01:00
|
|
|
ENDPBOp();
|
|
|
|
|
|
|
|
|
2010-04-15 01:09:59 +01:00
|
|
|
PBOp(trie_trust_atom, e)
|
2001-04-09 20:54:03 +01:00
|
|
|
register ans_node_ptr node = (ans_node_ptr) PREG;
|
2010-04-15 01:09:59 +01:00
|
|
|
register CELL *aux_stack = (CELL *) (B + 1);
|
|
|
|
int heap_arity = aux_stack[HEAP_ARITY_ENTRY];
|
|
|
|
int vars_arity = aux_stack[VARS_ARITY_ENTRY];
|
|
|
|
int subs_arity = aux_stack[SUBS_ARITY_ENTRY];
|
|
|
|
Term t = TrNode_entry(node);
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2009-06-24 20:04:16 +01:00
|
|
|
pop_trie_node();
|
2010-04-15 01:09:59 +01:00
|
|
|
aux_stack_term_instr();
|
2001-04-09 20:54:03 +01:00
|
|
|
ENDPBOp();
|
|
|
|
|
|
|
|
|
2010-04-15 01:09:59 +01:00
|
|
|
PBOp(trie_try_atom, e)
|
2001-04-09 20:54:03 +01:00
|
|
|
register ans_node_ptr node = (ans_node_ptr) PREG;
|
2010-04-15 01:09:59 +01:00
|
|
|
register CELL *aux_stack = TOP_STACK;
|
|
|
|
int heap_arity = aux_stack[HEAP_ARITY_ENTRY];
|
|
|
|
int vars_arity = aux_stack[VARS_ARITY_ENTRY];
|
|
|
|
int subs_arity = aux_stack[SUBS_ARITY_ENTRY];
|
|
|
|
Term t = TrNode_entry(node);
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2008-09-05 18:34:26 +01:00
|
|
|
store_trie_node(TrNode_next(node));
|
2010-04-15 01:09:59 +01:00
|
|
|
aux_stack_term_instr();
|
2001-04-09 20:54:03 +01:00
|
|
|
ENDPBOp();
|
|
|
|
|
|
|
|
|
2010-04-15 01:09:59 +01:00
|
|
|
PBOp(trie_retry_atom, e)
|
2001-04-09 20:54:03 +01:00
|
|
|
register ans_node_ptr node = (ans_node_ptr) PREG;
|
2010-04-15 01:09:59 +01:00
|
|
|
register CELL *aux_stack = (CELL *) (B + 1);
|
|
|
|
int heap_arity = aux_stack[HEAP_ARITY_ENTRY];
|
|
|
|
int vars_arity = aux_stack[VARS_ARITY_ENTRY];
|
|
|
|
int subs_arity = aux_stack[SUBS_ARITY_ENTRY];
|
|
|
|
Term t = TrNode_entry(node);
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2008-09-05 18:34:26 +01:00
|
|
|
restore_trie_node(TrNode_next(node));
|
2010-04-15 01:09:59 +01:00
|
|
|
aux_stack_term_instr();
|
2001-04-09 20:54:03 +01:00
|
|
|
ENDPBOp();
|
|
|
|
|
|
|
|
|
2010-04-15 01:09:59 +01:00
|
|
|
PBOp(trie_do_atom_in_pair, e)
|
2009-09-27 02:31:31 +01:00
|
|
|
#if defined(TRIE_COMPACT_PAIRS) && !defined(GLOBAL_TRIE)
|
2009-06-24 20:04:16 +01:00
|
|
|
register ans_node_ptr node = (ans_node_ptr) PREG;
|
2010-04-15 01:09:59 +01:00
|
|
|
register CELL *aux_stack = TOP_STACK;
|
|
|
|
int heap_arity = aux_stack[HEAP_ARITY_ENTRY];
|
|
|
|
int vars_arity = aux_stack[VARS_ARITY_ENTRY];
|
|
|
|
int subs_arity = aux_stack[SUBS_ARITY_ENTRY];
|
2009-06-24 20:04:16 +01:00
|
|
|
|
2010-04-15 01:09:59 +01:00
|
|
|
aux_stack_term_in_pair_instr();
|
2009-06-24 20:04:16 +01:00
|
|
|
#else
|
2010-04-15 01:09:59 +01:00
|
|
|
Yap_Error(INTERNAL_ERROR, TermNil, "trie_do_atom_in_pair: invalid instruction");
|
|
|
|
#endif /* TRIE_COMPACT_PAIRS && ! GLOBAL_TRIE */
|
2009-06-24 20:04:16 +01:00
|
|
|
ENDPBOp();
|
|
|
|
|
|
|
|
|
2010-04-15 01:09:59 +01:00
|
|
|
PBOp(trie_trust_atom_in_pair, e)
|
2009-09-27 02:31:31 +01:00
|
|
|
#if defined(TRIE_COMPACT_PAIRS) && !defined(GLOBAL_TRIE)
|
2009-06-24 20:04:16 +01:00
|
|
|
register ans_node_ptr node = (ans_node_ptr) PREG;
|
2010-04-15 01:09:59 +01:00
|
|
|
register CELL *aux_stack = (CELL *) (B + 1);
|
|
|
|
int heap_arity = aux_stack[HEAP_ARITY_ENTRY];
|
|
|
|
int vars_arity = aux_stack[VARS_ARITY_ENTRY];
|
|
|
|
int subs_arity = aux_stack[SUBS_ARITY_ENTRY];
|
2009-06-24 20:04:16 +01:00
|
|
|
|
|
|
|
pop_trie_node();
|
2010-04-15 01:09:59 +01:00
|
|
|
aux_stack_term_in_pair_instr();
|
2009-06-24 20:04:16 +01:00
|
|
|
#else
|
2010-04-15 01:09:59 +01:00
|
|
|
Yap_Error(INTERNAL_ERROR, TermNil, "trie_trust_atom_in_pair: invalid instruction");
|
|
|
|
#endif /* TRIE_COMPACT_PAIRS && ! GLOBAL_TRIE */
|
2009-06-24 20:04:16 +01:00
|
|
|
ENDPBOp();
|
|
|
|
|
|
|
|
|
2010-04-15 01:09:59 +01:00
|
|
|
PBOp(trie_try_atom_in_pair, e)
|
2009-09-27 02:31:31 +01:00
|
|
|
#if defined(TRIE_COMPACT_PAIRS) && !defined(GLOBAL_TRIE)
|
2009-06-24 20:04:16 +01:00
|
|
|
register ans_node_ptr node = (ans_node_ptr) PREG;
|
2010-04-15 01:09:59 +01:00
|
|
|
register CELL *aux_stack = TOP_STACK;
|
|
|
|
int heap_arity = aux_stack[HEAP_ARITY_ENTRY];
|
|
|
|
int vars_arity = aux_stack[VARS_ARITY_ENTRY];
|
|
|
|
int subs_arity = aux_stack[SUBS_ARITY_ENTRY];
|
2009-06-24 20:04:16 +01:00
|
|
|
|
|
|
|
store_trie_node(TrNode_next(node));
|
2010-04-15 01:09:59 +01:00
|
|
|
aux_stack_term_in_pair_instr();
|
2009-06-24 20:04:16 +01:00
|
|
|
#else
|
2010-04-15 01:09:59 +01:00
|
|
|
Yap_Error(INTERNAL_ERROR, TermNil, "trie_try_atom_in_pair: invalid instruction");
|
|
|
|
#endif /* TRIE_COMPACT_PAIRS && ! GLOBAL_TRIE */
|
2009-06-24 20:04:16 +01:00
|
|
|
ENDPBOp();
|
|
|
|
|
|
|
|
|
2010-04-15 01:09:59 +01:00
|
|
|
PBOp(trie_retry_atom_in_pair, e)
|
2009-09-27 02:31:31 +01:00
|
|
|
#if defined(TRIE_COMPACT_PAIRS) && !defined(GLOBAL_TRIE)
|
2009-06-24 20:04:16 +01:00
|
|
|
register ans_node_ptr node = (ans_node_ptr) PREG;
|
2010-04-15 01:09:59 +01:00
|
|
|
register CELL *aux_stack = (CELL *) (B + 1);
|
|
|
|
int heap_arity = aux_stack[HEAP_ARITY_ENTRY];
|
|
|
|
int vars_arity = aux_stack[VARS_ARITY_ENTRY];
|
|
|
|
int subs_arity = aux_stack[SUBS_ARITY_ENTRY];
|
2009-06-24 20:04:16 +01:00
|
|
|
|
|
|
|
restore_trie_node(TrNode_next(node));
|
2010-04-15 01:09:59 +01:00
|
|
|
aux_stack_term_in_pair_instr();
|
2009-06-24 20:04:16 +01:00
|
|
|
#else
|
2010-04-15 01:09:59 +01:00
|
|
|
Yap_Error(INTERNAL_ERROR, TermNil, "trie_retry_atom_in_pair: invalid instruction");
|
|
|
|
#endif /* TRIE_COMPACT_PAIRS && ! GLOBAL_TRIE */
|
2009-06-24 20:04:16 +01:00
|
|
|
ENDPBOp();
|
|
|
|
|
|
|
|
|
2010-04-15 01:09:59 +01:00
|
|
|
PBOp(trie_do_null, e)
|
2001-04-09 20:54:03 +01:00
|
|
|
register ans_node_ptr node = (ans_node_ptr) PREG;
|
|
|
|
|
2010-04-15 01:09:59 +01:00
|
|
|
aux_stack_null_instr();
|
2001-04-09 20:54:03 +01:00
|
|
|
ENDPBOp();
|
|
|
|
|
|
|
|
|
2010-04-15 01:09:59 +01:00
|
|
|
PBOp(trie_trust_null, e)
|
2001-04-09 20:54:03 +01:00
|
|
|
register ans_node_ptr node = (ans_node_ptr) PREG;
|
2010-04-15 01:09:59 +01:00
|
|
|
register CELL *aux_stack = (CELL *) (B + 1);
|
|
|
|
int heap_arity = aux_stack[HEAP_ARITY_ENTRY];
|
|
|
|
int vars_arity = aux_stack[VARS_ARITY_ENTRY];
|
|
|
|
int subs_arity = aux_stack[SUBS_ARITY_ENTRY];
|
|
|
|
|
2009-06-24 20:04:16 +01:00
|
|
|
pop_trie_node();
|
2010-04-15 01:09:59 +01:00
|
|
|
aux_stack_null_instr();
|
2001-04-09 20:54:03 +01:00
|
|
|
ENDPBOp();
|
|
|
|
|
|
|
|
|
2010-04-15 01:09:59 +01:00
|
|
|
PBOp(trie_try_null, e)
|
2001-04-09 20:54:03 +01:00
|
|
|
register ans_node_ptr node = (ans_node_ptr) PREG;
|
2010-04-15 01:09:59 +01:00
|
|
|
register CELL *aux_stack = TOP_STACK;
|
|
|
|
int heap_arity = aux_stack[HEAP_ARITY_ENTRY];
|
|
|
|
int vars_arity = aux_stack[VARS_ARITY_ENTRY];
|
|
|
|
int subs_arity = aux_stack[SUBS_ARITY_ENTRY];
|
|
|
|
|
2008-09-05 18:34:26 +01:00
|
|
|
store_trie_node(TrNode_next(node));
|
2010-04-15 01:09:59 +01:00
|
|
|
aux_stack_null_instr();
|
2001-04-09 20:54:03 +01:00
|
|
|
ENDPBOp();
|
|
|
|
|
|
|
|
|
2010-04-15 01:09:59 +01:00
|
|
|
PBOp(trie_retry_null, e)
|
2001-04-09 20:54:03 +01:00
|
|
|
register ans_node_ptr node = (ans_node_ptr) PREG;
|
2010-04-15 01:09:59 +01:00
|
|
|
register CELL *aux_stack = (CELL *) (B + 1);
|
|
|
|
int heap_arity = aux_stack[HEAP_ARITY_ENTRY];
|
|
|
|
int vars_arity = aux_stack[VARS_ARITY_ENTRY];
|
|
|
|
int subs_arity = aux_stack[SUBS_ARITY_ENTRY];
|
|
|
|
|
2008-09-05 18:34:26 +01:00
|
|
|
restore_trie_node(TrNode_next(node));
|
2010-04-15 01:09:59 +01:00
|
|
|
aux_stack_null_instr();
|
2001-04-09 20:54:03 +01:00
|
|
|
ENDPBOp();
|
|
|
|
|
|
|
|
|
2010-04-15 01:09:59 +01:00
|
|
|
PBOp(trie_do_null_in_pair, e)
|
|
|
|
#ifdef TRIE_COMPACT_PAIRS
|
2009-06-24 20:04:16 +01:00
|
|
|
register ans_node_ptr node = (ans_node_ptr) PREG;
|
2010-04-15 01:09:59 +01:00
|
|
|
register CELL *aux_stack = TOP_STACK;
|
|
|
|
int heap_arity = aux_stack[HEAP_ARITY_ENTRY];
|
|
|
|
int vars_arity = aux_stack[VARS_ARITY_ENTRY];
|
|
|
|
int subs_arity = aux_stack[SUBS_ARITY_ENTRY];
|
2009-06-24 20:04:16 +01:00
|
|
|
|
2010-04-15 01:09:59 +01:00
|
|
|
aux_stack_new_pair_instr();
|
2009-06-24 20:04:16 +01:00
|
|
|
#else
|
2010-04-15 01:09:59 +01:00
|
|
|
Yap_Error(INTERNAL_ERROR, TermNil, "trie_do_null_in_pair: invalid instruction");
|
|
|
|
#endif /* TRIE_COMPACT_PAIRS && ! GLOBAL_TRIE */
|
2009-06-24 20:04:16 +01:00
|
|
|
ENDPBOp();
|
|
|
|
|
|
|
|
|
2010-04-15 01:09:59 +01:00
|
|
|
PBOp(trie_trust_null_in_pair, e)
|
|
|
|
#ifdef TRIE_COMPACT_PAIRS
|
2009-06-24 20:04:16 +01:00
|
|
|
register ans_node_ptr node = (ans_node_ptr) PREG;
|
2010-04-15 01:09:59 +01:00
|
|
|
register CELL *aux_stack = (CELL *) (B + 1);
|
|
|
|
int heap_arity = aux_stack[HEAP_ARITY_ENTRY];
|
|
|
|
int vars_arity = aux_stack[VARS_ARITY_ENTRY];
|
|
|
|
int subs_arity = aux_stack[SUBS_ARITY_ENTRY];
|
2009-06-24 20:04:16 +01:00
|
|
|
|
|
|
|
pop_trie_node();
|
2010-04-15 01:09:59 +01:00
|
|
|
aux_stack_new_pair_instr();
|
2009-06-24 20:04:16 +01:00
|
|
|
#else
|
2010-04-15 01:09:59 +01:00
|
|
|
Yap_Error(INTERNAL_ERROR, TermNil, "trie_trust_null_in_pair: invalid instruction");
|
|
|
|
#endif /* TRIE_COMPACT_PAIRS && ! GLOBAL_TRIE */
|
2009-06-24 20:04:16 +01:00
|
|
|
ENDPBOp();
|
|
|
|
|
|
|
|
|
2010-04-15 01:09:59 +01:00
|
|
|
PBOp(trie_try_null_in_pair, e)
|
|
|
|
#ifdef TRIE_COMPACT_PAIRS
|
2009-06-24 20:04:16 +01:00
|
|
|
register ans_node_ptr node = (ans_node_ptr) PREG;
|
2010-04-15 01:09:59 +01:00
|
|
|
register CELL *aux_stack = TOP_STACK;
|
|
|
|
int heap_arity = aux_stack[HEAP_ARITY_ENTRY];
|
|
|
|
int vars_arity = aux_stack[VARS_ARITY_ENTRY];
|
|
|
|
int subs_arity = aux_stack[SUBS_ARITY_ENTRY];
|
2009-06-24 20:04:16 +01:00
|
|
|
|
|
|
|
store_trie_node(TrNode_next(node));
|
2010-04-15 01:09:59 +01:00
|
|
|
aux_stack_new_pair_instr();
|
2009-06-24 20:04:16 +01:00
|
|
|
#else
|
2010-04-15 01:09:59 +01:00
|
|
|
Yap_Error(INTERNAL_ERROR, TermNil, "trie_try_null_in_pair: invalid instruction");
|
|
|
|
#endif /* TRIE_COMPACT_PAIRS && ! GLOBAL_TRIE */
|
2009-06-24 20:04:16 +01:00
|
|
|
ENDPBOp();
|
|
|
|
|
|
|
|
|
2010-04-15 01:09:59 +01:00
|
|
|
PBOp(trie_retry_null_in_pair, e)
|
|
|
|
#ifdef TRIE_COMPACT_PAIRS
|
2009-06-24 20:04:16 +01:00
|
|
|
register ans_node_ptr node = (ans_node_ptr) PREG;
|
2010-04-15 01:09:59 +01:00
|
|
|
register CELL *aux_stack = (CELL *) (B + 1);
|
|
|
|
int heap_arity = aux_stack[HEAP_ARITY_ENTRY];
|
|
|
|
int vars_arity = aux_stack[VARS_ARITY_ENTRY];
|
|
|
|
int subs_arity = aux_stack[SUBS_ARITY_ENTRY];
|
2009-06-24 20:04:16 +01:00
|
|
|
|
|
|
|
restore_trie_node(TrNode_next(node));
|
2010-04-15 01:09:59 +01:00
|
|
|
aux_stack_new_pair_instr();
|
2009-06-24 20:04:16 +01:00
|
|
|
#else
|
2010-04-15 01:09:59 +01:00
|
|
|
Yap_Error(INTERNAL_ERROR, TermNil, "trie_retry_null_in_pair: invalid instruction");
|
|
|
|
#endif /* TRIE_COMPACT_PAIRS && ! GLOBAL_TRIE */
|
2001-04-09 20:54:03 +01:00
|
|
|
ENDPBOp();
|
|
|
|
|
|
|
|
|
2009-07-05 05:14:08 +01:00
|
|
|
PBOp(trie_do_pair, e)
|
2001-04-09 20:54:03 +01:00
|
|
|
register ans_node_ptr node = (ans_node_ptr) PREG;
|
2010-04-15 01:09:59 +01:00
|
|
|
register CELL *aux_stack = TOP_STACK;
|
|
|
|
int heap_arity = aux_stack[HEAP_ARITY_ENTRY];
|
|
|
|
int vars_arity = aux_stack[VARS_ARITY_ENTRY];
|
|
|
|
int subs_arity = aux_stack[SUBS_ARITY_ENTRY];
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2010-04-15 01:09:59 +01:00
|
|
|
aux_stack_pair_instr();
|
2001-04-09 20:54:03 +01:00
|
|
|
ENDPBOp();
|
|
|
|
|
|
|
|
|
2009-07-05 05:14:08 +01:00
|
|
|
PBOp(trie_trust_pair, e)
|
2009-06-24 20:04:16 +01:00
|
|
|
register ans_node_ptr node = (ans_node_ptr) PREG;
|
2010-04-15 01:09:59 +01:00
|
|
|
register CELL *aux_stack = (CELL *) (B + 1);
|
|
|
|
int heap_arity = aux_stack[HEAP_ARITY_ENTRY];
|
|
|
|
int vars_arity = aux_stack[VARS_ARITY_ENTRY];
|
|
|
|
int subs_arity = aux_stack[SUBS_ARITY_ENTRY];
|
2009-06-24 20:04:16 +01:00
|
|
|
|
|
|
|
pop_trie_node();
|
2010-04-15 01:09:59 +01:00
|
|
|
aux_stack_pair_instr();
|
2009-06-24 20:04:16 +01:00
|
|
|
ENDPBOp();
|
|
|
|
|
|
|
|
|
2009-07-05 05:14:08 +01:00
|
|
|
PBOp(trie_try_pair, e)
|
2009-06-24 20:04:16 +01:00
|
|
|
register ans_node_ptr node = (ans_node_ptr) PREG;
|
2010-04-15 01:09:59 +01:00
|
|
|
register CELL *aux_stack = TOP_STACK;
|
|
|
|
int heap_arity = aux_stack[HEAP_ARITY_ENTRY];
|
|
|
|
int vars_arity = aux_stack[VARS_ARITY_ENTRY];
|
|
|
|
int subs_arity = aux_stack[SUBS_ARITY_ENTRY];
|
2009-06-24 20:04:16 +01:00
|
|
|
|
|
|
|
store_trie_node(TrNode_next(node));
|
2010-04-15 01:09:59 +01:00
|
|
|
aux_stack_pair_instr();
|
2009-06-24 20:04:16 +01:00
|
|
|
ENDPBOp();
|
|
|
|
|
|
|
|
|
2009-07-05 05:14:08 +01:00
|
|
|
PBOp(trie_retry_pair, e)
|
2009-06-24 20:04:16 +01:00
|
|
|
register ans_node_ptr node = (ans_node_ptr) PREG;
|
2010-04-15 01:09:59 +01:00
|
|
|
register CELL *aux_stack = (CELL *) (B + 1);
|
|
|
|
int heap_arity = aux_stack[HEAP_ARITY_ENTRY];
|
|
|
|
int vars_arity = aux_stack[VARS_ARITY_ENTRY];
|
|
|
|
int subs_arity = aux_stack[SUBS_ARITY_ENTRY];
|
2009-06-24 20:04:16 +01:00
|
|
|
|
|
|
|
restore_trie_node(TrNode_next(node));
|
2010-04-15 01:09:59 +01:00
|
|
|
aux_stack_pair_instr();
|
2009-06-24 20:04:16 +01:00
|
|
|
ENDPBOp();
|
|
|
|
|
|
|
|
|
2010-04-15 01:09:59 +01:00
|
|
|
PBOp(trie_do_appl, e)
|
2001-04-09 20:54:03 +01:00
|
|
|
register ans_node_ptr node = (ans_node_ptr) PREG;
|
2010-04-15 01:09:59 +01:00
|
|
|
register CELL *aux_stack = TOP_STACK;
|
|
|
|
int heap_arity = aux_stack[HEAP_ARITY_ENTRY];
|
|
|
|
int vars_arity = aux_stack[VARS_ARITY_ENTRY];
|
|
|
|
int subs_arity = aux_stack[SUBS_ARITY_ENTRY];
|
2005-05-31 09:19:31 +01:00
|
|
|
Functor func = (Functor) RepAppl(TrNode_entry(node));
|
2001-04-09 20:54:03 +01:00
|
|
|
int func_arity = ArityOfFunctor(func);
|
|
|
|
|
2010-04-15 01:09:59 +01:00
|
|
|
aux_stack_appl_instr();
|
2001-04-09 20:54:03 +01:00
|
|
|
ENDPBOp();
|
|
|
|
|
|
|
|
|
2010-04-15 01:09:59 +01:00
|
|
|
PBOp(trie_trust_appl, e)
|
2001-04-09 20:54:03 +01:00
|
|
|
register ans_node_ptr node = (ans_node_ptr) PREG;
|
2010-04-15 01:09:59 +01:00
|
|
|
register CELL *aux_stack = (CELL *) (B + 1);
|
|
|
|
int heap_arity = aux_stack[HEAP_ARITY_ENTRY];
|
|
|
|
int vars_arity = aux_stack[VARS_ARITY_ENTRY];
|
|
|
|
int subs_arity = aux_stack[SUBS_ARITY_ENTRY];
|
2005-05-31 09:19:31 +01:00
|
|
|
Functor func = (Functor) RepAppl(TrNode_entry(node));
|
2001-04-09 20:54:03 +01:00
|
|
|
int func_arity = ArityOfFunctor(func);
|
|
|
|
|
2009-06-24 20:04:16 +01:00
|
|
|
pop_trie_node();
|
2010-04-15 01:09:59 +01:00
|
|
|
aux_stack_appl_instr();
|
2001-04-09 20:54:03 +01:00
|
|
|
ENDPBOp();
|
2005-06-03 09:19:18 +01:00
|
|
|
|
|
|
|
|
2010-04-15 01:09:59 +01:00
|
|
|
PBOp(trie_try_appl, e)
|
2005-07-06 20:34:12 +01:00
|
|
|
register ans_node_ptr node = (ans_node_ptr) PREG;
|
2010-04-15 01:09:59 +01:00
|
|
|
register CELL *aux_stack = TOP_STACK;
|
|
|
|
int heap_arity = aux_stack[HEAP_ARITY_ENTRY];
|
|
|
|
int vars_arity = aux_stack[VARS_ARITY_ENTRY];
|
|
|
|
int subs_arity = aux_stack[SUBS_ARITY_ENTRY];
|
2008-09-05 18:34:26 +01:00
|
|
|
Functor func = (Functor) RepAppl(TrNode_entry(node));
|
|
|
|
int func_arity = ArityOfFunctor(func);
|
2005-07-06 20:34:12 +01:00
|
|
|
|
2008-09-05 18:34:26 +01:00
|
|
|
store_trie_node(TrNode_next(node));
|
2010-04-15 01:09:59 +01:00
|
|
|
aux_stack_appl_instr();
|
2005-07-06 20:34:12 +01:00
|
|
|
ENDPBOp();
|
|
|
|
|
|
|
|
|
2010-04-15 01:09:59 +01:00
|
|
|
PBOp(trie_retry_appl, e)
|
2005-07-06 20:34:12 +01:00
|
|
|
register ans_node_ptr node = (ans_node_ptr) PREG;
|
2010-04-15 01:09:59 +01:00
|
|
|
register CELL *aux_stack = (CELL *) (B + 1);
|
|
|
|
int heap_arity = aux_stack[HEAP_ARITY_ENTRY];
|
|
|
|
int vars_arity = aux_stack[VARS_ARITY_ENTRY];
|
|
|
|
int subs_arity = aux_stack[SUBS_ARITY_ENTRY];
|
2008-09-05 18:34:26 +01:00
|
|
|
Functor func = (Functor) RepAppl(TrNode_entry(node));
|
|
|
|
int func_arity = ArityOfFunctor(func);
|
2005-07-06 20:34:12 +01:00
|
|
|
|
2008-09-05 18:34:26 +01:00
|
|
|
restore_trie_node(TrNode_next(node));
|
2010-04-15 01:09:59 +01:00
|
|
|
aux_stack_appl_instr();
|
2005-07-06 20:34:12 +01:00
|
|
|
ENDPBOp();
|
|
|
|
|
|
|
|
|
2010-04-15 01:09:59 +01:00
|
|
|
PBOp(trie_do_appl_in_pair, e)
|
|
|
|
#ifdef TRIE_COMPACT_PAIRS
|
2009-06-24 20:04:16 +01:00
|
|
|
register ans_node_ptr node = (ans_node_ptr) PREG;
|
2010-04-15 01:09:59 +01:00
|
|
|
register CELL *aux_stack = TOP_STACK;
|
|
|
|
int heap_arity = aux_stack[HEAP_ARITY_ENTRY];
|
|
|
|
int vars_arity = aux_stack[VARS_ARITY_ENTRY];
|
|
|
|
int subs_arity = aux_stack[SUBS_ARITY_ENTRY];
|
2009-06-24 20:04:16 +01:00
|
|
|
Functor func = (Functor) RepAppl(TrNode_entry(node));
|
|
|
|
int func_arity = ArityOfFunctor(func);
|
|
|
|
|
2010-04-15 01:09:59 +01:00
|
|
|
aux_stack_appl_in_pair_instr();
|
2009-06-24 20:04:16 +01:00
|
|
|
#else
|
2010-04-15 01:09:59 +01:00
|
|
|
Yap_Error(INTERNAL_ERROR, TermNil, "trie_do_appl_in_pair: invalid instruction");
|
|
|
|
#endif /* TRIE_COMPACT_PAIRS && ! GLOBAL_TRIE */
|
2009-06-24 20:04:16 +01:00
|
|
|
ENDPBOp();
|
|
|
|
|
|
|
|
|
2010-04-15 01:09:59 +01:00
|
|
|
PBOp(trie_trust_appl_in_pair, e)
|
|
|
|
#ifdef TRIE_COMPACT_PAIRS
|
2009-06-24 20:04:16 +01:00
|
|
|
register ans_node_ptr node = (ans_node_ptr) PREG;
|
2010-04-15 01:09:59 +01:00
|
|
|
register CELL *aux_stack = (CELL *) (B + 1);
|
|
|
|
int heap_arity = aux_stack[HEAP_ARITY_ENTRY];
|
|
|
|
int vars_arity = aux_stack[VARS_ARITY_ENTRY];
|
|
|
|
int subs_arity = aux_stack[SUBS_ARITY_ENTRY];
|
2009-06-24 20:04:16 +01:00
|
|
|
Functor func = (Functor) RepAppl(TrNode_entry(node));
|
|
|
|
int func_arity = ArityOfFunctor(func);
|
|
|
|
|
|
|
|
pop_trie_node();
|
2010-04-15 01:09:59 +01:00
|
|
|
aux_stack_appl_in_pair_instr();
|
2009-06-24 20:04:16 +01:00
|
|
|
#else
|
2010-04-15 01:09:59 +01:00
|
|
|
Yap_Error(INTERNAL_ERROR, TermNil, "trie_trust_appl_in_pair: invalid instruction");
|
|
|
|
#endif /* TRIE_COMPACT_PAIRS && ! GLOBAL_TRIE */
|
2009-06-24 20:04:16 +01:00
|
|
|
ENDPBOp();
|
|
|
|
|
|
|
|
|
2010-04-15 01:09:59 +01:00
|
|
|
PBOp(trie_try_appl_in_pair, e)
|
|
|
|
#ifdef TRIE_COMPACT_PAIRS
|
2009-06-24 20:04:16 +01:00
|
|
|
register ans_node_ptr node = (ans_node_ptr) PREG;
|
2010-04-15 01:09:59 +01:00
|
|
|
register CELL *aux_stack = TOP_STACK;
|
|
|
|
int heap_arity = aux_stack[HEAP_ARITY_ENTRY];
|
|
|
|
int vars_arity = aux_stack[VARS_ARITY_ENTRY];
|
|
|
|
int subs_arity = aux_stack[SUBS_ARITY_ENTRY];
|
2009-06-24 20:04:16 +01:00
|
|
|
Functor func = (Functor) RepAppl(TrNode_entry(node));
|
|
|
|
int func_arity = ArityOfFunctor(func);
|
|
|
|
|
|
|
|
store_trie_node(TrNode_next(node));
|
2010-04-15 01:09:59 +01:00
|
|
|
aux_stack_appl_in_pair_instr();
|
2009-06-24 20:04:16 +01:00
|
|
|
#else
|
2010-04-15 01:09:59 +01:00
|
|
|
Yap_Error(INTERNAL_ERROR, TermNil, "trie_try_appl_in_pair: invalid instruction");
|
|
|
|
#endif /* TRIE_COMPACT_PAIRS && ! GLOBAL_TRIE */
|
2009-06-24 20:04:16 +01:00
|
|
|
ENDPBOp();
|
|
|
|
|
|
|
|
|
2010-04-15 01:09:59 +01:00
|
|
|
PBOp(trie_retry_appl_in_pair, e)
|
|
|
|
#ifdef TRIE_COMPACT_PAIRS
|
2009-06-24 20:04:16 +01:00
|
|
|
register ans_node_ptr node = (ans_node_ptr) PREG;
|
2010-04-15 01:09:59 +01:00
|
|
|
register CELL *aux_stack = (CELL *) (B + 1);
|
|
|
|
int heap_arity = aux_stack[HEAP_ARITY_ENTRY];
|
|
|
|
int vars_arity = aux_stack[VARS_ARITY_ENTRY];
|
|
|
|
int subs_arity = aux_stack[SUBS_ARITY_ENTRY];
|
2009-06-24 20:04:16 +01:00
|
|
|
Functor func = (Functor) RepAppl(TrNode_entry(node));
|
|
|
|
int func_arity = ArityOfFunctor(func);
|
|
|
|
|
|
|
|
restore_trie_node(TrNode_next(node));
|
2010-04-15 01:09:59 +01:00
|
|
|
aux_stack_appl_in_pair_instr();
|
2009-06-24 20:04:16 +01:00
|
|
|
#else
|
2010-04-15 01:09:59 +01:00
|
|
|
Yap_Error(INTERNAL_ERROR, TermNil, "trie_retry_appl_in_pair: invalid instruction");
|
|
|
|
#endif /* TRIE_COMPACT_PAIRS && ! GLOBAL_TRIE */
|
2009-06-24 20:04:16 +01:00
|
|
|
ENDPBOp();
|
|
|
|
|
|
|
|
|
2008-09-05 18:34:26 +01:00
|
|
|
PBOp(trie_do_extension, e)
|
2005-07-06 20:34:12 +01:00
|
|
|
register ans_node_ptr node = (ans_node_ptr) PREG;
|
2010-04-15 01:09:59 +01:00
|
|
|
register CELL *aux_stack = TOP_STACK;
|
|
|
|
int heap_arity = aux_stack[HEAP_ARITY_ENTRY];
|
2005-07-06 20:34:12 +01:00
|
|
|
|
2010-04-15 01:09:59 +01:00
|
|
|
aux_stack_extension_instr();
|
2005-07-06 20:34:12 +01:00
|
|
|
ENDPBOp();
|
|
|
|
|
|
|
|
|
|
|
|
PBOp(trie_trust_extension, e)
|
|
|
|
register ans_node_ptr node = (ans_node_ptr) PREG;
|
2010-04-15 01:09:59 +01:00
|
|
|
register CELL *aux_stack = (CELL *) (B + 1);
|
|
|
|
int heap_arity = aux_stack[HEAP_ARITY_ENTRY];
|
|
|
|
int vars_arity = aux_stack[VARS_ARITY_ENTRY];
|
|
|
|
int subs_arity = aux_stack[SUBS_ARITY_ENTRY];
|
2009-06-24 20:04:16 +01:00
|
|
|
|
|
|
|
pop_trie_node();
|
2010-04-15 01:09:59 +01:00
|
|
|
aux_stack_extension_instr();
|
2005-07-06 20:34:12 +01:00
|
|
|
ENDPBOp();
|
|
|
|
|
|
|
|
|
2008-09-05 18:34:26 +01:00
|
|
|
PBOp(trie_try_extension, e)
|
|
|
|
register ans_node_ptr node = (ans_node_ptr) PREG;
|
2010-04-15 01:09:59 +01:00
|
|
|
register CELL *aux_stack = TOP_STACK;
|
|
|
|
int heap_arity = aux_stack[HEAP_ARITY_ENTRY];
|
|
|
|
int vars_arity = aux_stack[VARS_ARITY_ENTRY];
|
|
|
|
int subs_arity = aux_stack[SUBS_ARITY_ENTRY];
|
2008-09-05 18:34:26 +01:00
|
|
|
|
|
|
|
store_trie_node(TrNode_next(node));
|
2010-04-15 01:09:59 +01:00
|
|
|
aux_stack_extension_instr();
|
2008-09-05 18:34:26 +01:00
|
|
|
ENDPBOp();
|
|
|
|
|
|
|
|
|
|
|
|
PBOp(trie_retry_extension, e)
|
|
|
|
register ans_node_ptr node = (ans_node_ptr) PREG;
|
2010-04-15 01:09:59 +01:00
|
|
|
register CELL *aux_stack = (CELL *) (B + 1);
|
|
|
|
int heap_arity = aux_stack[HEAP_ARITY_ENTRY];
|
|
|
|
int vars_arity = aux_stack[VARS_ARITY_ENTRY];
|
|
|
|
int subs_arity = aux_stack[SUBS_ARITY_ENTRY];
|
2008-09-05 18:34:26 +01:00
|
|
|
|
|
|
|
restore_trie_node(TrNode_next(node));
|
2010-04-15 01:09:59 +01:00
|
|
|
aux_stack_extension_instr();
|
2008-09-05 18:34:26 +01:00
|
|
|
ENDPBOp();
|
|
|
|
|
|
|
|
|
2010-04-15 01:09:59 +01:00
|
|
|
PBOp(trie_do_double, e)
|
2005-06-03 09:19:18 +01:00
|
|
|
register ans_node_ptr node = (ans_node_ptr) PREG;
|
2010-04-15 01:09:59 +01:00
|
|
|
register CELL *aux_stack = TOP_STACK;
|
|
|
|
int heap_arity = aux_stack[HEAP_ARITY_ENTRY];
|
|
|
|
int vars_arity = aux_stack[VARS_ARITY_ENTRY];
|
|
|
|
int subs_arity = aux_stack[SUBS_ARITY_ENTRY];
|
2005-06-03 09:19:18 +01:00
|
|
|
volatile Float dbl;
|
|
|
|
volatile Term *t_dbl = (Term *)((void *) &dbl);
|
2009-07-05 05:14:08 +01:00
|
|
|
Term t;
|
2009-06-17 17:14:16 +01:00
|
|
|
|
2007-04-26 15:13:21 +01:00
|
|
|
#if SIZEOF_DOUBLE == 2 * SIZEOF_INT_P
|
2010-04-15 01:09:59 +01:00
|
|
|
t_dbl[0] = aux_stack[HEAP_ENTRY(1)];
|
|
|
|
t_dbl[1] = aux_stack[HEAP_ENTRY(3)]; /* jump the first extension mark */
|
2009-08-07 04:34:48 +01:00
|
|
|
heap_arity -= 4;
|
2010-04-15 01:09:59 +01:00
|
|
|
TOP_STACK = aux_stack = &aux_stack[4]; /* jump until the second extension mark */
|
2007-04-26 15:13:21 +01:00
|
|
|
#else /* SIZEOF_DOUBLE == SIZEOF_INT_P */
|
2010-04-15 01:09:59 +01:00
|
|
|
t_dbl[0] = aux_stack[HEAP_ENTRY(1)];
|
2009-08-07 04:34:48 +01:00
|
|
|
heap_arity -= 2;
|
2010-04-15 01:09:59 +01:00
|
|
|
TOP_STACK = aux_stack = &aux_stack[2]; /* jump until the extension mark */
|
2007-04-26 15:13:21 +01:00
|
|
|
#endif /* SIZEOF_DOUBLE x SIZEOF_INT_P */
|
2010-04-15 01:09:59 +01:00
|
|
|
TOP_STACK[HEAP_ARITY_ENTRY] = heap_arity;
|
2005-06-03 09:19:18 +01:00
|
|
|
t = MkFloatTerm(dbl);
|
2010-04-15 01:09:59 +01:00
|
|
|
aux_stack_term_instr();
|
2005-06-03 09:19:18 +01:00
|
|
|
ENDPBOp();
|
|
|
|
|
|
|
|
|
2010-04-15 01:09:59 +01:00
|
|
|
BOp(trie_trust_double, e)
|
|
|
|
Yap_Error(INTERNAL_ERROR, TermNil, "trie_trust_double: invalid instruction");
|
2008-09-05 18:34:26 +01:00
|
|
|
ENDBOp();
|
|
|
|
|
|
|
|
|
2010-04-15 01:09:59 +01:00
|
|
|
BOp(trie_try_double, e)
|
|
|
|
Yap_Error(INTERNAL_ERROR, TermNil, "trie_try_double: invalid instruction");
|
2006-01-17 14:10:42 +00:00
|
|
|
ENDBOp();
|
2005-06-03 09:19:18 +01:00
|
|
|
|
|
|
|
|
2010-04-15 01:09:59 +01:00
|
|
|
BOp(trie_retry_double, e)
|
|
|
|
Yap_Error(INTERNAL_ERROR, TermNil, "trie_retry_double: invalid instruction");
|
2006-01-17 14:10:42 +00:00
|
|
|
ENDBOp();
|
2005-06-03 09:19:18 +01:00
|
|
|
|
|
|
|
|
2010-04-15 01:09:59 +01:00
|
|
|
PBOp(trie_do_longint, e)
|
2005-06-04 08:28:24 +01:00
|
|
|
register ans_node_ptr node = (ans_node_ptr) PREG;
|
2010-04-15 01:09:59 +01:00
|
|
|
register CELL *aux_stack = TOP_STACK;
|
|
|
|
int heap_arity = aux_stack[HEAP_ARITY_ENTRY];
|
|
|
|
int vars_arity = aux_stack[VARS_ARITY_ENTRY];
|
|
|
|
int subs_arity = aux_stack[SUBS_ARITY_ENTRY];
|
|
|
|
Term t = MkLongIntTerm(aux_stack[HEAP_ENTRY(1)]);
|
2009-06-17 17:14:16 +01:00
|
|
|
|
2009-08-07 04:34:48 +01:00
|
|
|
heap_arity -= 2;
|
2010-04-15 01:09:59 +01:00
|
|
|
TOP_STACK = aux_stack = &aux_stack[2]; /* jump until the extension mark */
|
|
|
|
TOP_STACK[HEAP_ARITY_ENTRY] = heap_arity;
|
|
|
|
aux_stack_term_instr();
|
2005-06-04 08:28:24 +01:00
|
|
|
ENDPBOp();
|
|
|
|
|
2009-06-17 17:14:16 +01:00
|
|
|
|
2010-04-15 01:09:59 +01:00
|
|
|
BOp(trie_trust_longint, e)
|
|
|
|
Yap_Error(INTERNAL_ERROR, TermNil, "trie_trust_longint: invalid instruction");
|
2008-09-05 18:34:26 +01:00
|
|
|
ENDBOp();
|
2005-06-04 08:28:24 +01:00
|
|
|
|
2009-06-17 17:14:16 +01:00
|
|
|
|
2010-04-15 01:09:59 +01:00
|
|
|
BOp(trie_try_longint, e)
|
|
|
|
Yap_Error(INTERNAL_ERROR, TermNil, "trie_try_longint: invalid instruction");
|
2006-01-17 14:10:42 +00:00
|
|
|
ENDBOp();
|
2005-06-04 08:28:24 +01:00
|
|
|
|
|
|
|
|
2010-04-15 01:09:59 +01:00
|
|
|
BOp(trie_retry_longint, e)
|
|
|
|
Yap_Error(INTERNAL_ERROR, TermNil, "trie_retry_longint: invalid instruction");
|
2006-01-17 14:10:42 +00:00
|
|
|
ENDBOp();
|
2010-04-15 01:09:59 +01:00
|
|
|
|
|
|
|
|
|
|
|
PBOp(trie_do_gterm, e)
|
|
|
|
#ifdef GLOBAL_TRIE
|
|
|
|
register ans_node_ptr node = (ans_node_ptr) PREG;
|
|
|
|
register CELL *aux_stack = TOP_STACK;
|
|
|
|
int heap_arity = 0;
|
|
|
|
int vars_arity = aux_stack[VARS_ARITY_ENTRY];
|
|
|
|
int subs_arity = aux_stack[SUBS_ARITY_ENTRY];
|
|
|
|
|
|
|
|
TOP_STACK = exec_substitution((gt_node_ptr)TrNode_entry(node), aux_stack);
|
|
|
|
next_instruction(subs_arity - 1 , node);
|
|
|
|
#else
|
|
|
|
Yap_Error(INTERNAL_ERROR, TermNil, "trie_do_gterm: invalid instruction");
|
|
|
|
#endif /* GLOBAL_TRIE */
|
|
|
|
ENDPBOp();
|
|
|
|
|
|
|
|
|
|
|
|
PBOp(trie_trust_gterm, e)
|
|
|
|
#ifdef GLOBAL_TRIE
|
|
|
|
register ans_node_ptr node = (ans_node_ptr) PREG;
|
|
|
|
register CELL *aux_stack = (CELL *) (B + 1);
|
|
|
|
int heap_arity = 0;
|
|
|
|
int vars_arity = aux_stack[VARS_ARITY_ENTRY];
|
|
|
|
int subs_arity = aux_stack[SUBS_ARITY_ENTRY];
|
|
|
|
|
|
|
|
pop_trie_node();
|
|
|
|
TOP_STACK = exec_substitution((gt_node_ptr)TrNode_entry(node), aux_stack);
|
|
|
|
next_instruction(subs_arity - 1 , node);
|
|
|
|
#else
|
|
|
|
Yap_Error(INTERNAL_ERROR, TermNil, "trie_trust_gterm: invalid instruction");
|
|
|
|
#endif /* GLOBAL_TRIE */
|
|
|
|
ENDPBOp();
|
|
|
|
|
|
|
|
|
|
|
|
PBOp(trie_try_gterm, e)
|
|
|
|
#ifdef GLOBAL_TRIE
|
|
|
|
register ans_node_ptr node = (ans_node_ptr) PREG;
|
|
|
|
register CELL *aux_stack = TOP_STACK;
|
|
|
|
int heap_arity = 0;
|
|
|
|
int vars_arity = aux_stack[VARS_ARITY_ENTRY];
|
|
|
|
int subs_arity = aux_stack[SUBS_ARITY_ENTRY];
|
|
|
|
|
|
|
|
store_trie_node(TrNode_next(node));
|
|
|
|
TOP_STACK = exec_substitution((gt_node_ptr)TrNode_entry(node), aux_stack);
|
|
|
|
next_instruction(subs_arity - 1, node);
|
|
|
|
#else
|
|
|
|
Yap_Error(INTERNAL_ERROR, TermNil, "trie_try_gterm: invalid instruction");
|
|
|
|
#endif /* GLOBAL_TRIE */
|
|
|
|
ENDPBOp();
|
|
|
|
|
|
|
|
|
|
|
|
PBOp(trie_retry_gterm, e)
|
|
|
|
#ifdef GLOBAL_TRIE
|
|
|
|
register ans_node_ptr node = (ans_node_ptr) PREG;
|
|
|
|
register CELL *aux_stack = (CELL *) (B + 1);
|
|
|
|
int heap_arity = 0;
|
|
|
|
int vars_arity = aux_stack[VARS_ARITY_ENTRY];
|
|
|
|
int subs_arity = aux_stack[SUBS_ARITY_ENTRY];
|
|
|
|
|
|
|
|
restore_trie_node(TrNode_next(node));
|
|
|
|
TOP_STACK = exec_substitution((gt_node_ptr)TrNode_entry(node), aux_stack);
|
|
|
|
next_instruction(subs_arity - 1, node);
|
|
|
|
#else
|
|
|
|
Yap_Error(INTERNAL_ERROR, TermNil, "trie_retry_gterm: invalid instruction");
|
|
|
|
#endif /* GLOBAL_TRIE */
|
|
|
|
ENDPBOp();
|