Created initial stateful version of deVar iteration.
This commit is contained in:
parent
596d5dc528
commit
fb3b13f4e3
@ -1,4 +1,4 @@
|
||||
2 iterateTermOther arachne.c +1010 ; system.c +1139
|
||||
2 iterateTermOther arachne.c +1053 ; system.c +1155
|
||||
1 subtermUnify arachne.c +961
|
||||
1 term_iterate_open_leaves dotout.c +1790 // Could be replaced by term_iterate_leaves
|
||||
1 term_iterate_deVar heuristic.c +224
|
||||
@ -6,3 +6,6 @@
|
||||
1 iterateLocalToOther prune_theorems.c +54
|
||||
1 term_iterate_leaves term.c +1145
|
||||
1 term_iterate_deVar term.c +1544
|
||||
|
||||
term_iterate_deVar
|
||||
term_iterate_state_deVar
|
||||
|
69
src/term.c
69
src/term.c
@ -1110,6 +1110,75 @@ term_iterate_deVar (Term term, int (*leaf) (Term t), int (*nodel) (Term t),
|
||||
return true;
|
||||
}
|
||||
|
||||
//! Generic term iteration with state
|
||||
int
|
||||
term_iterate_state_deVar (Term term, int (*leaf) (Term t, void (*st)),
|
||||
int (*nodel) (Term t, void (*state)),
|
||||
int (*nodem) (Term t, void (*st)),
|
||||
int (*noder) (Term t, void (*st)), void (*state))
|
||||
{
|
||||
term = deVar (term);
|
||||
if (term != NULL)
|
||||
{
|
||||
if (realTermLeaf (term))
|
||||
{
|
||||
// Leaf
|
||||
if (leaf != NULL)
|
||||
{
|
||||
return leaf (term, state);
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int flag;
|
||||
|
||||
flag = true;
|
||||
|
||||
if (nodel != NULL)
|
||||
flag = flag && nodel (term, state);
|
||||
|
||||
// Left part
|
||||
if (realTermTuple (term))
|
||||
flag = flag
|
||||
&&
|
||||
(term_iterate_state_deVar
|
||||
(TermOp1 (term), leaf, nodel, nodem, noder, state));
|
||||
else
|
||||
flag = flag
|
||||
&&
|
||||
(term_iterate_state_deVar
|
||||
(TermOp (term), leaf, nodel, nodem, noder, state));
|
||||
|
||||
// Center
|
||||
|
||||
if (nodem != NULL)
|
||||
flag = flag && nodem (term, state);
|
||||
|
||||
// right part
|
||||
if (realTermTuple (term))
|
||||
flag = flag
|
||||
&&
|
||||
(term_iterate_state_deVar
|
||||
(TermOp2 (term), leaf, nodel, nodem, noder, state));
|
||||
else
|
||||
flag = flag
|
||||
&&
|
||||
(term_iterate_state_deVar
|
||||
(TermKey (term), leaf, nodel, nodem, noder, state));
|
||||
|
||||
if (noder != NULL)
|
||||
flag = flag && noder (term, state);
|
||||
|
||||
return flag;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//! Iterate over the leaves in a term
|
||||
/**
|
||||
* Note that this function iterates over real leaves; thus closed variables can occur as
|
||||
|
@ -197,6 +197,11 @@ int term_iterate (const Term term, int (*leaf) (Term t),
|
||||
int term_iterate_deVar (Term term, int (*leaf) (Term t),
|
||||
int (*nodel) (Term t), int (*nodem) (Term t),
|
||||
int (*noder) (Term t));
|
||||
int term_iterate_state_deVar (Term term, int (*leaf) (Term t, void (*st)),
|
||||
int (*nodel) (Term t, void (*state)),
|
||||
int (*nodem) (Term t, void (*st)),
|
||||
int (*noder) (Term t, void (*st)),
|
||||
void (*state));
|
||||
int term_iterate_leaves (const Term t, int (*func) (Term t));
|
||||
int term_iterate_open_leaves (const Term term, int (*func) (Term t));
|
||||
void term_rolelocals_are_variables ();
|
||||
|
Loading…
Reference in New Issue
Block a user