Removed trampoline for keycallback in subtermunify.

This commit is contained in:
Cas Cremers 2018-12-24 14:10:47 +01:00
parent d81a138040
commit 499b4f8987

View File

@ -287,6 +287,22 @@ unify (Term t1, Term t2, Termlist tl, int (*callback) (), void *state)
} }
/**
* State for subterm unification call into keycallback
*/
struct su_kcb_state
{
int (*callback) (Termlist, Termlist);
Termlist keylist;
};
int
keycallback (Termlist tl, struct su_kcb_state *ptr_kcb_state)
{
assert (ptr_kcb_state != NULL);
return ptr_kcb_state->callback (tl, ptr_kcb_state->keylist);
}
//! Subterm unification //! Subterm unification
/** /**
* Try to unify (a subterm of) tbig with tsmall. * Try to unify (a subterm of) tbig with tsmall.
@ -307,11 +323,10 @@ subtermUnify (Term tbig, Term tsmall, Termlist tl, Termlist keylist,
int (*callback) (Termlist, Termlist)) int (*callback) (Termlist, Termlist))
{ {
int proceed; int proceed;
struct su_kcb_state kcb_state;
int keycallback (Termlist tl) kcb_state.callback = callback;
{ kcb_state.keylist = keylist;
return callback (tl, keylist);
}
proceed = true; proceed = true;
@ -321,7 +336,7 @@ subtermUnify (Term tbig, Term tsmall, Termlist tl, Termlist keylist,
// Three options: // Three options:
// 1. simple unification // 1. simple unification
proceed = proceed && unify (tbig, tsmall, tl, keycallback, NULL); proceed = proceed && unify (tbig, tsmall, tl, keycallback, &kcb_state);
// [2/3]: complex // [2/3]: complex
if (switches.intruder) if (switches.intruder)