From 92c5b0bedcd2490a0bd861494254860b2c463547 Mon Sep 17 00:00:00 2001 From: Cas Cremers Date: Wed, 31 Oct 2018 23:48:45 +0100 Subject: [PATCH] Removed term_iterate_leaves. --- src/TODO-trampolines.txt | 2 -- src/term.c | 39 +++++++++++++-------------------------- src/term.h | 1 - 3 files changed, 13 insertions(+), 29 deletions(-) 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));