Fasm Added
This commit is contained in:
@@ -2,58 +2,90 @@ unit RuntimeBuilder.Fasm;
|
|||||||
|
|
||||||
interface
|
interface
|
||||||
|
|
||||||
uses RuntimeBuilder.Types;
|
uses RuntimeBuilder.Types,FasmOnDelphi;
|
||||||
|
|
||||||
|
|
||||||
type
|
type
|
||||||
{TRTBFasmFunc=class(TRTBFunc)
|
TRTBFasmCompiler=class(TRTBCompiler)
|
||||||
public
|
protected type
|
||||||
function Call(args:array of const;CallType:TRTBCallType=CRTBCallTypeDefault):Variant;override;
|
TRTBFasmSource=class(TRTBSource)
|
||||||
end;}
|
protected type
|
||||||
|
TRTBFasmFunc=class(TRTBFunc)
|
||||||
{TRTBLib=class abstract
|
protected
|
||||||
private
|
p:Pointer;
|
||||||
function GetFuntion(Name:string):TRTBFunc;virtual;abstract;
|
sb:NativeUInt;
|
||||||
public
|
public
|
||||||
property Funtion[Name:string]:TRTBFunc read GetFuntion;
|
constructor Create(p:Pointer;sb:NativeUInt);
|
||||||
end;}
|
//function Call(args:array of const;CallType:TRTBCallType=CRTBCallTypeDefault):Variant;override;
|
||||||
|
end;
|
||||||
TRTBFasmCompliter=class(TRTBCompliter)
|
TRTBLib=class abstract
|
||||||
private type
|
private
|
||||||
TRTBSource=class abstract
|
//function GetFuntion(Name:string):TRTBFunc;virtual;abstract;
|
||||||
private
|
public
|
||||||
FText:string;;
|
//property Funtion[Name:string]:TRTBFunc read GetFuntion;
|
||||||
function GetText:string;
|
end;
|
||||||
procedure SetText(S:string);
|
protected
|
||||||
|
FText:string;
|
||||||
|
function GetText:string;override;
|
||||||
|
procedure SetText(S:string);override;
|
||||||
public
|
public
|
||||||
constructor Create();
|
constructor Create(Compiler:TRTBFasmCompiler);
|
||||||
//procedure CompleteAsLib:TRTBLib;virtual;abstract;
|
function CompilateAsFunc:TRTBFunc;override;
|
||||||
//procedure CompleteAsFunc:TRTBLib;virtual;abstract;
|
//function CompilateAsLib:TRTBLib;virtual;abstract;
|
||||||
end;
|
end;
|
||||||
public
|
public
|
||||||
|
CompilerMem:NativeUInt;
|
||||||
|
MaxSteps:word;
|
||||||
|
constructor Create(FasmPath:String=FasmPath;AsDll:boolean=false);
|
||||||
//function LoadLib(Name:string):TRTBLib;
|
//function LoadLib(Name:string):TRTBLib;
|
||||||
function GenNewSrc():TRTBFasmSource;override;
|
function GenNewSrc():TRTBSource;override;
|
||||||
//function CompleteFunc(Source:TRTBSource;args:array of const):TRTBFunc;virtual;abstract;
|
|
||||||
//function CompleteLib(Source:TRTBSource;args:array of const):TRTBLib;virtual;abstract;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
constructor TRTBFasmCompliter.TRTBSource.Create();
|
uses System.SysUtils;
|
||||||
|
|
||||||
|
constructor TRTBFasmCompiler.TRTBFasmSource.TRTBFasmFunc.Create(p:Pointer;sb:NativeUInt);
|
||||||
begin
|
begin
|
||||||
|
Self.p:=p;
|
||||||
|
Self.sb:=sb;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TRTBFasmCompiler.TRTBFasmSource.GetText:string;
|
||||||
|
begin
|
||||||
|
Result:=FText;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TRTBFasmCompiler.TRTBFasmSource.SetText(S:string);
|
||||||
|
begin
|
||||||
|
FText:=S;
|
||||||
|
end;
|
||||||
|
|
||||||
|
constructor TRTBFasmCompiler.TRTBFasmSource.Create(Compiler:TRTBFasmCompiler);
|
||||||
|
begin
|
||||||
|
inherited Create(Compiler);
|
||||||
FText:='';
|
FText:='';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function GTRTBFasmCompliter.TRTBSource.etText:string;
|
function TRTBFasmCompiler.TRTBFasmSource.CompilateAsFunc:TRTBFunc;
|
||||||
|
var
|
||||||
|
Res:TFasmResult;
|
||||||
begin
|
begin
|
||||||
|
Res:=FasmAssemble(Text,(Compiler as TRTBFasmCompiler).CompilerMem,(Compiler as TRTBFasmCompiler).MaxSteps);
|
||||||
|
if Res.Error<>FASM_OK then
|
||||||
|
raise Exception.Create(Res.OutStr);
|
||||||
|
Result:=TRTBFasmFunc.Create(Res.OutData,Res.sb);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TRTBFasmCompliter.TRTBSource.SetText(S:string);
|
constructor TRTBFasmCompiler.Create(FasmPath:String=FasmPath;AsDll:boolean=false);
|
||||||
|
|
||||||
function TRTBFasmCompliter.GenNewSrc():TRTBSource;
|
|
||||||
begin
|
begin
|
||||||
Result:=;
|
CompilerMem:=1024*1024*16;
|
||||||
|
MaxSteps:=65535;
|
||||||
|
OpenFASM(FasmPath,AsDll);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TRTBFasmCompiler.GenNewSrc():TRTBSource;
|
||||||
|
begin
|
||||||
|
Result:=TRTBFasmSource.Create(Self);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ const
|
|||||||
CRTBCallTypeDefault=$80;
|
CRTBCallTypeDefault=$80;
|
||||||
|
|
||||||
type
|
type
|
||||||
TRTBCompliter=class;
|
TRTBCompiler=class;
|
||||||
|
|
||||||
TRTBCallType=CRTBCallTypeNil..CRTBCallTypeDefault;
|
TRTBCallType=CRTBCallTypeNil..CRTBCallTypeDefault;
|
||||||
|
|
||||||
@@ -27,31 +27,60 @@ type
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
TRTBLib=class abstract
|
TRTBLib=class abstract
|
||||||
private
|
protected
|
||||||
function GetFuntion(Name:string):TRTBFunc;virtual;abstract;
|
function GetFuntion(Name:string):TRTBFunc;virtual;abstract;
|
||||||
public
|
public
|
||||||
property Funtion[Name:string]:TRTBFunc read GetFuntion;
|
property Funtion[Name:string]:TRTBFunc read GetFuntion;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TRTBSource=class abstract
|
TRTBSource=class abstract
|
||||||
private
|
protected
|
||||||
Compliter:TRTBCompliter;
|
Compiler:TRTBCompiler;
|
||||||
function GetText:string;virtual;abstract;
|
function GetText:string;virtual;abstract;
|
||||||
procedure SetText(S:string);virtual;abstract;
|
procedure SetText(S:string);virtual;abstract;
|
||||||
public
|
public
|
||||||
procedure CompleteAsLib:TRTBLib;virtual;abstract;
|
constructor Create(Compiler:TRTBCompiler);
|
||||||
procedure CompleteAsFunc:TRTBLib;virtual;abstract;
|
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;
|
property Text:string read GetText write SetText;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TRTBCompliter=class abstract
|
TRTBCompiler=class abstract
|
||||||
public
|
public
|
||||||
function LoadLib(Name:string):TRTBLib;virtual;abstract;
|
function LoadLib(Name:string):TRTBLib;virtual;abstract;
|
||||||
function GenNewSrc():TRTBSource;virtual;abstract;
|
function GenNewSrc():TRTBSource;virtual;abstract;
|
||||||
function CompleteFunc(Source:TRTBSource;args:array of const):TRTBFunc;virtual;abstract;
|
|
||||||
function CompleteLib(Source:TRTBSource;args:array of const):TRTBLib;virtual;abstract;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
implementation
|
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.
|
end.
|
||||||
|
|||||||
@@ -13,7 +13,10 @@ uses
|
|||||||
DUnitX.TestFramework,
|
DUnitX.TestFramework,
|
||||||
Unit1 in 'Unit1.pas',
|
Unit1 in 'Unit1.pas',
|
||||||
RuntimeBuilder in '..\Source\RuntimeBuilder.pas',
|
RuntimeBuilder in '..\Source\RuntimeBuilder.pas',
|
||||||
RuntimeBuilder.Types in '..\Source\RuntimeBuilder.Types.pas';
|
RuntimeBuilder.Types in '..\Source\RuntimeBuilder.Types.pas',
|
||||||
|
RuntimeBuilder.Fasm in '..\Source\RuntimeBuilder.Fasm.pas',
|
||||||
|
FasmOnDelphi in '..\FasmOnDelphi\Source\FasmOnDelphi.pas',
|
||||||
|
Fasm4Delphi in '..\FasmOnDelphi\Fasm4Delphi\Source\Fasm4Delphi.pas';
|
||||||
|
|
||||||
var
|
var
|
||||||
runner : ITestRunner;
|
runner : ITestRunner;
|
||||||
|
|||||||
@@ -95,6 +95,9 @@
|
|||||||
<DCCReference Include="Unit1.pas"/>
|
<DCCReference Include="Unit1.pas"/>
|
||||||
<DCCReference Include="..\Source\RuntimeBuilder.pas"/>
|
<DCCReference Include="..\Source\RuntimeBuilder.pas"/>
|
||||||
<DCCReference Include="..\Source\RuntimeBuilder.Types.pas"/>
|
<DCCReference Include="..\Source\RuntimeBuilder.Types.pas"/>
|
||||||
|
<DCCReference Include="..\Source\RuntimeBuilder.Fasm.pas"/>
|
||||||
|
<DCCReference Include="..\FasmOnDelphi\Source\FasmOnDelphi.pas"/>
|
||||||
|
<DCCReference Include="..\FasmOnDelphi\Fasm4Delphi\Source\Fasm4Delphi.pas"/>
|
||||||
<BuildConfiguration Include="Release">
|
<BuildConfiguration Include="Release">
|
||||||
<Key>Cfg_2</Key>
|
<Key>Cfg_2</Key>
|
||||||
<CfgParent>Base</CfgParent>
|
<CfgParent>Base</CfgParent>
|
||||||
@@ -451,13 +454,13 @@
|
|||||||
<Operation>1</Operation>
|
<Operation>1</Operation>
|
||||||
</Platform>
|
</Platform>
|
||||||
</DeployClass>
|
</DeployClass>
|
||||||
<ProjectRoot Platform="iOSDevice32" Name="$(PROJECTNAME).app"/>
|
<ProjectRoot Platform="iOSSimulator" Name="$(PROJECTNAME).app"/>
|
||||||
<ProjectRoot Platform="Android" Name="$(PROJECTNAME)"/>
|
<ProjectRoot Platform="Android" Name="$(PROJECTNAME)"/>
|
||||||
<ProjectRoot Platform="Win32" Name="$(PROJECTNAME)"/>
|
<ProjectRoot Platform="Win32" Name="$(PROJECTNAME)"/>
|
||||||
<ProjectRoot Platform="iOSDevice64" Name="$(PROJECTNAME).app"/>
|
<ProjectRoot Platform="iOSDevice64" Name="$(PROJECTNAME).app"/>
|
||||||
<ProjectRoot Platform="Win64" Name="$(PROJECTNAME)"/>
|
<ProjectRoot Platform="Win64" Name="$(PROJECTNAME)"/>
|
||||||
<ProjectRoot Platform="OSX32" Name="$(PROJECTNAME)"/>
|
<ProjectRoot Platform="OSX32" Name="$(PROJECTNAME)"/>
|
||||||
<ProjectRoot Platform="iOSSimulator" Name="$(PROJECTNAME).app"/>
|
<ProjectRoot Platform="iOSDevice32" Name="$(PROJECTNAME).app"/>
|
||||||
</Deployment>
|
</Deployment>
|
||||||
<Platforms>
|
<Platforms>
|
||||||
<Platform value="OSX32">False</Platform>
|
<Platform value="OSX32">False</Platform>
|
||||||
|
|||||||
Reference in New Issue
Block a user