- Fixed some minor issues.

- Fixed type flaw in labellist type.
This commit is contained in:
ccremers 2004-08-30 20:08:11 +00:00
parent 20a38f79c5
commit 8f441ac913
3 changed files with 46 additions and 31 deletions

View File

@ -28,11 +28,11 @@ void label_destroy (Labelinfo linfo)
} }
//! Given a list of label infos, yield the correct one or NULL //! Given a list of label infos, yield the correct one or NULL
Labelinfo label_find (List labellist, const Term label) Labelinfo label_find (List labellist, Term label)
{ {
Labelinfo linfo; Labelinfo linfo;
int scan (void *data) int label_find_scan (void *data)
{ {
Labelinfo linfo_scan; Labelinfo linfo_scan;
@ -49,7 +49,10 @@ Labelinfo label_find (List labellist, const Term label)
} }
linfo = NULL; linfo = NULL;
list_iterate (labellist, scan); if (label != NULL)
{
list_iterate (labellist, label_find_scan);
}
return linfo; return linfo;
} }

View File

@ -11,7 +11,7 @@
struct labelinfo struct labelinfo
{ {
Term label; Term label;
Term protocol; Protocol protocol;
Term sendrole; Term sendrole;
Term readrole; Term readrole;
}; };

View File

@ -906,6 +906,7 @@ term_iterate (const Term term, int (*leaf) (), int (*nodel) (),
if (nodel != NULL) if (nodel != NULL)
flag = flag && nodel (term); flag = flag && nodel (term);
// Left part
if (realTermTuple (term)) if (realTermTuple (term))
flag = flag flag = flag
&& (term_iterate (term->left.op1, leaf, nodel, nodem, noder)); && (term_iterate (term->left.op1, leaf, nodel, nodem, noder));
@ -916,12 +917,13 @@ term_iterate (const Term term, int (*leaf) (), int (*nodel) (),
if (nodem != NULL) if (nodem != NULL)
flag = flag && nodem (term); flag = flag && nodem (term);
// Right part
if (realTermTuple (term)) if (realTermTuple (term))
flag = flag flag = flag
&& (term_iterate (term->left.op1, leaf, nodel, nodem, noder)); && (term_iterate (term->right.op2, leaf, nodel, nodem, noder));
else else
flag = flag flag = flag
&& (term_iterate (term->left.op, leaf, nodel, nodem, noder)); && (term_iterate (term->right.key, leaf, nodel, nodem, noder));
if (noder != NULL) if (noder != NULL)
flag = flag && noder (term); flag = flag && noder (term);
@ -947,6 +949,10 @@ term_iterate_deVar (Term term, int (*leaf) (), int (*nodel) (),
{ {
return leaf (term); return leaf (term);
} }
else
{
return 1;
}
} }
else else
{ {
@ -957,6 +963,7 @@ term_iterate_deVar (Term term, int (*leaf) (), int (*nodel) (),
if (nodel != NULL) if (nodel != NULL)
flag = flag && nodel (term); flag = flag && nodel (term);
// Left part
if (realTermTuple (term)) if (realTermTuple (term))
flag = flag flag = flag
&& &&
@ -970,15 +977,16 @@ term_iterate_deVar (Term term, int (*leaf) (), int (*nodel) (),
if (nodem != NULL) if (nodem != NULL)
flag = flag && nodem (term); flag = flag && nodem (term);
// right part
if (realTermTuple (term)) if (realTermTuple (term))
flag = flag flag = flag
&& &&
(term_iterate_deVar (term_iterate_deVar
(term->left.op1, leaf, nodel, nodem, noder)); (term->right.op2, leaf, nodel, nodem, noder));
else else
flag = flag flag = flag
&& &&
(term_iterate_deVar (term->left.op, leaf, nodel, nodem, noder)); (term_iterate_deVar (term->right.key, leaf, nodel, nodem, noder));
if (noder != NULL) if (noder != NULL)
flag = flag && noder (term); flag = flag && noder (term);
@ -1047,31 +1055,35 @@ term_rolelocals_are_variables ()
int int
term_encryption_level (const Term term) term_encryption_level (const Term term)
{ {
int level, maxlevel, flag; int iter_maxencrypt (Term term)
{
term = deVar (term);
if (realTermLeaf (term))
{
return 0;
}
else
{
if (realTermTuple (term))
{
int l,r;
int nodel (const Term term) l = iter_maxencrypt (term->left.op1);
{ r = iter_maxencrypt (term->right.op2);
if (realTermEncrypt (term)) if (l>r)
{ return l;
level++; else
if (level > maxlevel) return r;
maxlevel = level; }
} else
return 1; {
} // encrypt
int noder (const Term term) return 1+iter_maxencrypt (term->left.op);
{ }
if (realTermEncrypt (term)) }
{ }
level--;
}
return 1;
}
maxlevel = 0; return iter_maxencrypt (term);
level = 0;
flag = term_iterate_deVar (term, NULL, nodel, NULL, noder);
return maxlevel;
} }
//! Determine 'constrained factor' of a term //! Determine 'constrained factor' of a term