From ad06600bd8b9cdf1125a203c12eeccbb6fd17336 Mon Sep 17 00:00:00 2001 From: Cas Cremers Date: Fri, 19 Oct 2018 15:10:28 -0400 Subject: [PATCH] Removed a further simple trampoline. --- src/hidelevel.c | 40 +++++++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/src/hidelevel.c b/src/hidelevel.c index 8b4c63f..85eefba 100644 --- a/src/hidelevel.c +++ b/src/hidelevel.c @@ -31,15 +31,15 @@ extern Term TERM_Hidden; -//! hide level within protocol +//! Helper for HideLevel unsigned int -protocolHidelevel (const System sys, const Term t) +minlevel_itsends (const Protocol p, const Role r, const Term t) { + Roledef rd; unsigned int minlevel; - int itsends (const Protocol p, const Role r) - { - int sends (Roledef rd) + minlevel = UINT_MAX; + for (rd = r->roledef; rd != NULL; rd = rd->next) { if (rd->type == SEND) { @@ -55,15 +55,33 @@ protocolHidelevel (const System sys, const Term t) if (l < minlevel) minlevel = l; } - return true; } + return minlevel; +} - roledef_iterate_events (r->roledef, sends); - return true; - } +//! hide level within protocol +unsigned int +protocolHidelevel (const System sys, const Term t) +{ + unsigned int minlevel; + Protocol p; - minlevel = INT_MAX; - iterateRoles (sys, itsends); + minlevel = UINT_MAX; + for (p = sys->protocols; p != NULL; p = p->next) + { + Role r; + + for (r = p->roles; r != NULL; r = r->next) + { + unsigned int ml; + + ml = minlevel_itsends (p, r, t); + if (ml < minlevel) + { + minlevel = ml; + } + } + } return minlevel; }