Removing a collection of fairly simple remaining nested function calls.
This commit is contained in:
parent
d25445538e
commit
d4ec0004d6
@ -300,27 +300,16 @@ goal_remove_last (int n)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Determine whether some label set is ordered w.r.t. send/recv order.
|
//! Get index of run
|
||||||
/**
|
|
||||||
* Assumes all these labels exist in the system, within length etc, and that the run mappings are valid.
|
|
||||||
*/
|
|
||||||
int
|
int
|
||||||
labels_ordered (Termmap runs, Termlist labels)
|
get_index (const int run, const Term label)
|
||||||
{
|
|
||||||
while (labels != NULL)
|
|
||||||
{
|
|
||||||
// Given this label, and the mapping of runs, we want to know if the order is okay. Thus, we need to know sendrole and recvrole
|
|
||||||
Labelinfo linfo;
|
|
||||||
int send_run, send_ev, recv_run, recv_ev;
|
|
||||||
|
|
||||||
int get_index (const int run)
|
|
||||||
{
|
{
|
||||||
Roledef rd;
|
Roledef rd;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
rd = sys->runs[run].start;
|
rd = sys->runs[run].start;
|
||||||
while (rd != NULL && !isTermEqual (rd->label, labels->term))
|
while (rd != NULL && !isTermEqual (rd->label, label))
|
||||||
{
|
{
|
||||||
rd = rd->next;
|
rd = rd->next;
|
||||||
i++;
|
i++;
|
||||||
@ -333,13 +322,28 @@ labels_ordered (Termmap runs, Termlist labels)
|
|||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
linfo = label_find (sys->labellist, labels->term);
|
//! Determine whether some label set is ordered w.r.t. send/recv order.
|
||||||
|
/**
|
||||||
|
* Assumes all these labels exist in the system, within length etc, and that the run mappings are valid.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
labels_ordered (Termmap runs, Termlist labels)
|
||||||
|
{
|
||||||
|
while (labels != NULL)
|
||||||
|
{
|
||||||
|
// Given this label, and the mapping of runs, we want to know if the order is okay. Thus, we need to know sendrole and recvrole
|
||||||
|
Labelinfo linfo;
|
||||||
|
int send_run, send_ev, recv_run, recv_ev;
|
||||||
|
Term label;
|
||||||
|
|
||||||
|
label = labels->term;
|
||||||
|
linfo = label_find (sys->labellist, label);
|
||||||
if (!linfo->ignore)
|
if (!linfo->ignore)
|
||||||
{
|
{
|
||||||
send_run = termmapGet (runs, linfo->sendrole);
|
send_run = termmapGet (runs, linfo->sendrole);
|
||||||
recv_run = termmapGet (runs, linfo->recvrole);
|
recv_run = termmapGet (runs, linfo->recvrole);
|
||||||
send_ev = get_index (send_run);
|
send_ev = get_index (send_run, label);
|
||||||
recv_ev = get_index (recv_run);
|
recv_ev = get_index (recv_run, label);
|
||||||
if (!isDependEvent (send_run, send_ev, recv_run, recv_ev))
|
if (!isDependEvent (send_run, send_ev, recv_run, recv_ev))
|
||||||
{
|
{
|
||||||
// Not ordered; false
|
// Not ordered; false
|
||||||
|
63
src/claim.c
63
src/claim.c
@ -514,34 +514,10 @@ check_claim_niagree (const System sys, const int i)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Get label event
|
||||||
|
Roledef
|
||||||
//! Check generic agree claim for a given set of runs, arachne style
|
get_label_event (const System sys, const Labelinfo linfo, const Term role,
|
||||||
int
|
const Term label, const Termmap runs)
|
||||||
arachne_runs_agree (const System sys, const Claimlist cl, const Termmap runs)
|
|
||||||
{
|
|
||||||
Termlist labels;
|
|
||||||
int flag;
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
|
||||||
if (DEBUGL (5))
|
|
||||||
{
|
|
||||||
eprintf ("Checking runs agreement for Arachne.\n");
|
|
||||||
termmapPrint (runs);
|
|
||||||
eprintf ("\n");
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
flag = 1;
|
|
||||||
labels = cl->prec;
|
|
||||||
while (flag && labels != NULL)
|
|
||||||
{
|
|
||||||
// For each label, check whether it matches. Maybe a bit too strict (what about variables?)
|
|
||||||
// Locate roledefs for recv & send, and check whether they are before step
|
|
||||||
Roledef rd_send, rd_recv;
|
|
||||||
Labelinfo linfo;
|
|
||||||
|
|
||||||
Roledef get_label_event (const Term role, const Term label)
|
|
||||||
{
|
{
|
||||||
Roledef rd, rd_res;
|
Roledef rd, rd_res;
|
||||||
int i;
|
int i;
|
||||||
@ -592,12 +568,39 @@ arachne_runs_agree (const System sys, const Claimlist cl, const Termmap runs)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Check generic agree claim for a given set of runs, arachne style
|
||||||
|
int
|
||||||
|
arachne_runs_agree (const System sys, const Claimlist cl, const Termmap runs)
|
||||||
|
{
|
||||||
|
Termlist labels;
|
||||||
|
int flag;
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
if (DEBUGL (5))
|
||||||
|
{
|
||||||
|
eprintf ("Checking runs agreement for Arachne.\n");
|
||||||
|
termmapPrint (runs);
|
||||||
|
eprintf ("\n");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
flag = 1;
|
||||||
|
labels = cl->prec;
|
||||||
|
while (flag && labels != NULL)
|
||||||
|
{
|
||||||
|
// For each label, check whether it matches. Maybe a bit too strict (what about variables?)
|
||||||
|
// Locate roledefs for recv & send, and check whether they are before step
|
||||||
|
Roledef rd_send, rd_recv;
|
||||||
|
Labelinfo linfo;
|
||||||
|
|
||||||
// Main
|
// Main
|
||||||
linfo = label_find (sys->labellist, labels->term);
|
linfo = label_find (sys->labellist, labels->term);
|
||||||
if (!linfo->ignore)
|
if (!linfo->ignore)
|
||||||
{
|
{
|
||||||
rd_send = get_label_event (linfo->sendrole, labels->term);
|
rd_send =
|
||||||
rd_recv = get_label_event (linfo->recvrole, labels->term);
|
get_label_event (sys, linfo, linfo->sendrole, labels->term, runs);
|
||||||
|
rd_recv =
|
||||||
|
get_label_event (sys, linfo, linfo->recvrole, labels->term, runs);
|
||||||
|
|
||||||
if (rd_send == NULL || rd_recv == NULL)
|
if (rd_send == NULL || rd_recv == NULL)
|
||||||
{
|
{
|
||||||
|
186
src/compiler.c
186
src/compiler.c
@ -1183,12 +1183,10 @@ normalDeclaration (Tac tc)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Add all sorts of claims to this role
|
|
||||||
void
|
|
||||||
claimAddAll (const System sys, const Protocol protocol, const Role role)
|
|
||||||
{
|
|
||||||
/* first: secrecy claims for all locally declared things */
|
/* first: secrecy claims for all locally declared things */
|
||||||
void addSecrecyList (Termlist tl)
|
void
|
||||||
|
addSecrecyList (const System sys, const Protocol protocol, const Role role,
|
||||||
|
Termlist tl)
|
||||||
{
|
{
|
||||||
while (tl != NULL)
|
while (tl != NULL)
|
||||||
{
|
{
|
||||||
@ -1204,10 +1202,14 @@ claimAddAll (const System sys, const Protocol protocol, const Role role)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Add all sorts of claims to this role
|
||||||
|
void
|
||||||
|
claimAddAll (const System sys, const Protocol protocol, const Role role)
|
||||||
|
{
|
||||||
if (!isHelperProtocol (protocol))
|
if (!isHelperProtocol (protocol))
|
||||||
{
|
{
|
||||||
addSecrecyList (role->declaredconsts);
|
addSecrecyList (sys, protocol, role, role->declaredconsts);
|
||||||
addSecrecyList (role->declaredvars);
|
addSecrecyList (sys, protocol, role, role->declaredvars);
|
||||||
|
|
||||||
/* full non-injective agreement and ni-synch */
|
/* full non-injective agreement and ni-synch */
|
||||||
claimCreate (sys, protocol, role, CLAIM_Alive, NULL, NULL, -1);
|
claimCreate (sys, protocol, role, CLAIM_Alive, NULL, NULL, -1);
|
||||||
@ -1699,6 +1701,26 @@ compute_label_roles (Termlist labels)
|
|||||||
return roles;
|
return roles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This function checks whether the newrole can connect to the connectedrole, and whether they fulfil their requirements.
|
||||||
|
int
|
||||||
|
roles_test (const Termlist roles_ordered, const Termlist roles_remaining,
|
||||||
|
const Term connectedrole, const Term newrole)
|
||||||
|
{
|
||||||
|
if (inTermlist (roles_ordered, connectedrole) &&
|
||||||
|
inTermlist (roles_remaining, newrole))
|
||||||
|
{
|
||||||
|
#ifdef DEBUG
|
||||||
|
if (DEBUGL (4))
|
||||||
|
{
|
||||||
|
eprintf (" ");
|
||||||
|
termPrint (newrole);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
//! Order the label roles for a given claim
|
//! Order the label roles for a given claim
|
||||||
void
|
void
|
||||||
order_label_roles (const Claimlist cl)
|
order_label_roles (const Claimlist cl)
|
||||||
@ -1749,30 +1771,28 @@ order_label_roles (const Claimlist cl)
|
|||||||
{
|
{
|
||||||
// If it's not the same protocol, the labels can't match
|
// If it's not the same protocol, the labels can't match
|
||||||
|
|
||||||
// This function checks whether the newrole can connect to the connectedrole, and whether they fulfil their requirements.
|
if (roles_test
|
||||||
void roles_test (const Term connectedrole,
|
(roles_ordered, roles_remaining, linfo->sendrole,
|
||||||
const Term newrole)
|
linfo->recvrole))
|
||||||
{
|
{
|
||||||
if (inTermlist (roles_ordered, connectedrole) &&
|
|
||||||
inTermlist (roles_remaining, newrole))
|
|
||||||
{
|
|
||||||
#ifdef DEBUG
|
|
||||||
if (DEBUGL (4))
|
|
||||||
{
|
|
||||||
eprintf (" ");
|
|
||||||
termPrint (newrole);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
roles_ordered =
|
roles_ordered =
|
||||||
termlistAppend (roles_ordered, newrole);
|
termlistAppend (roles_ordered, linfo->recvrole);
|
||||||
roles_remaining =
|
roles_remaining =
|
||||||
termlistDelTerm (termlistFind
|
termlistDelTerm (termlistFind
|
||||||
(roles_remaining, newrole));
|
(roles_remaining,
|
||||||
|
linfo->recvrole));
|
||||||
}
|
}
|
||||||
|
if (roles_test
|
||||||
|
(roles_ordered, roles_remaining, linfo->recvrole,
|
||||||
|
linfo->sendrole))
|
||||||
|
{
|
||||||
|
roles_ordered =
|
||||||
|
termlistAppend (roles_ordered, linfo->sendrole);
|
||||||
|
roles_remaining =
|
||||||
|
termlistDelTerm (termlistFind
|
||||||
|
(roles_remaining,
|
||||||
|
linfo->sendrole));
|
||||||
}
|
}
|
||||||
|
|
||||||
roles_test (linfo->sendrole, linfo->recvrole);
|
|
||||||
roles_test (linfo->recvrole, linfo->sendrole);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1788,34 +1808,16 @@ order_label_roles (const Claimlist cl)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Compute prec() sets for each claim.
|
// Assist: compute m_index from role, lev
|
||||||
/**
|
int
|
||||||
* Generates two auxiliary structures. First, a table that contains
|
m_index (const System sys, const int r, const int lev)
|
||||||
* a mapping from all events to event/claim labels.
|
|
||||||
* A second table is used to compute the precedence order, and
|
|
||||||
* Warshall's algorithm is used to compute the transitive closure.
|
|
||||||
* Then, for each claim, the in the preceding labels occurring roles are stored,
|
|
||||||
* which is useful later.
|
|
||||||
*@returns For each claim in the claim list, a preceding label set is defined.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
compute_prec_sets (const System sys)
|
|
||||||
{
|
|
||||||
Term *eventlabels; // array: maps events to labels
|
|
||||||
unsigned int *prec; // array: maps event*event to precedence
|
|
||||||
int size; // temp constant: rolecount * roleeventmax
|
|
||||||
int rowsize;
|
|
||||||
int r1, r2, ev1, ev2; // some counters
|
|
||||||
Claimlist cl;
|
|
||||||
|
|
||||||
// Assist: compute index from role, lev
|
|
||||||
int index (int r, int lev)
|
|
||||||
{
|
{
|
||||||
return r * sys->roleeventmax + lev;
|
return r * sys->roleeventmax + lev;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Assist: yield roledef from r, lev
|
// Assist: yield roledef from r, lev
|
||||||
Roledef roledef_re (int r, int lev)
|
Roledef
|
||||||
|
roledef_re (const System sys, int r, int lev)
|
||||||
{
|
{
|
||||||
Protocol pr;
|
Protocol pr;
|
||||||
Role ro;
|
Role ro;
|
||||||
@ -1856,40 +1858,53 @@ compute_prec_sets (const System sys)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Assist: print matrix
|
//! Assist: print matrix
|
||||||
void show_matrix (void)
|
void
|
||||||
|
show_matrix (const System sys, const int rowsize, const unsigned int *prec)
|
||||||
{
|
{
|
||||||
int r1, r2, ev1, ev2;
|
int r1, r2, ev1, ev2;
|
||||||
|
|
||||||
r1 = 0;
|
for (r1 = 0; r1 < sys->rolecount; r1++)
|
||||||
while (r1 < sys->rolecount)
|
|
||||||
{
|
{
|
||||||
ev1 = 0;
|
for (ev1 = 0; ev1 < sys->roleeventmax; ev1++)
|
||||||
while (ev1 < sys->roleeventmax)
|
|
||||||
{
|
{
|
||||||
eprintf ("prec %i,%i: ", r1, ev1);
|
eprintf ("prec %i,%i: ", r1, ev1);
|
||||||
r2 = 0;
|
for (r2 = 0; r2 < sys->rolecount; r2++)
|
||||||
while (r2 < sys->rolecount)
|
|
||||||
{
|
{
|
||||||
ev2 = 0;
|
for (ev2 = 0; ev2 < sys->roleeventmax; ev2++)
|
||||||
while (ev2 < sys->roleeventmax)
|
|
||||||
{
|
{
|
||||||
eprintf ("%i ",
|
eprintf ("%i ",
|
||||||
BIT (prec + rowsize * index (r2, ev2),
|
BIT (prec + rowsize * m_index (sys, r2, ev2),
|
||||||
index (r1, ev1)));
|
m_index (sys, r1, ev1)));
|
||||||
ev2++;
|
|
||||||
}
|
}
|
||||||
eprintf (" ");
|
eprintf (" ");
|
||||||
r2++;
|
|
||||||
}
|
|
||||||
eprintf ("\n");
|
|
||||||
ev1++;
|
|
||||||
}
|
|
||||||
eprintf ("\n");
|
|
||||||
r1++;
|
|
||||||
}
|
}
|
||||||
eprintf ("\n");
|
eprintf ("\n");
|
||||||
}
|
}
|
||||||
|
eprintf ("\n");
|
||||||
|
}
|
||||||
|
eprintf ("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Compute prec() sets for each claim.
|
||||||
|
/**
|
||||||
|
* Generates two auxiliary structures. First, a table that contains
|
||||||
|
* a mapping from all events to event/claim labels.
|
||||||
|
* A second table is used to compute the precedence order, and
|
||||||
|
* Warshall's algorithm is used to compute the transitive closure.
|
||||||
|
* Then, for each claim, the in the preceding labels occurring roles are stored,
|
||||||
|
* which is useful later.
|
||||||
|
*@returns For each claim in the claim list, a preceding label set is defined.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
compute_prec_sets (const System sys)
|
||||||
|
{
|
||||||
|
Term *eventlabels; // array: maps events to labels
|
||||||
|
unsigned int *prec; // array: maps event*event to precedence
|
||||||
|
int size; // temp constant: rolecount * roleeventmax
|
||||||
|
int rowsize;
|
||||||
|
int r1, r2, ev1, ev2; // some counters
|
||||||
|
Claimlist cl;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Phase 1: Allocate structures and map to labels
|
* Phase 1: Allocate structures and map to labels
|
||||||
@ -1907,10 +1922,10 @@ compute_prec_sets (const System sys)
|
|||||||
Roledef rd;
|
Roledef rd;
|
||||||
|
|
||||||
ev1 = 0;
|
ev1 = 0;
|
||||||
rd = roledef_re (r1, ev1);
|
rd = roledef_re (sys, r1, ev1);
|
||||||
while (rd != NULL)
|
while (rd != NULL)
|
||||||
{
|
{
|
||||||
eventlabels[index (r1, ev1)] = rd->label;
|
eventlabels[m_index (sys, r1, ev1)] = rd->label;
|
||||||
//termPrint (rd->label);
|
//termPrint (rd->label);
|
||||||
//eprintf ("\t");
|
//eprintf ("\t");
|
||||||
ev1++;
|
ev1++;
|
||||||
@ -1918,7 +1933,7 @@ compute_prec_sets (const System sys)
|
|||||||
}
|
}
|
||||||
while (ev1 < sys->roleeventmax)
|
while (ev1 < sys->roleeventmax)
|
||||||
{
|
{
|
||||||
eventlabels[index (r1, ev1)] = NULL;
|
eventlabels[m_index (sys, r1, ev1)] = NULL;
|
||||||
ev1++;
|
ev1++;
|
||||||
}
|
}
|
||||||
//eprintf ("\n");
|
//eprintf ("\n");
|
||||||
@ -1931,7 +1946,8 @@ compute_prec_sets (const System sys)
|
|||||||
ev1 = 1;
|
ev1 = 1;
|
||||||
while (ev1 < (sys->roleeventmax))
|
while (ev1 < (sys->roleeventmax))
|
||||||
{
|
{
|
||||||
SETBIT (prec + rowsize * index (r1, ev1 - 1), index (r1, ev1));
|
SETBIT (prec + rowsize * m_index (sys, r1, ev1 - 1),
|
||||||
|
m_index (sys, r1, ev1));
|
||||||
ev1++;
|
ev1++;
|
||||||
}
|
}
|
||||||
r1++;
|
r1++;
|
||||||
@ -1945,7 +1961,7 @@ compute_prec_sets (const System sys)
|
|||||||
{
|
{
|
||||||
Roledef rd1;
|
Roledef rd1;
|
||||||
|
|
||||||
rd1 = roledef_re (r1, ev1);
|
rd1 = roledef_re (sys, r1, ev1);
|
||||||
if (rd1 != NULL && rd1->type == SEND)
|
if (rd1 != NULL && rd1->type == SEND)
|
||||||
{
|
{
|
||||||
r2 = 0;
|
r2 = 0;
|
||||||
@ -1956,12 +1972,12 @@ compute_prec_sets (const System sys)
|
|||||||
{
|
{
|
||||||
Roledef rd2;
|
Roledef rd2;
|
||||||
|
|
||||||
rd2 = roledef_re (r2, ev2);
|
rd2 = roledef_re (sys, r2, ev2);
|
||||||
if (rd2 != NULL && rd2->type == RECV
|
if (rd2 != NULL && rd2->type == RECV
|
||||||
&& isTermEqual (rd1->label, rd2->label))
|
&& isTermEqual (rd1->label, rd2->label))
|
||||||
{
|
{
|
||||||
SETBIT (prec + rowsize * index (r1, ev1),
|
SETBIT (prec + rowsize * m_index (sys, r1, ev1),
|
||||||
index (r2, ev2));
|
m_index (sys, r2, ev2));
|
||||||
}
|
}
|
||||||
ev2++;
|
ev2++;
|
||||||
}
|
}
|
||||||
@ -1976,7 +1992,7 @@ compute_prec_sets (const System sys)
|
|||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (DEBUGL (5))
|
if (DEBUGL (5))
|
||||||
{
|
{
|
||||||
show_matrix ();
|
show_matrix (sys, rowsize, prec);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1988,7 +2004,7 @@ compute_prec_sets (const System sys)
|
|||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (DEBUGL (5))
|
if (DEBUGL (5))
|
||||||
{
|
{
|
||||||
show_matrix ();
|
show_matrix (sys, rowsize, prec);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -2016,14 +2032,14 @@ compute_prec_sets (const System sys)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (r1 < sys->rolecount
|
while (r1 < sys->rolecount
|
||||||
&& !isTermEqual (label, eventlabels[index (r1, ev1)]));
|
&& !isTermEqual (label, eventlabels[m_index (sys, r1, ev1)]));
|
||||||
|
|
||||||
if (r1 == sys->rolecount)
|
if (r1 == sys->rolecount)
|
||||||
{
|
{
|
||||||
error
|
error
|
||||||
("Prec() setup: Could not find the event corresponding to a claim label.");
|
("Prec() setup: Could not find the event corresponding to a claim label.");
|
||||||
}
|
}
|
||||||
rd = roledef_re (r1, ev1);
|
rd = roledef_re (sys, r1, ev1);
|
||||||
if (rd->type != CLAIM)
|
if (rd->type != CLAIM)
|
||||||
{
|
{
|
||||||
error
|
error
|
||||||
@ -2039,15 +2055,15 @@ compute_prec_sets (const System sys)
|
|||||||
* Now we compute the preceding label set
|
* Now we compute the preceding label set
|
||||||
*/
|
*/
|
||||||
cl->prec = NULL; // clear first
|
cl->prec = NULL; // clear first
|
||||||
claim_index = index (r1, ev1);
|
claim_index = m_index (sys, r1, ev1);
|
||||||
r2 = 0;
|
r2 = 0;
|
||||||
while (r2 < sys->rolecount)
|
while (r2 < sys->rolecount)
|
||||||
{
|
{
|
||||||
ev2 = 0;
|
ev2 = 0;
|
||||||
rd = roledef_re (r2, ev2);
|
rd = roledef_re (sys, r2, ev2);
|
||||||
while (rd != NULL)
|
while (rd != NULL)
|
||||||
{
|
{
|
||||||
if (BIT (prec + rowsize * index (r2, ev2), claim_index))
|
if (BIT (prec + rowsize * m_index (sys, r2, ev2), claim_index))
|
||||||
{
|
{
|
||||||
// This event precedes the claim
|
// This event precedes the claim
|
||||||
|
|
||||||
@ -2118,12 +2134,12 @@ compute_prec_sets (const System sys)
|
|||||||
{
|
{
|
||||||
// if this event preceds the claim, replace the label term
|
// if this event preceds the claim, replace the label term
|
||||||
if (BIT
|
if (BIT
|
||||||
(prec + rowsize * index (r_scan, ev_scan),
|
(prec + rowsize * m_index (sys, r_scan, ev_scan),
|
||||||
claim_index))
|
claim_index))
|
||||||
{
|
{
|
||||||
Roledef rd;
|
Roledef rd;
|
||||||
|
|
||||||
rd = roledef_re (r_scan, ev_scan);
|
rd = roledef_re (sys, r_scan, ev_scan);
|
||||||
if (rd->label != NULL)
|
if (rd->label != NULL)
|
||||||
{
|
{
|
||||||
t_buf = rd->label;
|
t_buf = rd->label;
|
||||||
|
83
src/dotout.c
83
src/dotout.c
@ -263,11 +263,8 @@ redirNode (const System sys, Binding b)
|
|||||||
node (sys, b->run_to, b->ev_to);
|
node (sys, b->run_to, b->ev_to);
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Roledef draw
|
|
||||||
void
|
void
|
||||||
roledefDraw (Roledef rd)
|
optlabel (const Roledef rd)
|
||||||
{
|
|
||||||
void optlabel (void)
|
|
||||||
{
|
{
|
||||||
Term label;
|
Term label;
|
||||||
|
|
||||||
@ -283,10 +280,14 @@ roledefDraw (Roledef rd)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Roledef draw
|
||||||
|
void
|
||||||
|
roledefDraw (Roledef rd)
|
||||||
|
{
|
||||||
if (rd->type == RECV)
|
if (rd->type == RECV)
|
||||||
{
|
{
|
||||||
eprintf ("recv");
|
eprintf ("recv");
|
||||||
optlabel ();
|
optlabel (rd);
|
||||||
eprintf (" from ");
|
eprintf (" from ");
|
||||||
termPrintRemap (rd->from);
|
termPrintRemap (rd->from);
|
||||||
eprintf ("\\n");
|
eprintf ("\\n");
|
||||||
@ -295,7 +296,7 @@ roledefDraw (Roledef rd)
|
|||||||
if (rd->type == SEND)
|
if (rd->type == SEND)
|
||||||
{
|
{
|
||||||
eprintf ("send");
|
eprintf ("send");
|
||||||
optlabel ();
|
optlabel (rd);
|
||||||
eprintf (" to ");
|
eprintf (" to ");
|
||||||
termPrintRemap (rd->to);
|
termPrintRemap (rd->to);
|
||||||
eprintf ("\\n");
|
eprintf ("\\n");
|
||||||
@ -304,7 +305,7 @@ roledefDraw (Roledef rd)
|
|||||||
if (rd->type == CLAIM)
|
if (rd->type == CLAIM)
|
||||||
{
|
{
|
||||||
eprintf ("claim");
|
eprintf ("claim");
|
||||||
optlabel ();
|
optlabel (rd);
|
||||||
eprintf ("\\n");
|
eprintf ("\\n");
|
||||||
termPrintRemap (rd->to);
|
termPrintRemap (rd->to);
|
||||||
if (rd->message != NULL)
|
if (rd->message != NULL)
|
||||||
@ -348,13 +349,8 @@ hlsValue (double n1, double n2, double hue)
|
|||||||
return n1;
|
return n1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! hls to rgb conversion
|
int
|
||||||
void
|
bytedouble (double d)
|
||||||
hlsrgbreal (int *r, int *g, int *b, double h, double l, double s)
|
|
||||||
{
|
|
||||||
double m1, m2;
|
|
||||||
|
|
||||||
int bytedouble (double d)
|
|
||||||
{
|
{
|
||||||
double x;
|
double x;
|
||||||
|
|
||||||
@ -367,6 +363,12 @@ hlsrgbreal (int *r, int *g, int *b, double h, double l, double s)
|
|||||||
return (int) x;
|
return (int) x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! hls to rgb conversion
|
||||||
|
void
|
||||||
|
hlsrgbreal (int *r, int *g, int *b, double h, double l, double s)
|
||||||
|
{
|
||||||
|
double m1, m2;
|
||||||
|
|
||||||
while (h >= 360.0)
|
while (h >= 360.0)
|
||||||
h -= 360.0;
|
h -= 360.0;
|
||||||
while (h < 0)
|
while (h < 0)
|
||||||
@ -385,6 +387,12 @@ hlsrgbreal (int *r, int *g, int *b, double h, double l, double s)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double
|
||||||
|
closer (double l, double factor)
|
||||||
|
{
|
||||||
|
return l + ((1.0 - l) * factor);
|
||||||
|
}
|
||||||
|
|
||||||
//! hls to rgb conversion
|
//! hls to rgb conversion
|
||||||
/**
|
/**
|
||||||
* Secretly takes the monochrome switch into account
|
* Secretly takes the monochrome switch into account
|
||||||
@ -392,11 +400,6 @@ hlsrgbreal (int *r, int *g, int *b, double h, double l, double s)
|
|||||||
void
|
void
|
||||||
hlsrgb (int *r, int *g, int *b, double h, double l, double s)
|
hlsrgb (int *r, int *g, int *b, double h, double l, double s)
|
||||||
{
|
{
|
||||||
double closer (double l, double factor)
|
|
||||||
{
|
|
||||||
return l + ((1.0 - l) * factor);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (switches.monochrome)
|
if (switches.monochrome)
|
||||||
{
|
{
|
||||||
// No colors
|
// No colors
|
||||||
@ -432,6 +435,14 @@ printColor (double h, double l, double s)
|
|||||||
eprintf ("#%02x%02x%02x", r, g, b);
|
eprintf ("#%02x%02x%02x", r, g, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// help function: contract roleoffset, roledelta with a factor (<= 1.0)
|
||||||
|
void
|
||||||
|
contract (double roledelta, double roleoffset, double factor)
|
||||||
|
{
|
||||||
|
roledelta = roledelta * factor;
|
||||||
|
roleoffset = (roleoffset * factor) + ((1.0 - factor) / 2.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//! Set local buffer with the correct color for this run.
|
//! Set local buffer with the correct color for this run.
|
||||||
/**
|
/**
|
||||||
@ -453,13 +464,6 @@ setRunColorBuf (const System sys, int run, char *colorbuf)
|
|||||||
double h, l, s;
|
double h, l, s;
|
||||||
int r, g, b;
|
int r, g, b;
|
||||||
|
|
||||||
// help function: contract roleoffset, roledelta with a factor (<= 1.0)
|
|
||||||
void contract (double factor)
|
|
||||||
{
|
|
||||||
roledelta = roledelta * factor;
|
|
||||||
roleoffset = (roleoffset * factor) + ((1.0 - factor) / 2.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// determine #protocol, resulting in two colors
|
// determine #protocol, resulting in two colors
|
||||||
{
|
{
|
||||||
Termlist protocols;
|
Termlist protocols;
|
||||||
@ -547,12 +551,13 @@ setRunColorBuf (const System sys, int run, char *colorbuf)
|
|||||||
// Now this can result in a delta that is too high (depending on protocolrange)
|
// Now this can result in a delta that is too high (depending on protocolrange)
|
||||||
if (protrange * roledelta > RUNCOLORDELTA)
|
if (protrange * roledelta > RUNCOLORDELTA)
|
||||||
{
|
{
|
||||||
contract (RUNCOLORDELTA / (protrange * roledelta));
|
contract (roledelta, roleoffset,
|
||||||
|
RUNCOLORDELTA / (protrange * roledelta));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// We slightly contract the colors (taking them away from protocol edges)
|
// We slightly contract the colors (taking them away from protocol edges)
|
||||||
contract (RUNCOLORCONTRACT);
|
contract (roledelta, roleoffset, RUNCOLORCONTRACT);
|
||||||
|
|
||||||
// Now we can convert this to a color
|
// Now we can convert this to a color
|
||||||
color = protoffset + (protrange * roleoffset);
|
color = protoffset + (protrange * roleoffset);
|
||||||
@ -1061,13 +1066,8 @@ regularModifiedLabel (Binding b)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Draw a single binding
|
|
||||||
void
|
void
|
||||||
drawBinding (const System sys, Binding b)
|
myarrow (const System sys, const int m0_from, const Binding b)
|
||||||
{
|
|
||||||
int intr_to, intr_from, m0_from;
|
|
||||||
|
|
||||||
void myarrow (const Binding b)
|
|
||||||
{
|
{
|
||||||
if (m0_from)
|
if (m0_from)
|
||||||
{
|
{
|
||||||
@ -1083,6 +1083,13 @@ drawBinding (const System sys, Binding b)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Draw a single binding
|
||||||
|
void
|
||||||
|
drawBinding (const System sys, Binding b)
|
||||||
|
{
|
||||||
|
int intr_to, intr_from, m0_from;
|
||||||
|
|
||||||
|
|
||||||
intr_from = (sys->runs[b->run_from].protocol == INTRUDER);
|
intr_from = (sys->runs[b->run_from].protocol == INTRUDER);
|
||||||
intr_to = (sys->runs[b->run_to].protocol == INTRUDER);
|
intr_to = (sys->runs[b->run_to].protocol == INTRUDER);
|
||||||
m0_from = false;
|
m0_from = false;
|
||||||
@ -1121,7 +1128,7 @@ drawBinding (const System sys, Binding b)
|
|||||||
{
|
{
|
||||||
// intr->intr
|
// intr->intr
|
||||||
eprintf ("\t");
|
eprintf ("\t");
|
||||||
myarrow (b);
|
myarrow (sys, m0_from, b);
|
||||||
eprintf (" [label=\"");
|
eprintf (" [label=\"");
|
||||||
termPrintRemap (b->term);
|
termPrintRemap (b->term);
|
||||||
eprintf ("\"");
|
eprintf ("\"");
|
||||||
@ -1136,7 +1143,7 @@ drawBinding (const System sys, Binding b)
|
|||||||
{
|
{
|
||||||
// intr->regular
|
// intr->regular
|
||||||
eprintf ("\t");
|
eprintf ("\t");
|
||||||
myarrow (b);
|
myarrow (sys, m0_from, b);
|
||||||
if (m0_from)
|
if (m0_from)
|
||||||
{
|
{
|
||||||
eprintf ("[weight=\"0.5\"]");
|
eprintf ("[weight=\"0.5\"]");
|
||||||
@ -1151,7 +1158,7 @@ drawBinding (const System sys, Binding b)
|
|||||||
{
|
{
|
||||||
// regular->intr
|
// regular->intr
|
||||||
eprintf ("\t");
|
eprintf ("\t");
|
||||||
myarrow (b);
|
myarrow (sys, m0_from, b);
|
||||||
eprintf (";\n");
|
eprintf (";\n");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1163,7 +1170,7 @@ drawBinding (const System sys, Binding b)
|
|||||||
if (isCommunicationExact (sys, b))
|
if (isCommunicationExact (sys, b))
|
||||||
{
|
{
|
||||||
eprintf ("\t");
|
eprintf ("\t");
|
||||||
myarrow (b);
|
myarrow (sys, m0_from, b);
|
||||||
eprintf (" [style=bold,color=\"%s\"]", GOODCOMMCOLOR);
|
eprintf (" [style=bold,color=\"%s\"]", GOODCOMMCOLOR);
|
||||||
eprintf (";\n");
|
eprintf (";\n");
|
||||||
}
|
}
|
||||||
|
@ -56,36 +56,25 @@ addEnumTerm (const System sys, Term t, Term actor, Termlist todo,
|
|||||||
{
|
{
|
||||||
if (termSubTerm (t, todo->term))
|
if (termSubTerm (t, todo->term))
|
||||||
{
|
{
|
||||||
// Occurs, we have to iterate
|
Termlist tl;
|
||||||
void iterateThis (Term to)
|
|
||||||
{
|
|
||||||
tolist = termlistPrepend (tolist, to);
|
|
||||||
|
|
||||||
addEnumTerm (sys, t, actor, todo->next, fromlist, tolist);
|
|
||||||
|
|
||||||
tolist = termlistDelTerm (tolist);
|
|
||||||
}
|
|
||||||
|
|
||||||
fromlist = termlistPrepend (fromlist, todo->term);
|
fromlist = termlistPrepend (fromlist, todo->term);
|
||||||
if (isTermEqual (todo->term, actor))
|
if (isTermEqual (todo->term, actor))
|
||||||
{
|
{
|
||||||
// Untrusted agents only
|
// Untrusted agents only
|
||||||
Termlist tl;
|
tl = sys->untrusted;
|
||||||
|
|
||||||
for (tl = sys->untrusted; tl != NULL; tl = tl->next)
|
|
||||||
{
|
|
||||||
iterateThis (tl->term);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// any agents
|
// any agents
|
||||||
Termlist tl;
|
tl = sys->agentnames;
|
||||||
|
|
||||||
for (tl = sys->agentnames; tl != NULL; tl = tl->next)
|
|
||||||
{
|
|
||||||
iterateThis (tl->term);
|
|
||||||
}
|
}
|
||||||
|
while (tl != NULL)
|
||||||
|
{
|
||||||
|
tolist = termlistPrepend (tolist, tl->term);
|
||||||
|
addEnumTerm (sys, t, actor, todo->next, fromlist, tolist);
|
||||||
|
tolist = termlistDelTerm (tolist);
|
||||||
|
tl = tl->next;
|
||||||
}
|
}
|
||||||
fromlist = termlistDelTerm (fromlist);
|
fromlist = termlistDelTerm (fromlist);
|
||||||
}
|
}
|
||||||
|
@ -430,6 +430,14 @@ isKnowledgePublicFunction (const Knowledge know, const Term f)
|
|||||||
return inTermlist (know->publicfunctions, f);
|
return inTermlist (know->publicfunctions, f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Term
|
||||||
|
funKey (Term orig, Term f)
|
||||||
|
{
|
||||||
|
/* in: f'{op}, f
|
||||||
|
* out: f{op'} */
|
||||||
|
return makeTermFcall (termDuplicate (TermOp (orig)), termDuplicate (f));
|
||||||
|
}
|
||||||
|
|
||||||
//! Give the inverse key term of a term.
|
//! Give the inverse key term of a term.
|
||||||
/**
|
/**
|
||||||
* Gives a duplicate of the inverse Key of some term (which is used to encrypt something), as is defined
|
* Gives a duplicate of the inverse Key of some term (which is used to encrypt something), as is defined
|
||||||
@ -452,14 +460,6 @@ inverseKey (Knowledge know, Term key)
|
|||||||
{
|
{
|
||||||
Termlist tl;
|
Termlist tl;
|
||||||
|
|
||||||
Term funKey (Term orig, Term f)
|
|
||||||
{
|
|
||||||
/* in: f'{op}, f
|
|
||||||
* out: f{op'} */
|
|
||||||
return makeTermFcall (termDuplicate (TermOp (orig)),
|
|
||||||
termDuplicate (f));
|
|
||||||
}
|
|
||||||
|
|
||||||
tl = know->inversekeyfunctions;
|
tl = know->inversekeyfunctions;
|
||||||
while (tl != NULL && tl->next != NULL)
|
while (tl != NULL && tl->next != NULL)
|
||||||
{
|
{
|
||||||
|
37
src/mgu.c
37
src/mgu.c
@ -146,6 +146,22 @@ unify_callback_wrapper (Termlist tl, struct state_mgu_tmp *ptr_tmpstate)
|
|||||||
ptr_tmpstate->oldcallback, ptr_tmpstate->oldstate);
|
ptr_tmpstate->oldcallback, ptr_tmpstate->oldstate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
callsubst (int (*callback) (), void *state, Termlist tl, Term t, Term tsubst)
|
||||||
|
{
|
||||||
|
int proceed;
|
||||||
|
|
||||||
|
t->subst = tsubst;
|
||||||
|
#ifdef DEBUG
|
||||||
|
showSubst (t);
|
||||||
|
#endif
|
||||||
|
tl = termlistAdd (tl, t);
|
||||||
|
proceed = callback (tl, state);
|
||||||
|
tl = termlistDelTerm (tl);
|
||||||
|
t->subst = NULL;
|
||||||
|
return proceed;
|
||||||
|
}
|
||||||
|
|
||||||
//! Most general unifier iteration
|
//! Most general unifier iteration
|
||||||
/**
|
/**
|
||||||
* Try to determine the most general unifier of two terms, if so calls function.
|
* Try to determine the most general unifier of two terms, if so calls function.
|
||||||
@ -161,21 +177,6 @@ unify_callback_wrapper (Termlist tl, struct state_mgu_tmp *ptr_tmpstate)
|
|||||||
int
|
int
|
||||||
unify (Term t1, Term t2, Termlist tl, int (*callback) (), void *state)
|
unify (Term t1, Term t2, Termlist tl, int (*callback) (), void *state)
|
||||||
{
|
{
|
||||||
int callsubst (Termlist tl, Term t, Term tsubst)
|
|
||||||
{
|
|
||||||
int proceed;
|
|
||||||
|
|
||||||
t->subst = tsubst;
|
|
||||||
#ifdef DEBUG
|
|
||||||
showSubst (t);
|
|
||||||
#endif
|
|
||||||
tl = termlistAdd (tl, t);
|
|
||||||
proceed = callback (tl, state);
|
|
||||||
tl = termlistDelTerm (tl);
|
|
||||||
t->subst = NULL;
|
|
||||||
return proceed;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* added for speed */
|
/* added for speed */
|
||||||
t1 = deVar (t1);
|
t1 = deVar (t1);
|
||||||
t2 = deVar (t2);
|
t2 = deVar (t2);
|
||||||
@ -223,7 +224,7 @@ unify (Term t1, Term t2, Termlist tl, int (*callback) (), void *state)
|
|||||||
t1 = t2;
|
t1 = t2;
|
||||||
t2 = t3;
|
t2 = t3;
|
||||||
}
|
}
|
||||||
return callsubst (tl, t1, t2);
|
return callsubst (callback, state, tl, t1, t2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* symmetrical tests for single variable.
|
/* symmetrical tests for single variable.
|
||||||
@ -235,7 +236,7 @@ unify (Term t1, Term t2, Termlist tl, int (*callback) (), void *state)
|
|||||||
return true;
|
return true;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return callsubst (tl, t2, t1);
|
return callsubst (callback, state, tl, t2, t1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (realTermVariable (t1))
|
if (realTermVariable (t1))
|
||||||
@ -244,7 +245,7 @@ unify (Term t1, Term t2, Termlist tl, int (*callback) (), void *state)
|
|||||||
return true;
|
return true;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return callsubst (tl, t1, t2);
|
return callsubst (callback, state, tl, t1, t2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
124
src/term.c
124
src/term.c
@ -1188,14 +1188,9 @@ term_rolelocals_are_variables ()
|
|||||||
rolelocal_variable = 1;
|
rolelocal_variable = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Count the encryption level of a term
|
//! Helper for counting encryption level of a term
|
||||||
/**
|
|
||||||
* Note that this stops at any variable that is of ticket type.
|
|
||||||
*/
|
|
||||||
int
|
int
|
||||||
term_encryption_level (const Term term)
|
iter_maxencrypt (Term baseterm, Term t)
|
||||||
{
|
|
||||||
int iter_maxencrypt (Term t)
|
|
||||||
{
|
{
|
||||||
if (isTicketTerm (t))
|
if (isTicketTerm (t))
|
||||||
{
|
{
|
||||||
@ -1208,7 +1203,7 @@ term_encryption_level (const Term term)
|
|||||||
if (DEBUGL (2))
|
if (DEBUGL (2))
|
||||||
{
|
{
|
||||||
eprintf ("Warning: Term encryption level finds a NULL for term ");
|
eprintf ("Warning: Term encryption level finds a NULL for term ");
|
||||||
termPrint (term);
|
termPrint (baseterm);
|
||||||
eprintf ("\n");
|
eprintf ("\n");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -1224,14 +1219,14 @@ term_encryption_level (const Term term)
|
|||||||
|
|
||||||
if (realTermTuple (t))
|
if (realTermTuple (t))
|
||||||
{
|
{
|
||||||
l = iter_maxencrypt (TermOp1 (t));
|
l = iter_maxencrypt (baseterm, TermOp1 (t));
|
||||||
r = iter_maxencrypt (TermOp2 (t));
|
r = iter_maxencrypt (baseterm, TermOp2 (t));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// encrypt
|
// encrypt
|
||||||
l = 1 + iter_maxencrypt (TermOp (t));
|
l = 1 + iter_maxencrypt (baseterm, TermOp (t));
|
||||||
r = iter_maxencrypt (TermKey (t));
|
r = iter_maxencrypt (baseterm, TermKey (t));
|
||||||
}
|
}
|
||||||
if (l > r)
|
if (l > r)
|
||||||
return l;
|
return l;
|
||||||
@ -1240,7 +1235,45 @@ term_encryption_level (const Term term)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return iter_maxencrypt (term);
|
//! Count the encryption level of a term
|
||||||
|
/**
|
||||||
|
* Note that this stops at any variable that is of ticket type.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
term_encryption_level (const Term term)
|
||||||
|
{
|
||||||
|
return iter_maxencrypt (term, term);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct ti_data
|
||||||
|
{
|
||||||
|
int vars;
|
||||||
|
int structure;
|
||||||
|
};
|
||||||
|
|
||||||
|
void
|
||||||
|
tcl_iterate (struct ti_data *p_data, Term t)
|
||||||
|
{
|
||||||
|
t = deVar (t);
|
||||||
|
(p_data->structure)++;
|
||||||
|
if (realTermLeaf (t))
|
||||||
|
{
|
||||||
|
if (realTermVariable (t))
|
||||||
|
(p_data->vars)++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (realTermTuple (t))
|
||||||
|
{
|
||||||
|
tcl_iterate (p_data, TermOp1 (t));
|
||||||
|
tcl_iterate (p_data, TermOp2 (t));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tcl_iterate (p_data, TermOp (t));
|
||||||
|
tcl_iterate (p_data, TermKey (t));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Determine 'constrained factor' of a term
|
//! Determine 'constrained factor' of a term
|
||||||
@ -1252,50 +1285,19 @@ term_encryption_level (const Term term)
|
|||||||
float
|
float
|
||||||
term_constrain_level (const Term term)
|
term_constrain_level (const Term term)
|
||||||
{
|
{
|
||||||
int vars;
|
struct ti_data data;
|
||||||
int structure;
|
|
||||||
|
|
||||||
void tcl_iterate (Term t)
|
|
||||||
{
|
|
||||||
t = deVar (t);
|
|
||||||
structure++;
|
|
||||||
if (realTermLeaf (t))
|
|
||||||
{
|
|
||||||
if (realTermVariable (t))
|
|
||||||
vars++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (realTermTuple (t))
|
|
||||||
{
|
|
||||||
tcl_iterate (TermOp1 (t));
|
|
||||||
tcl_iterate (TermOp2 (t));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
tcl_iterate (TermOp (t));
|
|
||||||
tcl_iterate (TermKey (t));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (term == NULL)
|
if (term == NULL)
|
||||||
error ("Cannot determine constrain level of empty term.");
|
error ("Cannot determine constrain level of empty term.");
|
||||||
|
|
||||||
vars = 0;
|
data.vars = 0;
|
||||||
structure = 0;
|
data.structure = 0;
|
||||||
tcl_iterate (term);
|
tcl_iterate (&data, term);
|
||||||
return ((float) vars / (float) structure);
|
return ((float) data.vars / (float) data.structure);
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Adjust the keylevels of the symbols in a term.
|
|
||||||
/**
|
|
||||||
* This is used to scan the roles. For each symbol, this function does the bookkeeping of the keylevels at which they occur.
|
|
||||||
*/
|
|
||||||
void
|
void
|
||||||
term_set_keylevels (const Term term)
|
scan_levels (int level, Term t)
|
||||||
{
|
|
||||||
void scan_levels (int level, Term t)
|
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (DEBUGL (5))
|
if (DEBUGL (5))
|
||||||
@ -1340,17 +1342,18 @@ term_set_keylevels (const Term term)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Adjust the keylevels of the symbols in a term.
|
||||||
|
/**
|
||||||
|
* This is used to scan the roles. For each symbol, this function does the bookkeeping of the keylevels at which they occur.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
term_set_keylevels (const Term term)
|
||||||
|
{
|
||||||
scan_levels (0, term);
|
scan_levels (0, term);
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Print the term diff of two terms
|
|
||||||
/**
|
|
||||||
* This is not correct yet. We need to add function application and correct tuple handing.
|
|
||||||
*/
|
|
||||||
void
|
void
|
||||||
termPrintDiff (Term t1, Term t2)
|
termFromTo (Term t1, Term t2)
|
||||||
{
|
|
||||||
void termFromTo (Term t1, Term t2)
|
|
||||||
{
|
{
|
||||||
t1 = deVar (t1);
|
t1 = deVar (t1);
|
||||||
t2 = deVar (t2);
|
t2 = deVar (t2);
|
||||||
@ -1362,6 +1365,13 @@ termPrintDiff (Term t1, Term t2)
|
|||||||
eprintf ("] ");
|
eprintf ("] ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Print the term diff of two terms
|
||||||
|
/**
|
||||||
|
* This is not correct yet. We need to add function application and correct tuple handing.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
termPrintDiff (Term t1, Term t2)
|
||||||
|
{
|
||||||
t1 = deVar (t1);
|
t1 = deVar (t1);
|
||||||
t2 = deVar (t2);
|
t2 = deVar (t2);
|
||||||
|
|
||||||
|
46
src/xmlout.c
46
src/xmlout.c
@ -843,31 +843,13 @@ xmlRunInfo (const System sys, const int run)
|
|||||||
xmlRunVariables (sys, run);
|
xmlRunVariables (sys, run);
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Display runs
|
|
||||||
void
|
|
||||||
xmlOutRuns (const System sys)
|
|
||||||
{
|
|
||||||
int run;
|
|
||||||
|
|
||||||
for (run = 0; run < sys->maxruns; run++)
|
|
||||||
{
|
|
||||||
xmlPrint ("<run>");
|
|
||||||
xmlindent++;
|
|
||||||
|
|
||||||
xmlRunInfo (sys, run);
|
|
||||||
|
|
||||||
xmlPrint ("<eventlist>");
|
|
||||||
xmlindent++;
|
|
||||||
{
|
|
||||||
Roledef rd;
|
|
||||||
int index;
|
|
||||||
|
|
||||||
//! Test whether to display this event
|
//! Test whether to display this event
|
||||||
/**
|
/**
|
||||||
* Could be integrated into a single line on the while loop,
|
* Could be integrated into a single line on the while loop,
|
||||||
* but that makes it rather hard to understand.
|
* but that makes it rather hard to understand.
|
||||||
*/
|
*/
|
||||||
int showthis (void)
|
int
|
||||||
|
showthis (const System sys, const int run, const Roledef rd, const int index)
|
||||||
{
|
{
|
||||||
if (rd != NULL)
|
if (rd != NULL)
|
||||||
{
|
{
|
||||||
@ -895,8 +877,7 @@ xmlOutRuns (const System sys)
|
|||||||
* events.
|
* events.
|
||||||
*/
|
*/
|
||||||
if (isTriviallyKnownAtArachne (sys,
|
if (isTriviallyKnownAtArachne (sys,
|
||||||
rd->message,
|
rd->message, run, index))
|
||||||
run, index))
|
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -927,9 +908,28 @@ xmlOutRuns (const System sys)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Display runs
|
||||||
|
void
|
||||||
|
xmlOutRuns (const System sys)
|
||||||
|
{
|
||||||
|
int run;
|
||||||
|
|
||||||
|
for (run = 0; run < sys->maxruns; run++)
|
||||||
|
{
|
||||||
|
xmlPrint ("<run>");
|
||||||
|
xmlindent++;
|
||||||
|
|
||||||
|
xmlRunInfo (sys, run);
|
||||||
|
|
||||||
|
xmlPrint ("<eventlist>");
|
||||||
|
xmlindent++;
|
||||||
|
{
|
||||||
|
Roledef rd;
|
||||||
|
int index;
|
||||||
|
|
||||||
index = 0;
|
index = 0;
|
||||||
rd = sys->runs[run].start;
|
rd = sys->runs[run].start;
|
||||||
while (showthis ())
|
while (showthis (sys, run, rd, index))
|
||||||
{
|
{
|
||||||
xmlOutEvent (sys, rd, run, index);
|
xmlOutEvent (sys, rd, run, index);
|
||||||
index++;
|
index++;
|
||||||
|
Loading…
Reference in New Issue
Block a user