public static bool TranslateConstantWithReference(Constant c, EnumCollection enums, EnumCollection auxEnums)
{
if (!String.IsNullOrEmpty(c.Reference))
{
Constant referenced_constant;
if (enums.ContainsKey(c.Reference) && enums[c.Reference].ConstantCollection.ContainsKey(c.Value))
{
TranslateConstantWithReference(enums[c.Reference].ConstantCollection[c.Value] as Constant, enums, auxEnums);
referenced_constant = (enums[c.Reference].ConstantCollection[c.Value] as Constant);
}
else if (auxEnums.ContainsKey(c.Reference) && auxEnums[c.Reference].ConstantCollection.ContainsKey(c.Value))
{
TranslateConstantWithReference(auxEnums[c.Reference].ConstantCollection[c.Value] as Constant, enums, auxEnums);
referenced_constant = (auxEnums[c.Reference].ConstantCollection[c.Value] as Constant);
}
else
{
Console.WriteLine("[Warning] Reference {0} not found for token {1}.", c.Reference, c);
return false;
}
//else throw new InvalidOperationException(String.Format("Unknown Enum \"{0}\" referenced by Constant \"{1}\"",
// c.Reference, c.ToString()));
c.Value = referenced_constant.Value;
c.Reference = null;
c.Unchecked = referenced_constant.Unchecked;
}
return true;
}