public void Check(BinaryFileSchema schema)
{
foreach (IBfsDataBlock block in schema.DatablockList)
{
//Link all unresolved field-types to their declarations (data-blocks).
if (block is IBfsStructType)
{
IBfsStructType structType = block as IBfsStructType;
foreach (BfsStructField field in structType.StructFields.Values)
if (field.FieldType is BfsUnresolvedNamedType)
{
BfsUnresolvedNamedType oldtype = (BfsUnresolvedNamedType)field.FieldType;
if (schema.DataBlocks.ContainsKey(oldtype.Name))
{
BfsNamedType newtype = new BfsNamedType();
newtype.DataBlock = schema.DataBlocks[oldtype.Name];
newtype.ArrayExtension = oldtype.ArrayExtension;
newtype.SourceRange = oldtype.SourceRange;
field.FieldType = newtype;
}
else BfsCompiler.ReportError(oldtype.SourceRange, "Could not resolve '" + oldtype.Name + "' to a type.");
}
}
else if (block is BfsEnum)
foreach (BfsEnumField field in (block as BfsEnum).EnumFields)
CheckActionList(field.Actions, block);
else if (block is BfsBitfield)
foreach (BfsBitfieldField field in (block as BfsBitfield).BitFieldFields)
CheckActionList(field.Actions, block);
}
}