From c434a151dd7429e7595e5f19411a64d786b68b03 Mon Sep 17 00:00:00 2001 From: Michael Schimmel Date: Tue, 26 Aug 2025 12:44:29 +0200 Subject: [PATCH] New type system --- Src/Data/Myc.Data.Types.Void.pas | 91 ++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 Src/Data/Myc.Data.Types.Void.pas diff --git a/Src/Data/Myc.Data.Types.Void.pas b/Src/Data/Myc.Data.Types.Void.pas new file mode 100644 index 0000000..5b18e44 --- /dev/null +++ b/Src/Data/Myc.Data.Types.Void.pas @@ -0,0 +1,91 @@ +unit Myc.Data.Types.Void; + +interface + +uses + System.SysUtils, + System.RTTI, + Myc.Data.Types; + +type + // Implements a singleton data value representing void. + TImplDataVoidValue = class(TInterfacedObject, IDataVoidValue) + private + class var + FSingleton: IDataVoidValue; + class constructor CreateSingleton; + public + // IDataValue + function GetDataType: IDataType; + function GetAsString: string; + function AsTValue: TValue; + + class property Singleton: IDataVoidValue read FSingleton; + end; + + // Implements a singleton data type representing void. + TImplDataVoidType = class(TInterfacedObject, IDataVoidType) + private + class var + FSingleton: IDataVoidType; + class constructor CreateSingleton; + public + // IDataType + function GetName: String; + function GetKind: TDataKind; + + // IDataVoidType + function GetValue: IDataVoidValue; + + class property Singleton: IDataVoidType read FSingleton; + end; + +implementation + +{ TImplDataVoidValue } + +function TImplDataVoidValue.AsTValue: TValue; +begin + Result := TValue.Empty; +end; + +class constructor TImplDataVoidValue.CreateSingleton; +begin + // Singleton instance created for the void value + FSingleton := TImplDataVoidValue.Create; +end; + +function TImplDataVoidValue.GetAsString: string; +begin + Result := '(void)'; +end; + +function TImplDataVoidValue.GetDataType: IDataType; +begin + Result := TImplDataVoidType.Singleton; +end; + +{ TImplDataVoidType } + +function TImplDataVoidType.GetValue: IDataVoidValue; +begin + Result := TImplDataVoidValue.Singleton; +end; + +class constructor TImplDataVoidType.CreateSingleton; +begin + // Singleton instance created for the void type + FSingleton := TImplDataVoidType.Create; +end; + +function TImplDataVoidType.GetKind: TDataKind; +begin + Result := dkVoid; +end; + +function TImplDataVoidType.GetName: String; +begin + Result := 'Void'; +end; + +end.