Type System

This commit is contained in:
Michael Schimmel
2025-08-26 11:06:35 +02:00
parent e4681e2bf7
commit 5adbe67d0b
15 changed files with 1426 additions and 612 deletions
+21 -21
View File
@@ -9,7 +9,7 @@ uses
type
// Implements the IDataMethodType interface.
TDataMethodType = class(TInterfacedObject, IDataMethodType)
TImplDataMethodType = class(TInterfacedObject, IDataMethodType)
private
FArgType: IDataType;
FResultType: IDataType;
@@ -17,7 +17,7 @@ type
function GetKind: TDataKind;
function GetArgType: IDataType;
function GetResultType: IDataType;
function CreateValue(const AValue: TMethodProc): IDataMethodValue;
function CreateValue(const AValue: TDataMethodProc): IDataMethodValue;
public
constructor Create(const AArgType, AResultType: IDataType);
end;
@@ -29,51 +29,51 @@ uses
type
// Implements the IDataMethodValue interface.
TDataMethodValue = class(TInterfacedObject, IDataMethodValue)
TImplDataMethodValue = class(TInterfacedObject, IDataMethodValue)
private
FDataType: IDataMethodType;
FValue: TMethodProc;
FValue: TDataMethodProc;
function GetDataType: IDataType;
function GetAsString: string;
function AsTValue: TValue;
function GetValue: TMethodProc;
function GetValue: TDataMethodProc;
public
constructor Create(const ADataType: IDataMethodType; const AValue: TMethodProc);
constructor Create(const ADataType: IDataMethodType; const AValue: TDataMethodProc);
end;
{ TDataMethodType }
{ TImplDataMethodType }
constructor TDataMethodType.Create(const AArgType, AResultType: IDataType);
constructor TImplDataMethodType.Create(const AArgType, AResultType: IDataType);
begin
inherited Create;
FArgType := AArgType;
FResultType := AResultType;
end;
function TDataMethodType.CreateValue(const AValue: TMethodProc): IDataMethodValue;
function TImplDataMethodType.CreateValue(const AValue: TDataMethodProc): IDataMethodValue;
begin
if not Assigned(AValue) then
raise EArgumentException.Create('AValue');
Result := TDataMethodValue.Create(Self, AValue);
Result := TImplDataMethodValue.Create(Self, AValue);
end;
function TDataMethodType.GetArgType: IDataType;
function TImplDataMethodType.GetArgType: IDataType;
begin
Result := FArgType;
end;
function TDataMethodType.GetResultType: IDataType;
function TImplDataMethodType.GetResultType: IDataType;
begin
Result := FResultType;
end;
function TDataMethodType.GetKind: TDataKind;
function TImplDataMethodType.GetKind: TDataKind;
begin
Result := dkMethod;
end;
function TDataMethodType.GetName: String;
function TImplDataMethodType.GetName: String;
var
sb: TStringBuilder;
argName, resultName: string;
@@ -101,31 +101,31 @@ begin
end;
end;
{ TDataMethodValue }
{ TImplDataMethodValue }
constructor TDataMethodValue.Create(const ADataType: IDataMethodType; const AValue: TMethodProc);
constructor TImplDataMethodValue.Create(const ADataType: IDataMethodType; const AValue: TDataMethodProc);
begin
inherited Create;
FDataType := ADataType;
FValue := AValue;
end;
function TDataMethodValue.GetDataType: IDataType;
function TImplDataMethodValue.GetDataType: IDataType;
begin
Result := FDataType;
end;
function TDataMethodValue.GetAsString: string;
function TImplDataMethodValue.GetAsString: string;
begin
Result := '<METHOD>';
end;
function TDataMethodValue.AsTValue: TValue;
function TImplDataMethodValue.AsTValue: TValue;
begin
Result := TValue.From<TMethodProc>(FValue);
Result := TValue.From<TDataMethodProc>(FValue);
end;
function TDataMethodValue.GetValue: TMethodProc;
function TImplDataMethodValue.GetValue: TDataMethodProc;
begin
Result := FValue;
end;