add some very basic foundation for static typing

This commit is contained in:
Qrakhen 2025-12-16 10:02:24 +01:00
parent c4de1dfb0a
commit 880f3e60ce
2 changed files with 13 additions and 3 deletions

View File

@ -1,6 +1,6 @@
namespace Qrakhen.Qamp.Core.Values.Objects; namespace Qrakhen.Qamp.Core.Values.Objects;
public class Obj(ValueType type) : IValue public class Obj(ValueType type) : IDynamicValue
{ {
public bool __gcMarked = false; public bool __gcMarked = false;
public int __gcCount = 1; public int __gcCount = 1;

View File

@ -7,13 +7,21 @@ using T = Qrakhen.Qamp.Core.Values.ValueType;
namespace Qrakhen.Qamp.Core.Values; namespace Qrakhen.Qamp.Core.Values;
public interface IValue public interface IValue<T>
{
T Data { get; }
}
public interface IDynamicValue : IValue<ulong>
{ {
T ValueType { get; } T ValueType { get; }
} }
[StructLayout(LayoutKind.Explicit, Size = 0x10)] [StructLayout(LayoutKind.Explicit, Size = 0x10)]
public readonly struct Value : IValue, ISerialize<Value>, IDebug<string> public readonly struct Value :
IDynamicValue,
ISerialize<Value>,
IDebug<string>
{ {
public static readonly Value Void = new Value(); public static readonly Value Void = new Value();
public static readonly Value True = new Value(true); public static readonly Value True = new Value(true);
@ -28,6 +36,8 @@ public readonly struct Value : IValue, ISerialize<Value>, IDebug<string>
[FieldOffset(0x00)] [Serialized] public readonly Ptr Ptr; [FieldOffset(0x00)] [Serialized] public readonly Ptr Ptr;
[FieldOffset(0x00)] [Serialized] public readonly Ref Ref; [FieldOffset(0x00)] [Serialized] public readonly Ref Ref;
public ulong Data => Unsigned;
[FieldOffset(0x08)] [Serialized] public readonly T Type; [FieldOffset(0x08)] [Serialized] public readonly T Type;
[FieldOffset(0x0c)] [Serialized] public readonly uint Meta; // like lengths of arrays or lists [FieldOffset(0x0c)] [Serialized] public readonly uint Meta; // like lengths of arrays or lists