New type system
This commit is contained in:
@@ -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.
|
||||
Reference in New Issue
Block a user