New type system

This commit is contained in:
Michael Schimmel
2025-08-26 15:49:28 +02:00
parent e9608a746a
commit 54d470b2f8
15 changed files with 58 additions and 364 deletions
+1 -42
View File
@@ -25,8 +25,7 @@ type
implementation
uses
System.Math,
System.Rtti;
System.Math;
type
// Implements the float data value.
@@ -39,7 +38,6 @@ type
// IDataValue
function GetDataType: IDataType;
function GetAsString: string;
function AsTValue: TValue;
// IDataFloatValue
function GetValue: Double;
@@ -47,28 +45,18 @@ type
// Special implementation for the value 0.0 (Singleton)
TImplDataFloatValueZero = class(TInterfacedObject, IDataValue, IDataFloatValue)
strict private
class var
FValue: TValue;
class constructor CreateClass;
public
function GetDataType: IDataType;
function GetAsString: string;
function GetValue: Double;
function AsTValue: TValue;
end;
// Special implementation for NaN (Not a Number) (Singleton)
TImplDataFloatValueNaN = class(TInterfacedObject, IDataValue, IDataFloatValue)
strict private
class var
FValue: TValue;
class constructor CreateClass;
public
function GetDataType: IDataType;
function GetAsString: string;
function GetValue: Double;
function AsTValue: TValue;
end;
{ TImplDataFloatValue }
@@ -89,23 +77,11 @@ begin
Result := FloatToStr(FValue);
end;
function TImplDataFloatValue.AsTValue: TValue;
begin
Result := TValue.From<Double>(FValue);
end;
function TImplDataFloatValue.GetValue: Double;
begin
Result := FValue;
end;
{ TImplDataFloatValueZero }
class constructor TImplDataFloatValueZero.CreateClass;
begin
FValue := TValue.From<Double>(0.0);
end;
function TImplDataFloatValueZero.GetAsString: string;
begin
Result := '0';
@@ -121,18 +97,6 @@ begin
Result := 0.0;
end;
function TImplDataFloatValueZero.AsTValue: TValue;
begin
Result := FValue;
end;
{ TImplDataFloatValueNaN }
class constructor TImplDataFloatValueNaN.CreateClass;
begin
FValue := TValue.From<Double>(NaN);
end;
function TImplDataFloatValueNaN.GetAsString: string;
begin
Result := 'NaN';
@@ -148,11 +112,6 @@ begin
Result := NaN;
end;
function TImplDataFloatValueNaN.AsTValue: TValue;
begin
Result := FValue;
end;
{ TImplDataFloatType }
class constructor TImplDataFloatType.CreateClass;