...
This commit is contained in:
@@ -70,25 +70,8 @@ public record Manifest(Dictionary<string, Manifest.Module> Modules)
|
||||
|
||||
foreach (var module in moduleGraph.GetModules())
|
||||
{
|
||||
var types = new Dictionary<string, Module.TypeInfo>();
|
||||
var identifiers = new Dictionary<string, Module.IdentifierInfo>();
|
||||
|
||||
foreach (var (name, typeInfo) in module.GetTypes())
|
||||
{
|
||||
if (typeInfo.Exported)
|
||||
{
|
||||
types.Add(name, ConvertType(typeInfo));
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var (name, identifierInfo) in module.GetIdentifiers())
|
||||
{
|
||||
if (identifierInfo.Exported)
|
||||
{
|
||||
identifiers.Add(name, new Module.IdentifierInfo(identifierInfo.Type, identifierInfo.MangledName));
|
||||
}
|
||||
}
|
||||
|
||||
var types = module.GetTypes().ToDictionary(x => x.Key, x => ConvertType(x.Value));
|
||||
var identifiers = module.GetIdentifiers().ToDictionary(x => x.Key, x => new Module.IdentifierInfo(x.Value.Type, x.Value.Exported, x.Value.Extern, x.Value.MangledName));
|
||||
modules[module.Name] = new Module(types, identifiers);
|
||||
}
|
||||
|
||||
@@ -98,8 +81,8 @@ public record Manifest(Dictionary<string, Manifest.Module> Modules)
|
||||
{
|
||||
return typeInfo switch
|
||||
{
|
||||
Compiler.Module.TypeInfoStruct s => new Module.TypeInfoStruct(s.Packed, s.Fields.Select(x => new Module.TypeInfoStruct.Field(x.Name, x.Type)).ToList()),
|
||||
Compiler.Module.TypeInfoEnum e => new Module.TypeInfoEnum(e.Variants.Select(v => new Module.TypeInfoEnum.Variant(v.Name, v.Type)).ToList()),
|
||||
Compiler.Module.TypeInfoStruct s => new Module.TypeInfoStruct(s.Exported, s.Packed, s.Fields.Select(x => new Module.TypeInfoStruct.Field(x.Name, x.Type)).ToList()),
|
||||
Compiler.Module.TypeInfoEnum e => new Module.TypeInfoEnum(e.Exported, e.Variants.Select(v => new Module.TypeInfoEnum.Variant(v.Name, v.Type)).ToList()),
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(typeInfo))
|
||||
};
|
||||
}
|
||||
@@ -108,18 +91,18 @@ public record Manifest(Dictionary<string, Manifest.Module> Modules)
|
||||
|
||||
public record Module(Dictionary<string, Module.TypeInfo> Types, Dictionary<string, Module.IdentifierInfo> Identifiers)
|
||||
{
|
||||
public record IdentifierInfo(NubType Type, string MangledName);
|
||||
public record IdentifierInfo(NubType Type, bool Exported, bool Extern, string MangledName);
|
||||
|
||||
[JsonDerivedType(typeof(TypeInfoStruct), "struct")]
|
||||
[JsonDerivedType(typeof(TypeInfoEnum), "enum")]
|
||||
public abstract record TypeInfo;
|
||||
public abstract record TypeInfo(bool Exported);
|
||||
|
||||
public record TypeInfoStruct(bool Packed, IReadOnlyList<TypeInfoStruct.Field> Fields) : TypeInfo
|
||||
public record TypeInfoStruct(bool Exported, bool Packed, IReadOnlyList<TypeInfoStruct.Field> Fields) : TypeInfo(Exported)
|
||||
{
|
||||
public record Field(string Name, NubType Type);
|
||||
}
|
||||
|
||||
public record TypeInfoEnum(IReadOnlyList<TypeInfoEnum.Variant> Variants) : TypeInfo
|
||||
public record TypeInfoEnum(bool Exported, IReadOnlyList<TypeInfoEnum.Variant> Variants) : TypeInfo(Exported)
|
||||
{
|
||||
public record Variant(string Name, NubType Type);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user