This commit is contained in:
nub31
2026-02-11 21:47:51 +01:00
parent 0a5b39b217
commit 21a095f691
4 changed files with 284 additions and 166 deletions

View File

@@ -198,7 +198,7 @@ public class ModuleGraph
foreach (var structDef in ast.Definitions.OfType<NodeDefinitionStruct>())
{
var type = new NubTypeStruct(module.Name, structDef.Name.Ident, structDef.Packed);
var type = NubTypeStruct.CreateWithoutFields(structDef.Packed);
var info = new Module.CustomTypeInfo(type, structDef.Exported, Module.Source.Ast);
module.AddCustomType(structDef.Name.Ident, info);
}
@@ -214,8 +214,11 @@ public class ModuleGraph
if (!module.TryResolveCustomType(structDef.Name.Ident, true, out var customType))
throw new UnreachableException($"{nameof(customType)} should always be registered");
var fields = structDef.Fields.Select(f => new NubTypeStruct.Field(f.Name.Ident, ResolveType(f.Type, module.Name))).ToList();
((NubTypeStruct)customType).ResolveFields(fields);
if (customType is NubTypeStruct structType)
{
var fields = structDef.Fields.Select(f => new NubTypeStruct.Field(f.Name.Ident, ResolveType(f.Type, module.Name))).ToList();
structType.SetFields(fields);
}
}
}