This repository has been archived on 2025-10-24. You can view files and clone it, but cannot push or open issues or pull requests.
Files
nub-lang-archive-2/lang/Nub.Lang/NubType.cs
2025-05-04 20:52:24 +02:00

38 lines
910 B
C#

namespace Nub.Lang;
public sealed class NubType
{
public NubType(string name, NubType[] generics)
{
Name = name;
Generics = generics;
}
public string Name { get; }
public NubType[] Generics { get; }
public static NubType Int64 => new("int64", []);
public static NubType Int32 => new("int32", []);
public static NubType Bool => new("bool", []);
public static NubType String => new("string", []);
public override bool Equals(object? obj)
{
if (obj is not NubType item)
{
return false;
}
return Name.Equals(item.Name) && Generics.SequenceEqual(item.Generics);
}
public override int GetHashCode()
{
return HashCode.Combine(Name, Generics);
}
public override string ToString()
{
return $"{Name}<{string.Join(", ", Generics.Select(x => x.ToString()))}>";
}
}