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