85 lines
1.8 KiB
ObjectPascal
85 lines
1.8 KiB
ObjectPascal
unit RuntimeBuilder.Types;
|
|
|
|
interface
|
|
|
|
uses System.TypInfo,System.Rtti;
|
|
|
|
const
|
|
CRTBCallTypeNil=$0;
|
|
CRTBCallTypeRegister=$1;
|
|
CRTBCallTypeStdCall=$2;
|
|
CRTBCallTypeCdecl=$3;
|
|
CRTBCallTypePascal=$4;
|
|
CRTBCallTypeSafeCall=$5;
|
|
CRTBCallType64Call=$40;
|
|
CRTBCallTypeDefault=$80;
|
|
|
|
type
|
|
TRTBCompiler=class;
|
|
|
|
TRTBCallType=CRTBCallTypeNil..CRTBCallTypeDefault;
|
|
|
|
TRTBFunc=class abstract
|
|
public
|
|
function Call(OutType:PTypeInfo;args:TArray<TValue>;CallType:TRTBCallType=CRTBCallTypeDefault):TValue;virtual;abstract;
|
|
end;
|
|
|
|
TRTBLib=class abstract
|
|
protected
|
|
function GetFuntion(Name:string):TRTBFunc;virtual;abstract;
|
|
public
|
|
property Funtion[Name:string]:TRTBFunc read GetFuntion;
|
|
end;
|
|
|
|
TRTBSource=class abstract
|
|
protected
|
|
Compiler:TRTBCompiler;
|
|
function GetText:string;virtual;abstract;
|
|
procedure SetText(S:string);virtual;abstract;
|
|
public
|
|
constructor Create(Compiler:TRTBCompiler);
|
|
function CompilateAsFunc:TRTBFunc;virtual;abstract;
|
|
function CompilateAsLib:TRTBLib;virtual;abstract;
|
|
procedure LoadFromFile(&File:string);
|
|
procedure SaveToFile(&File:string);
|
|
property Text:string read GetText write SetText;
|
|
end;
|
|
|
|
TRTBCompiler=class abstract
|
|
public
|
|
function LoadLib(Name:string):TRTBLib;virtual;abstract;
|
|
function GenNewSrc():TRTBSource;virtual;abstract;
|
|
end;
|
|
|
|
implementation
|
|
|
|
uses
|
|
System.SysUtils,System.Classes;
|
|
|
|
constructor TRTBSource.Create(Compiler:TRTBCompiler);
|
|
begin
|
|
Self.Compiler:=Compiler;
|
|
end;
|
|
|
|
procedure TRTBSource.LoadFromFile(&File:string);
|
|
var
|
|
Data:TStrings;
|
|
begin
|
|
Data:=TStringList.Create;
|
|
Data.LoadFromFile(&File);
|
|
Text:=Data.Text;
|
|
FreeAndNil(Data);
|
|
end;
|
|
|
|
procedure TRTBSource.SaveToFile(&File:string);
|
|
var
|
|
Data:TStrings;
|
|
begin
|
|
Data:=TStringList.Create;
|
|
Data.Text:=Text;
|
|
Data.SaveToFile(&File);
|
|
FreeAndNil(Data);
|
|
end;
|
|
|
|
end.
|