meowlang/typechecker/types/GenericStructTypeDescription.cs
Gwendolyn d6bdd08002 loooots of stuff
the typechecker project can collect all the top level types from a file, which is pretty cool I think
(except for pointers, those aren't implemented yet...)
2022-02-13 02:41:16 +01:00

21 lines
754 B
C#

namespace meowlang.typechecker;
public record GenericStructTypeDescription : GenericTypeDescription
{
private readonly List<(string Name, GenericTypeId Type)> _members;
public List<(string Name, GenericTypeId Type)> DebugGetMembers => _members;
public GenericStructTypeDescription(List<string> genericNames, List<(string Name, GenericTypeId Type)> members) : base(genericNames)
{
_members = members;
CheckGenericNames(members.Select(x => x.Type).ToList());
}
public override StructTypeDescription Concretize(List<Guid> typeParams)
{
var members = _members.Select(x => (x.Name, ConcretizeGenericType(x.Type, typeParams))).ToList();
return new StructTypeDescription(members);
}
}