d6bdd08002
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...)
21 lines
741 B
C#
21 lines
741 B
C#
namespace meowlang.typechecker;
|
|
|
|
public record GenericEnumTypeDescription : GenericTypeDescription
|
|
{
|
|
private readonly List<(string Name, GenericTypeId? Type)> _members;
|
|
|
|
public GenericEnumTypeDescription(List<string> genericNames, List<(string Name, GenericTypeId? Type)> members) :
|
|
base(genericNames)
|
|
{
|
|
_members = members;
|
|
CheckGenericNames(members.Where(x => x.Type != null).Select(x => x.Type!).ToList());
|
|
}
|
|
|
|
|
|
public override EnumTypeDescription Concretize(List<Guid> typeParams)
|
|
{
|
|
var members = _members.Select(x =>
|
|
x.Type == null ? (x.Name, null) : (x.Name, ConcretizeGenericType(x.Type, typeParams))).ToList();
|
|
return new EnumTypeDescription(members);
|
|
}
|
|
} |