- Fixed role comparison bug.

This commit is contained in:
ccremers 2007-02-01 12:18:38 +00:00
parent 6e82d585be
commit 9882651f4a
5 changed files with 29 additions and 8 deletions

Binary file not shown.

View File

@ -1950,7 +1950,8 @@ checkWellFormed (const System sys)
//! Check matching role defs //! Check matching role defs
int int
checkEventMatch (const Roledef rd1, const Roledef rd2) checkEventMatch (const Roledef rd1, const Roledef rd2,
const Termlist rolenames)
{ {
if (!isTermEqual (rd1->from, rd2->from)) if (!isTermEqual (rd1->from, rd2->from))
{ {
@ -1960,7 +1961,7 @@ checkEventMatch (const Roledef rd1, const Roledef rd2)
{ {
return false; return false;
} }
if (!checkRoletermMatch (rd1->message, rd2->message)) if (!checkRoletermMatch (rd1->message, rd2->message, rolenames))
{ {
return false; return false;
} }
@ -1992,7 +1993,7 @@ checkLabelMatchThis (const System sys, const Protocol p, const Role readrole,
if (isTermEqual (event->label, readevent->label)) if (isTermEqual (event->label, readevent->label))
{ {
// Same labels, so they should match up! // Same labels, so they should match up!
if (!checkEventMatch (event, readevent)) if (!checkEventMatch (event, readevent, p->rolenames))
{ {
globalError++; globalError++;
eprintf ("error: [%i]", readevent->lineno); eprintf ("error: [%i]", readevent->lineno);

View File

@ -581,9 +581,12 @@ termMguSubTerm (Term smallterm, Term bigterm,
return flag; return flag;
} }
//! Check if terms might match in some way //! Check if role terms might match in some way
/**
* Interesting case: role names are variables here, so they always match. We catch that case by inspecting the variable list.
*/
int int
checkRoletermMatch (const Term t1, const Term t2) checkRoletermMatch (const Term t1, const Term t2, const Termlist notmapped)
{ {
Termlist tl; Termlist tl;
@ -595,10 +598,27 @@ checkRoletermMatch (const Term t1, const Term t2)
} }
else else
{ {
int result;
Termlist vl;
result = true;
// Reset variables // Reset variables
termlistSubstReset (tl); termlistSubstReset (tl);
// Check variable list etc: should not contain mapped role names
vl = tl;
while (vl != NULL)
{
// This term should not be in the notmapped list
if (inTermlist (notmapped, vl->term))
{
result = false;
break;
}
vl = vl->next;
}
// Remove list // Remove list
termlistDelete (tl); termlistDelete (tl);
return true; return result;
} }
} }

View File

@ -19,7 +19,7 @@ int termMguInTerm (Term t1, Term t2, int (*iterator) (Termlist));
int termMguSubTerm (Term t1, Term t2, int (*iterator) (Termlist, Termlist), int termMguSubTerm (Term t1, Term t2, int (*iterator) (Termlist, Termlist),
Termlist inverses, Termlist keylist); Termlist inverses, Termlist keylist);
void termlistSubstReset (Termlist tl); void termlistSubstReset (Termlist tl);
int checkRoletermMatch (Term t1, Term t2); int checkRoletermMatch (const Term t1, const Term t2, const Termlist tl);
// The new iteration methods // The new iteration methods
int unify (Term t1, Term t2, Termlist tl, int (*callback) (Termlist)); int unify (Term t1, Term t2, Termlist tl, int (*callback) (Termlist));

View File

@ -318,7 +318,7 @@ int yyerror(char *s)
extern int yylineno; //!< defined and maintained in lex.c extern int yylineno; //!< defined and maintained in lex.c
extern char *yytext; //!< defined and maintained in lex.c extern char *yytext; //!< defined and maintained in lex.c
error ("%s at symbol '%s' on line %i.\n", s, yytext, yylineno); error ("[%i] %s at symbol '%s'.\n", yylineno, s, yytext);
return 0; return 0;
} }