- First broken steps towards prec() computation for each claim label.

This commit is contained in:
ccremers 2004-06-14 22:08:47 +00:00
parent 0e0f52c6aa
commit 9634034ebb
5 changed files with 89 additions and 1 deletions

View File

@ -3,6 +3,7 @@
#include "tac.h"
#include "terms.h"
#include "termlists.h"
#include "memory.h"
#include "runs.h"
#include "knowledge.h"
#include "symbols.h"
@ -316,6 +317,7 @@ void
commEvent (int event, Tac tc)
{
/* Add an event to the roledef, send or read */
Claimlist cl;
Term fromrole = NULL;
Term torole = NULL;
Term msg = NULL;
@ -360,7 +362,7 @@ commEvent (int event, Tac tc)
/* now parse tuple info */
if (trip == NULL || trip->next == NULL)
{
error ("Problem with %i event on line %i.", event, tc->lineno);
error ("Problem with claim %i event on line %i.", event, tc->lineno);
}
fromrole = tacTerm (trip);
claimbig = tacTerm (tacTuple ((trip->next)));
@ -396,6 +398,31 @@ commEvent (int event, Tac tc)
}
}
/* store claim in claim list */
// First check whether label is unique
cl = sys->claimlist;
while (cl != NULL)
{
if (isTermEqual (cl->label, label))
{
/**
*@todo This should not error exit, but automatically generate a fresh claim label.
*/
error ("Claim label is not unique at line %i.",tc->lineno);
}
cl = cl->next;
}
// Assert: label is unique, add claimlist info
cl = memAlloc (sizeof (struct claimlist));
cl->label = label;
cl->rolename = fromrole;
cl->count = 0;
cl->failed = 0;
cl->prec = NULL;
cl->next = sys->claimlist;
sys->claimlist = cl;
/* handles all claim types differently */
if (claim == CLAIM_Secret)
@ -719,3 +746,24 @@ tacTermlist (Tac tc)
}
return tl;
}
//! Compute prec() sets for each claim.
void
compute_prec_sets (const System sys)
{
Claimlist cl;
// Process each individual claim
cl = sys->claimlist;
while (cl != NULL)
{
//!@todo compute transitive closure
}
}
//! Preprocess after system compilation
void
preprocess (const System sys)
{
compute_prec_sets(sys);
}

View File

@ -2,5 +2,6 @@
#define COMPILER
void compile (System sys, Tac tc, int maxruns);
void preprocess (const System sys);
#endif

View File

@ -288,6 +288,9 @@ main (int argc, char **argv)
compile (sys, spdltac, maxruns->ival[0]);
scanner_cleanup ();
/* preprocess */
preprocess (sys);
#ifdef DEBUG
if (DEBUGL (1))
{

View File

@ -81,6 +81,8 @@ systemInit ()
sys->untrusted = NULL;
sys->secrets = NULL; // list of claimed secrets
sys->attack = NULL;
/* no protocols => no protocol preprocessed */
sys->claimlist = NULL;
/* matching CLP */
sys->constraints = NULL; // no initial constraints
@ -99,12 +101,22 @@ systemInit ()
void
systemReset (const System sys)
{
Claimlist cl;
/* some initial counters */
sys->statesLow = 0; // number of explored states
sys->statesHigh = 0; // this is not as ridiculous as it might seem
sys->explore = 1; // do explore the space
sys->claims = 0; // number of claims encountered
sys->failed = 0; // number of failed claims
cl = sys->claimlist;
while (cl != NULL)
{
cl->count = 0;
cl->failed = 0;
cl = cl->next;
}
sys->knowPhase = 0; // knowledge transition id
termlistDestroy (sys->secrets); // remove old secrets list

View File

@ -2,6 +2,7 @@
#define RUNS
#include "terms.h"
#include "termmaps.h"
#include "termlists.h"
#include "knowledge.h"
#include "constraints.h"
@ -154,6 +155,26 @@ struct tracebuf
Varbuf variables;
};
//! The container for the claim info list
struct claimlist
{
//! The term element for this node.
Term label;
//! The name of the role in which it occurs.
Term rolename;
//! Number of occurrences in system exploration.
int count;
//! Number of occurrences that failed.
int failed;
//! Preceding label list
Termlist prec;
//! Next node pointer or NULL for the last element of the function.
struct claimlist *next;
};
//! Shorthand for claimlist pointers.
typedef struct claimlist *Claimlist;
//! The main state structure.
struct system
{
@ -206,6 +227,9 @@ struct system
Termlist variables;
Termlist untrusted;
/* protocol preprocessing */
Claimlist claimlist;
/* constructed trace pointers, static */
Roledef *traceEvent; // MaxRuns * maxRoledef
int *traceRun; // MaxRuns * maxRoledef