meowlang/typechecker/ModelExtensions.cs

20 lines
498 B
C#
Raw Permalink Normal View History

using meowlang.parser;
namespace meowlang.typechecker;
public static class ModelExtensions
{
private static readonly Guid ExpressionTypeKey = new Guid("6560485F-A4B0-4E24-A03D-D87776BBF9F4");
public static void SetType(this ExpressionModel m, TypeId t)
{
m.Metadata[ExpressionTypeKey] = t;
}
public static TypeId? GetType(this ExpressionModel m)
{
m.Metadata.TryGetValue(ExpressionTypeKey, out var value);
return value as TypeId;
}
}