using NubLang.Parsing.Syntax; namespace NubLang.Modules; public class Module { private readonly List _structs = []; private readonly List _interfaces = []; private readonly List _functions = []; public void RegisterStruct(bool exported, string name, IReadOnlyList fields) { _structs.Add(new ModuleStructType(exported, name, fields)); } public void RegisterInterface(bool exported, string name) { _interfaces.Add(new ModuleInterfaceType(exported, name)); } public void RegisterFunction(bool exported, string name, string? externSymbol, FuncTypeSyntax type) { _functions.Add(new ModuleFuncType(exported, name, externSymbol, type)); } public IReadOnlyList StructTypes(bool includePrivate) { return _structs.Where(x => x.Exported || includePrivate).ToList(); } public IReadOnlyList InterfaceTypes(bool includePrivate) { return _interfaces.Where(x => x.Exported || includePrivate).ToList(); } public IReadOnlyList Functions(bool includePrivate) { return _functions.Where(x => x.Exported || includePrivate).ToList(); } } public record ModuleStructTypeField(string Name, TypeSyntax Type, bool HasDefaultValue); public record ModuleStructType(bool Exported, string Name, IReadOnlyList Fields); public record ModuleInterfaceType(bool Exported, string Name); public record ModuleFuncType(bool Exported, string Name, string? ExternSymbol, FuncTypeSyntax FuncType);