Refactoring code.
This commit is contained in:
parent
024a76a32b
commit
178c20a61c
107
src/arachne.c
107
src/arachne.c
@ -1375,6 +1375,23 @@ bind_goal_new_intruder_run (const Binding b)
|
|||||||
return flag;
|
return flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Debug information?
|
||||||
|
void
|
||||||
|
debug_send_candidate (const Protocol p, const Role r, const Roledef rd,
|
||||||
|
const int index)
|
||||||
|
{
|
||||||
|
#ifdef DEBUG
|
||||||
|
indentPrint ();
|
||||||
|
eprintf ("Checking send candidate with message ");
|
||||||
|
termPrint (rd->message);
|
||||||
|
eprintf (" from ");
|
||||||
|
termPrint (p->nameterm);
|
||||||
|
eprintf (", ");
|
||||||
|
termPrint (r->nameterm);
|
||||||
|
eprintf (", index %i\n", index);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
//! Dummy helper function for iterator; abort if sub-unification found
|
//! Dummy helper function for iterator; abort if sub-unification found
|
||||||
int
|
int
|
||||||
test_sub_unification (Termlist substlist, Termlist keylist)
|
test_sub_unification (Termlist substlist, Termlist keylist)
|
||||||
@ -1383,6 +1400,50 @@ test_sub_unification (Termlist substlist, Termlist keylist)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Proof output for first match
|
||||||
|
void
|
||||||
|
proof_term_match_first (const int found, const Binding b)
|
||||||
|
{
|
||||||
|
if (switches.output == PROOF && found == 1)
|
||||||
|
{
|
||||||
|
indentPrint ();
|
||||||
|
eprintf ("The term ", found);
|
||||||
|
termPrint (b->term);
|
||||||
|
eprintf (" matches patterns from the role definitions. Investigate.\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Proof output for any match
|
||||||
|
void
|
||||||
|
proof_term_match (const Protocol p, const Role r, const Roledef rd,
|
||||||
|
const int index, const int found)
|
||||||
|
{
|
||||||
|
if (switches.output == PROOF)
|
||||||
|
{
|
||||||
|
indentPrint ();
|
||||||
|
eprintf ("%i. It matches the pattern ", found);
|
||||||
|
termPrint (rd->message);
|
||||||
|
eprintf (" from ");
|
||||||
|
termPrint (p->nameterm);
|
||||||
|
eprintf (", ");
|
||||||
|
termPrint (r->nameterm);
|
||||||
|
eprintf (", at %i\n", index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Proof output for no match
|
||||||
|
void
|
||||||
|
proof_term_match_none (const Binding b, const int found)
|
||||||
|
{
|
||||||
|
if (switches.output == PROOF && found == 0)
|
||||||
|
{
|
||||||
|
indentPrint ();
|
||||||
|
eprintf ("The term ");
|
||||||
|
termPrint (b->term);
|
||||||
|
eprintf (" does not match any pattern from the role definitions.\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//! Bind a regular goal
|
//! Bind a regular goal
|
||||||
/**
|
/**
|
||||||
* Problem child. Valgrind does not like it.
|
* Problem child. Valgrind does not like it.
|
||||||
@ -1405,19 +1466,8 @@ bind_goal_regular_run (const Binding b)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Test for interm unification
|
// Test for interm unification
|
||||||
#ifdef DEBUG
|
debug_send_candidate (p, r, rd, index);
|
||||||
if (DEBUGL (5))
|
|
||||||
{
|
|
||||||
indentPrint ();
|
|
||||||
eprintf ("Checking send candidate with message ");
|
|
||||||
termPrint (rd->message);
|
|
||||||
eprintf (" from ");
|
|
||||||
termPrint (p->nameterm);
|
|
||||||
eprintf (", ");
|
|
||||||
termPrint (r->nameterm);
|
|
||||||
eprintf (", index %i\n", index);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
if (!subtermUnify
|
if (!subtermUnify
|
||||||
(rd->message, b->term, NULL, NULL, test_sub_unification))
|
(rd->message, b->term, NULL, NULL, test_sub_unification))
|
||||||
{
|
{
|
||||||
@ -1425,25 +1475,9 @@ bind_goal_regular_run (const Binding b)
|
|||||||
|
|
||||||
// A good candidate
|
// A good candidate
|
||||||
found++;
|
found++;
|
||||||
if (switches.output == PROOF && found == 1)
|
proof_term_match_first (found, b);
|
||||||
{
|
proof_term_match (p, r, rd, index, found);
|
||||||
indentPrint ();
|
|
||||||
eprintf ("The term ", found);
|
|
||||||
termPrint (b->term);
|
|
||||||
eprintf
|
|
||||||
(" matches patterns from the role definitions. Investigate.\n");
|
|
||||||
}
|
|
||||||
if (switches.output == PROOF)
|
|
||||||
{
|
|
||||||
indentPrint ();
|
|
||||||
eprintf ("%i. It matches the pattern ", found);
|
|
||||||
termPrint (rd->message);
|
|
||||||
eprintf (" from ");
|
|
||||||
termPrint (p->nameterm);
|
|
||||||
eprintf (", ");
|
|
||||||
termPrint (r->nameterm);
|
|
||||||
eprintf (", at %i\n", index);
|
|
||||||
}
|
|
||||||
indentDepth++;
|
indentDepth++;
|
||||||
|
|
||||||
// Bind to existing run
|
// Bind to existing run
|
||||||
@ -1474,13 +1508,8 @@ bind_goal_regular_run (const Binding b)
|
|||||||
// Bind to all possible sends of regular runs
|
// Bind to all possible sends of regular runs
|
||||||
found = 0;
|
found = 0;
|
||||||
flag = iterate_role_sends (bind_this_role_send);
|
flag = iterate_role_sends (bind_this_role_send);
|
||||||
if (switches.output == PROOF && found == 0)
|
|
||||||
{
|
proof_term_match_none (b, found);
|
||||||
indentPrint ();
|
|
||||||
eprintf ("The term ");
|
|
||||||
termPrint (b->term);
|
|
||||||
eprintf (" does not match any pattern from the role definitions.\n");
|
|
||||||
}
|
|
||||||
return flag;
|
return flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user