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