From c3e9de4bf9db2d3162a521ab93b5b1661df0631c Mon Sep 17 00:00:00 2001 From: Artem3213212 Date: Fri, 13 Apr 2018 09:38:20 +0300 Subject: [PATCH] Fix abstract fasm part --- Source/RuntimeBuilder.Fasm.pas | 45 +++++++++++++++++++++++----- Tests/Unit1.pas | 4 +-- Tests/Win64/Debug/dunitx-results.xml | 26 ---------------- 3 files changed, 39 insertions(+), 36 deletions(-) delete mode 100644 Tests/Win64/Debug/dunitx-results.xml diff --git a/Source/RuntimeBuilder.Fasm.pas b/Source/RuntimeBuilder.Fasm.pas index 0294f3f..87f36fa 100644 --- a/Source/RuntimeBuilder.Fasm.pas +++ b/Source/RuntimeBuilder.Fasm.pas @@ -28,7 +28,7 @@ type p:pointer; &Type:TRTBType; procedure SetVal(Val:TValue);override; - //function GetVal:TValue;override; + function GetVal:TValue;override; public constructor Create(p:pointer;&Type:TRTBType); destructor Destroy;override; @@ -55,7 +55,7 @@ type public constructor Create(Compiler:TRTBFasmCompiler); - {procedure LoadLib(Name:string);override; + procedure LoadLib(Name:string);override; procedure UnLoadLib(Name:string);override; procedure AddNameSpace(Name:string);override; @@ -65,7 +65,7 @@ type procedure ExportType(NameSpace:string;Name:string;&Type:TRTBType);override; procedure DelType(NameSpace:string;Name:string);override; - procedure AddConst(NameSpace:string;Name:string;Val:TValue);override; + {procedure AddConst(NameSpace:string;Name:string;Val:TValue);override; procedure ExportConst(NameSpace:string;Name:string;Val:TValue);override; procedure DelConst(NameSpace:string;Name:string);override; @@ -124,6 +124,11 @@ if Val.TypeInfo=&Type then Val.ExtractRawData(p); end; +function TRTBFasmCompiler.TRTBFasmSource.TRTBFasmModule.TRTBFasmVar.GetVal:TValue; +begin +TValue.Make(p,&Type,Result); +end; + constructor TRTBFasmCompiler.TRTBFasmSource.TRTBFasmModule.TRTBFasmVar.Create(p:pointer;&Type:TRTBType); begin Self.p:=p; @@ -202,10 +207,36 @@ funcs:=TStringList.Create; regvars:=TList>.Create; end; -{function TRTBFasmCompiler.TRTBFasmSource.LoadLib(Name:string):TRTBLib; +procedure TRTBFasmCompiler.TRTBFasmSource.LoadLib(Name:string); begin libs.Add(Name); -end;} +end; + +procedure TRTBFasmCompiler.TRTBFasmSource.UnLoadLib(Name:string); +begin +with libs do + Delete(IndexOf(Name)); +end; + +procedure TRTBFasmCompiler.TRTBFasmSource.AddNameSpace(Name:string); +begin +end; + +procedure TRTBFasmCompiler.TRTBFasmSource.DelNameSpace(Name:string); +begin +end; + +procedure TRTBFasmCompiler.TRTBFasmSource.AddType(NameSpace:string;Name:string;&Type:TRTBType); +begin +end; + +procedure ExportType(NameSpace:string;Name:string;&Type:TRTBType); +begin +end; + +procedure DelType(NameSpace:string;Name:string); +begin +end; procedure TRTBFasmCompiler.TRTBFasmSource.&Register(NameSpace:string;Name:string;&Type:TRTBType); begin @@ -282,14 +313,12 @@ with regvars do end; sb:=(Compiler as TRTBFasmCompiler).CompilerMem; p:=VirtualAlloc(nil,sb,MEM_COMMIT,PAGE_EXECUTE_READWRITE); -Res:=FasmAssemble('org '+NativeUint(p).ToString+ - sLineBreak+PreDecl+Text+GetIncLibs,sb,(Compiler as TRTBFasmCompiler).MaxSteps); +Res:=FasmAssemble('org '+NativeUint(p).ToString+sLineBreak+PreDecl+Text+GetIncLibs,sb,(Compiler as TRTBFasmCompiler).MaxSteps); if Res.Error<>FASM_OK then begin VirtualFree(p,sb,MEM_RELEASE); raise Exception.Create(Res.OutStr); end; -//VirtualFree(p,sb,MEM_RELEASE); VirtualAlloc(p,Res.sb,MEM_COMMIT,PAGE_EXECUTE_READWRITE); CopyMemory(p,Res.OutData,Res.sb); FreeMem(Res.OutData); diff --git a/Tests/Unit1.pas b/Tests/Unit1.pas index d8b33fc..1af532a 100644 --- a/Tests/Unit1.pas +++ b/Tests/Unit1.pas @@ -40,8 +40,8 @@ begin raise Exception.Create('Error in test1'); end; Var1:=Module.&Var['Pmain']; -Var1.Val:=454; -if 454<>Func2.Call(TypeInfo(integer),[],CRTBCallTypeStdCall).AsInteger then +Var1.Val:=424; +if Var1.Val.AsInteger<>Func2.Call(TypeInfo(integer),[],CRTBCallTypeStdCall).AsInteger then begin raise Exception.Create('Error in test1'); end; diff --git a/Tests/Win64/Debug/dunitx-results.xml b/Tests/Win64/Debug/dunitx-results.xml deleted file mode 100644 index e5d16f2..0000000 --- a/Tests/Win64/Debug/dunitx-results.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - -