Removed another straightforward trampoline with one nested call only.

This commit is contained in:
Cas Cremers 2018-11-04 23:06:24 +01:00
parent 92c5b0bedc
commit 131ee69f1d
4 changed files with 61 additions and 55 deletions

View File

@ -2,7 +2,6 @@
1 subtermUnify arachne.c +961 1 subtermUnify arachne.c +961
1 term_iterate_open_leaves dotout.c +1790 // Could be replaced by term_iterate_leaves 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 3 unify mgu.c +233 ; mgu.c +247 ; mgu.c +281
1 iterateLocalToOther prune_theorems.c +108
term_iterate_leaves term_iterate_leaves
term_iterate_state_leaves term_iterate_state_leaves
@ -13,5 +12,4 @@ iterateTermOther is called using makeDepend and addOther
subtermUnify is called using unifiesWithKeys subtermUnify is called using unifiesWithKeys
term_iterate_open_leaves is called using addsubterms 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) 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

View File

@ -41,17 +41,9 @@ extern Protocol INTRUDER;
extern int proofDepth; extern int proofDepth;
extern int max_encryption_level; extern int max_encryption_level;
//! checkTerm is a helper for the next function
//! Check locals occurrence
/*
* Returns true if the order is correct
*/
int int
correctLocalOrder (const System sys) checkTerm (const System sys, const Term t, const int r1)
{
int r1;
int checkTerm (Term t)
{ {
if (!isTermVariable (t)) if (!isTermVariable (t))
{ {
@ -101,6 +93,16 @@ correctLocalOrder (const System sys)
return true; return true;
} }
//! Check locals occurrence
/*
* Returns true if the order is correct
*/
int
correctLocalOrder (const System sys)
{
int r1;
for (r1 = 0; r1 < sys->maxruns; r1++) for (r1 = 0; r1 < sys->maxruns; r1++)
{ {
if (sys->runs[r1].protocol != INTRUDER) if (sys->runs[r1].protocol != INTRUDER)

View File

@ -1129,9 +1129,14 @@ iterateEventsType (const System sys, const int run, const int evtype,
} }
// Iterate over all 'others': local variables of a run that are instantiated and contain some term of another run. // Iterate over all 'others': local variables of a run that are instantiated and contain some term of another run.
/**
* Now incorporates "checkterm" required argument of myrun to the callback:
*
* It's now callback(conts Term,const int);
*/
int int
iterateLocalToOther (const System sys, const int myrun, iterateLocalToOther (const System sys, const int myrun,
int (*callback) (Term tlocal)) int (*callback) (const System, const Term, const int))
{ {
Termlist tlo, tls; Termlist tlo, tls;
int flag; int flag;
@ -1158,7 +1163,7 @@ iterateLocalToOther (const System sys, const int myrun,
// now iterate over all of them // now iterate over all of them
for (tls = tlo; flag && (tls != NULL); tls = tls->next) for (tls = tlo; flag && (tls != NULL); tls = tls->next)
{ {
if (!callback (tls->term)) if (!callback (sys, tls->term, myrun))
{ {
flag = false; flag = false;
} }

View File

@ -199,7 +199,8 @@ int iterateAllEvents (const System sys,
int iterateEventsType (const System sys, const int run, const int evtype, int iterateEventsType (const System sys, const int run, const int evtype,
int (*callback) (Roledef rd, int ev)); int (*callback) (Roledef rd, int ev));
int iterateLocalToOther (const System sys, const int myrun, int iterateLocalToOther (const System sys, const int myrun,
int (*callback) (Term t)); int (*callback) (const System sys, const Term t,
const int myrun));
int iterateRoles (const System sys, int (*callback) (Protocol p, Role r)); int iterateRoles (const System sys, int (*callback) (Protocol p, Role r));
int firstOccurrence (const System sys, const int r, Term t, int evtype); int firstOccurrence (const System sys, const int r, Term t, int evtype);
Roledef eventRoledef (const System sys, const int run, const int ev); Roledef eventRoledef (const System sys, const int run, const int ev);