diff --git a/src/TODO-trampolines.txt b/src/TODO-trampolines.txt index 24844d9..e34f389 100644 --- a/src/TODO-trampolines.txt +++ b/src/TODO-trampolines.txt @@ -3,7 +3,6 @@ 1 term_iterate_open_leaves dotout.c +1790 // Could be replaced by term_iterate_leaves 3 unify mgu.c +233 ; mgu.c +247 ; mgu.c +281 1 iterateLocalToOther prune_theorems.c +108 -1 term_iterate_leaves term.c +1145 term_iterate_leaves term_iterate_state_leaves @@ -15,5 +14,4 @@ subtermUnify is called using unifiesWithKeys term_iterate_open_leaves is called using addsubterms unify is called using unify_combine_enc and unify_combined_tup, and a callback using the keys list? (which propagates back to subtermunify data) iterateLocalToOther is called using checkTerm -term_iterate_leaves is called using testleaf diff --git a/src/term.c b/src/term.c index cbbe101..c7e09fb 100644 --- a/src/term.c +++ b/src/term.c @@ -1148,47 +1148,34 @@ term_iterate_state_leaves (const Term term, int (*func) (), void (*state)) * well. It is up to func to decide wether or not to recurse. */ int -term_iterate_leaves (const Term term, int (*func) (Term t)) +term_iterate_open_leaves (const Term term, int (*func) (Term t)) { if (term != NULL) { if (realTermLeaf (term)) { - if (!func (term)) - return 0; + if (substVar (term)) + { + return term_iterate_open_leaves (term->subst, func); + } + else + { + return func (term); + } } else { if (realTermTuple (term)) - return (term_iterate_leaves (TermOp1 (term), func) - && term_iterate_leaves (TermOp2 (term), func)); + return (term_iterate_open_leaves (TermOp1 (term), func) + && term_iterate_open_leaves (TermOp2 (term), func)); else - return (term_iterate_leaves (TermOp (term), func) - && term_iterate_leaves (TermKey (term), func)); + return (term_iterate_open_leaves (TermOp (term), func) + && term_iterate_open_leaves (TermKey (term), func)); } } return 1; } -//! Iterate over open leaves (i.e. respect variable closure) -int -term_iterate_open_leaves (const Term term, int (*func) (Term t)) -{ - int testleaf (const Term t) - { - if (substVar (t)) - { - return term_iterate_open_leaves (t->subst, func); - } - else - { - return func (t); - } - } - - return term_iterate_leaves (term, testleaf); -} - //! Turn all rolelocals into variables void term_rolelocals_are_variables () diff --git a/src/term.h b/src/term.h index 7a537d2..6d0f53c 100644 --- a/src/term.h +++ b/src/term.h @@ -198,7 +198,6 @@ int term_iterate_state_deVar (Term term, int (*leaf) (), int (*nodel) (), int (*nodem) (), int (*noder) (), void (*state)); -int term_iterate_leaves (const Term t, int (*func) (Term t)); int term_iterate_state_leaves (const Term term, int (*func) (), void (*state)); int term_iterate_open_leaves (const Term term, int (*func) (Term t));