mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-21 00:25:44 +00:00
ZoneCodeGenerator: Add all used membertypes to a list in context
This commit is contained in:
parent
d7f05b97c9
commit
8c303d394d
@ -7,21 +7,8 @@ namespace ZoneCodeGenerator.Domain
|
|||||||
{
|
{
|
||||||
private const int PointerSize = 4;
|
private const int PointerSize = 4;
|
||||||
|
|
||||||
private DataType type;
|
public DataType Type { get; set; }
|
||||||
public DataType Type
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (type is DataTypeTypedef typedef)
|
|
||||||
{
|
|
||||||
return typedef.TypeDefinition.Type;
|
|
||||||
}
|
|
||||||
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
set => type = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int? CustomBitSize { get; set; }
|
public int? CustomBitSize { get; set; }
|
||||||
|
|
||||||
@ -32,7 +19,7 @@ namespace ZoneCodeGenerator.Domain
|
|||||||
private readonly List<ReferenceType> references;
|
private readonly List<ReferenceType> references;
|
||||||
public IReadOnlyList<ReferenceType> References => references.AsReadOnly();
|
public IReadOnlyList<ReferenceType> References => references.AsReadOnly();
|
||||||
|
|
||||||
public int Alignment => references.OfType<ReferenceTypePointer>().Any() ? PointerSize : type.Alignment;
|
public int Alignment => references.OfType<ReferenceTypePointer>().Any() ? PointerSize : Type.Alignment;
|
||||||
|
|
||||||
public int Size
|
public int Size
|
||||||
{
|
{
|
||||||
@ -59,7 +46,7 @@ namespace ZoneCodeGenerator.Domain
|
|||||||
|
|
||||||
public TypeDeclaration(DataType type, List<ReferenceType> references)
|
public TypeDeclaration(DataType type, List<ReferenceType> references)
|
||||||
{
|
{
|
||||||
this.type = type;
|
Type = type;
|
||||||
this.references = references ?? new List<ReferenceType>();
|
this.references = references ?? new List<ReferenceType>();
|
||||||
CustomBitSize = null;
|
CustomBitSize = null;
|
||||||
}
|
}
|
||||||
|
@ -13,10 +13,13 @@ namespace ZoneCodeGenerator.Generating
|
|||||||
{
|
{
|
||||||
public string Game { get; set; }
|
public string Game { get; set; }
|
||||||
public StructureInformation Asset { get; set; }
|
public StructureInformation Asset { get; set; }
|
||||||
public HashSet<StructureInformation> Structures { get; }
|
|
||||||
|
public ISet<StructureInformation> Structures { get; }
|
||||||
|
public ISet<DataType> MemberTypes { get; }
|
||||||
|
|
||||||
public IEnumerable<StructureInformation> ReferencedAssets => Structures.Where(inf => inf.IsAsset && inf != Asset);
|
public IEnumerable<StructureInformation> ReferencedAssets => Structures.Where(inf => inf.IsAsset && inf != Asset);
|
||||||
|
|
||||||
public List<FastFileBlock> Blocks { get; private set; }
|
public IList<FastFileBlock> Blocks { get; private set; }
|
||||||
|
|
||||||
public FastFileBlock DefaultNormalBlock => Blocks.FirstOrDefault(block => block.IsDefault && block.IsNormal) ??
|
public FastFileBlock DefaultNormalBlock => Blocks.FirstOrDefault(block => block.IsDefault && block.IsNormal) ??
|
||||||
Blocks.FirstOrDefault(block => block.IsNormal);
|
Blocks.FirstOrDefault(block => block.IsNormal);
|
||||||
@ -24,6 +27,7 @@ namespace ZoneCodeGenerator.Generating
|
|||||||
private RenderingContext()
|
private RenderingContext()
|
||||||
{
|
{
|
||||||
Structures = new HashSet<StructureInformation>();
|
Structures = new HashSet<StructureInformation>();
|
||||||
|
MemberTypes = new HashSet<DataType>();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AddToContext(StructureInformation structureInformation)
|
private void AddToContext(StructureInformation structureInformation)
|
||||||
@ -51,6 +55,12 @@ namespace ZoneCodeGenerator.Generating
|
|||||||
};
|
};
|
||||||
|
|
||||||
context.AddToContext(asset);
|
context.AddToContext(asset);
|
||||||
|
context.MemberTypes.UnionWith(context.Structures.Where(information => !information.IsAsset || information == asset)
|
||||||
|
.SelectMany(information => information.OrderedMembers)
|
||||||
|
.Select(information => information.Member.VariableType.Type)
|
||||||
|
.Where(type => !(type is DataTypeBaseType) && type != asset.Type)
|
||||||
|
.Distinct());
|
||||||
|
|
||||||
|
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user