Add FPC Compabulity
This commit is contained in:
@@ -39,7 +39,7 @@
|
||||
<PackageName Value="FCL"/>
|
||||
</Item3>
|
||||
</RequiredPackages>
|
||||
<Units Count="3">
|
||||
<Units Count="4">
|
||||
<Unit0>
|
||||
<Filename Value="fpcunitproject1.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
@@ -50,9 +50,13 @@
|
||||
<UnitName Value="TestCase1"/>
|
||||
</Unit1>
|
||||
<Unit2>
|
||||
<Filename Value="..\Source\Fasm4Delphi.pas"/>
|
||||
<Filename Value="..\Source\FasmOnDelphi.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit2>
|
||||
<Unit3>
|
||||
<Filename Value="..\Fasm4Delphi\Source\Fasm4Delphi.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit3>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
@@ -60,11 +64,11 @@
|
||||
<PathDelim Value="\"/>
|
||||
<SearchPaths>
|
||||
<IncludeFiles Value="$(ProjOutDir)"/>
|
||||
<OtherUnitFiles Value="..\Source"/>
|
||||
<OtherUnitFiles Value="..\Source;..\Fasm4Delphi\Source"/>
|
||||
</SearchPaths>
|
||||
</CompilerOptions>
|
||||
<Debugging>
|
||||
<Exceptions Count="3">
|
||||
<Exceptions Count="4">
|
||||
<Item1>
|
||||
<Name Value="EAbort"/>
|
||||
</Item1>
|
||||
@@ -74,6 +78,9 @@
|
||||
<Item3>
|
||||
<Name Value="EFOpenError"/>
|
||||
</Item3>
|
||||
<Item4>
|
||||
<Name Value="EOSError"/>
|
||||
</Item4>
|
||||
</Exceptions>
|
||||
</Debugging>
|
||||
</CONFIG>
|
||||
|
||||
@@ -4,37 +4,217 @@
|
||||
<PathDelim Value="\"/>
|
||||
<Version Value="10"/>
|
||||
<BuildModes Active="Default"/>
|
||||
<Units Count="3">
|
||||
<Units Count="11">
|
||||
<Unit0>
|
||||
<Filename Value="fpcunitproject1.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<CursorPos X="66" Y="6"/>
|
||||
<UsageCount Value="20"/>
|
||||
<UsageCount Value="22"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit0>
|
||||
<Unit1>
|
||||
<Filename Value="testcase1.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="TestCase1"/>
|
||||
<IsVisibleTab Value="True"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<TopLine Value="21"/>
|
||||
<CursorPos X="62" Y="41"/>
|
||||
<UsageCount Value="20"/>
|
||||
<EditorIndex Value="1"/>
|
||||
<TopLine Value="17"/>
|
||||
<CursorPos X="67" Y="29"/>
|
||||
<UsageCount Value="22"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit1>
|
||||
<Unit2>
|
||||
<Filename Value="..\Source\Fasm4Delphi.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<WindowIndex Value="-1"/>
|
||||
<TopLine Value="-1"/>
|
||||
<CursorPos X="-1" Y="-1"/>
|
||||
<UsageCount Value="20"/>
|
||||
</Unit2>
|
||||
<Unit3>
|
||||
<Filename Value="..\..\Source\FasmOnDelphi.pas"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<WindowIndex Value="-1"/>
|
||||
<TopLine Value="-1"/>
|
||||
<CursorPos X="-1" Y="-1"/>
|
||||
<UsageCount Value="20"/>
|
||||
</Unit3>
|
||||
<Unit4>
|
||||
<Filename Value="..\Source\FasmOnDelphi.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<IsVisibleTab Value="True"/>
|
||||
<EditorIndex Value="2"/>
|
||||
<TopLine Value="217"/>
|
||||
<CursorPos Y="234"/>
|
||||
<UsageCount Value="22"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit4>
|
||||
<Unit5>
|
||||
<Filename Value="..\Fasm4Delphi\Source\Fasm4Delphi.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<EditorIndex Value="4"/>
|
||||
<TopLine Value="16"/>
|
||||
<CursorPos X="3" Y="31"/>
|
||||
<UsageCount Value="22"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit5>
|
||||
<Unit6>
|
||||
<Filename Value="C:\lazarus\fpc\3.0.2\source\rtl\inc\varianth.inc"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<TopLine Value="484"/>
|
||||
<CursorPos X="12" Y="496"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit6>
|
||||
<Unit7>
|
||||
<Filename Value="C:\lazarus\fpc\3.0.2\source\rtl\inc\wstringh.inc"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<TopLine Value="2"/>
|
||||
<CursorPos X="11" Y="19"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit7>
|
||||
<Unit8>
|
||||
<Filename Value="C:\lazarus\fpc\3.0.2\source\rtl\inc\ustringh.inc"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<TopLine Value="2"/>
|
||||
<CursorPos X="11" Y="19"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit8>
|
||||
<Unit9>
|
||||
<Filename Value="C:\lazarus\fpc\3.0.2\source\rtl\inc\systemh.inc"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<TopLine Value="1068"/>
|
||||
<CursorPos X="17" Y="1086"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit9>
|
||||
<Unit10>
|
||||
<Filename Value="C:\lazarus\fpc\3.0.2\source\rtl\win\wininc\base.inc"/>
|
||||
<EditorIndex Value="3"/>
|
||||
<TopLine Value="140"/>
|
||||
<CursorPos X="6" Y="169"/>
|
||||
<UsageCount Value="10"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit10>
|
||||
</Units>
|
||||
<General>
|
||||
<ActiveWindowIndexAtStart Value="-1"/>
|
||||
</General>
|
||||
<JumpHistory HistoryIndex="-1"/>
|
||||
<JumpHistory Count="30" HistoryIndex="29">
|
||||
<Position1>
|
||||
<Filename Value="testcase1.pas"/>
|
||||
<Caret Line="33" TopLine="17"/>
|
||||
</Position1>
|
||||
<Position2>
|
||||
<Filename Value="..\Source\FasmOnDelphi.pas"/>
|
||||
<Caret Line="429" Column="56" TopLine="427"/>
|
||||
</Position2>
|
||||
<Position3>
|
||||
<Filename Value="testcase1.pas"/>
|
||||
<Caret Line="33" TopLine="17"/>
|
||||
</Position3>
|
||||
<Position4>
|
||||
<Filename Value="..\Source\FasmOnDelphi.pas"/>
|
||||
<Caret Line="185" Column="44" TopLine="170"/>
|
||||
</Position4>
|
||||
<Position5>
|
||||
<Filename Value="testcase1.pas"/>
|
||||
<Caret Line="33" TopLine="17"/>
|
||||
</Position5>
|
||||
<Position6>
|
||||
<Filename Value="..\Source\FasmOnDelphi.pas"/>
|
||||
<Caret Line="185" Column="35" TopLine="174"/>
|
||||
</Position6>
|
||||
<Position7>
|
||||
<Filename Value="..\Source\FasmOnDelphi.pas"/>
|
||||
<Caret Line="188" Column="24" TopLine="171"/>
|
||||
</Position7>
|
||||
<Position8>
|
||||
<Filename Value="..\Source\FasmOnDelphi.pas"/>
|
||||
<Caret Line="198" Column="20" TopLine="180"/>
|
||||
</Position8>
|
||||
<Position9>
|
||||
<Filename Value="testcase1.pas"/>
|
||||
<Caret Line="33" TopLine="17"/>
|
||||
</Position9>
|
||||
<Position10>
|
||||
<Filename Value="..\Source\FasmOnDelphi.pas"/>
|
||||
<Caret Line="549" TopLine="533"/>
|
||||
</Position10>
|
||||
<Position11>
|
||||
<Filename Value="..\Source\FasmOnDelphi.pas"/>
|
||||
<Caret Line="539" TopLine="533"/>
|
||||
</Position11>
|
||||
<Position12>
|
||||
<Filename Value="testcase1.pas"/>
|
||||
<Caret Line="33" TopLine="17"/>
|
||||
</Position12>
|
||||
<Position13>
|
||||
<Filename Value="..\Source\FasmOnDelphi.pas"/>
|
||||
<Caret Line="537" Column="8" TopLine="533"/>
|
||||
</Position13>
|
||||
<Position14>
|
||||
<Filename Value="..\Source\FasmOnDelphi.pas"/>
|
||||
<Caret Line="185" Column="56" TopLine="169"/>
|
||||
</Position14>
|
||||
<Position15>
|
||||
<Filename Value="testcase1.pas"/>
|
||||
<Caret Line="33" TopLine="17"/>
|
||||
</Position15>
|
||||
<Position16>
|
||||
<Filename Value="testcase1.pas"/>
|
||||
<Caret Line="23" Column="11" TopLine="17"/>
|
||||
</Position16>
|
||||
<Position17>
|
||||
<Filename Value="..\Source\FasmOnDelphi.pas"/>
|
||||
<Caret Line="174" Column="17" TopLine="157"/>
|
||||
</Position17>
|
||||
<Position18>
|
||||
<Filename Value="..\Source\FasmOnDelphi.pas"/>
|
||||
<Caret Line="217" Column="6" TopLine="201"/>
|
||||
</Position18>
|
||||
<Position19>
|
||||
<Filename Value="..\Source\FasmOnDelphi.pas"/>
|
||||
<Caret Line="621" Column="58" TopLine="599"/>
|
||||
</Position19>
|
||||
<Position20>
|
||||
<Filename Value="..\Source\FasmOnDelphi.pas"/>
|
||||
<Caret Line="355" Column="29" TopLine="336"/>
|
||||
</Position20>
|
||||
<Position21>
|
||||
<Filename Value="..\Source\FasmOnDelphi.pas"/>
|
||||
<Caret Line="217" Column="5" TopLine="194"/>
|
||||
</Position21>
|
||||
<Position22>
|
||||
<Filename Value="..\Source\FasmOnDelphi.pas"/>
|
||||
<Caret Line="226" Column="32" TopLine="205"/>
|
||||
</Position22>
|
||||
<Position23>
|
||||
<Filename Value="testcase1.pas"/>
|
||||
<Caret Line="27" TopLine="17"/>
|
||||
</Position23>
|
||||
<Position24>
|
||||
<Filename Value="testcase1.pas"/>
|
||||
<Caret Line="23" Column="60" TopLine="17"/>
|
||||
</Position24>
|
||||
<Position25>
|
||||
<Filename Value="testcase1.pas"/>
|
||||
<Caret Line="27" TopLine="17"/>
|
||||
</Position25>
|
||||
<Position26>
|
||||
<Filename Value="..\Source\FasmOnDelphi.pas"/>
|
||||
<Caret Line="234" TopLine="217"/>
|
||||
</Position26>
|
||||
<Position27>
|
||||
<Filename Value="testcase1.pas"/>
|
||||
<Caret Line="23" Column="59" TopLine="17"/>
|
||||
</Position27>
|
||||
<Position28>
|
||||
<Filename Value="testcase1.pas"/>
|
||||
<Caret Line="29" Column="67" TopLine="17"/>
|
||||
</Position28>
|
||||
<Position29>
|
||||
<Filename Value="..\Source\FasmOnDelphi.pas"/>
|
||||
<Caret Line="234" TopLine="217"/>
|
||||
</Position29>
|
||||
<Position30>
|
||||
<Filename Value="..\Source\FasmOnDelphi.pas"/>
|
||||
<Caret Line="539" TopLine="523"/>
|
||||
</Position30>
|
||||
</JumpHistory>
|
||||
</ProjectSession>
|
||||
</CONFIG>
|
||||
|
||||
BIN
FPCTests/test
Normal file
BIN
FPCTests/test
Normal file
Binary file not shown.
@@ -5,7 +5,7 @@ unit TestCase1;
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, fpcunit, testutils, testregistry,Fasm4Delphi;
|
||||
Classes, SysUtils, fpcunit, testutils, testregistry,FasmOnDelphi;
|
||||
|
||||
type
|
||||
|
||||
@@ -16,36 +16,35 @@ type
|
||||
|
||||
implementation
|
||||
|
||||
const
|
||||
CompliterMemSize=$10000;
|
||||
|
||||
var
|
||||
CompliterMem:PFASM_STATE;
|
||||
|
||||
procedure TTestCase1.TestHookUp;
|
||||
var
|
||||
Res:TFasmResult;
|
||||
begin
|
||||
if fasm_AssembleFile('..\Tests\Test1.asm',CompliterMem,CompliterMemSize)<>FASM_OK then
|
||||
Fail('Error in test1:'+sLineBreak+
|
||||
'Condition: '+CompliterMem^.condition.ToString+sLineBreak+
|
||||
'Error Code: '+CompliterMem^.error_code.ToString);
|
||||
if fasm_Assemble('add eax,0',CompliterMem,CompliterMemSize)<>FASM_OK then
|
||||
writeln('Error in test2:'+sLineBreak+
|
||||
'Condition: '+CompliterMem^.condition.ToString+sLineBreak+
|
||||
'Error Code: '+CompliterMem^.error_code.ToString);
|
||||
if fasm_AssembleFile('..\FasmDll\FASM.ASH',CompliterMem,CompliterMemSize)=FASM_OK then
|
||||
Fail('Error in test3:'+sLineBreak+
|
||||
'FASM is compiling something that it is can not compile at all.');
|
||||
if fasm_Assemble('call -100',CompliterMem,CompliterMemSize)<>FASM_OK then
|
||||
Fail('Error in test4:'+sLineBreak+
|
||||
'Condition: '+CompliterMem^.condition.ToString+sLineBreak+
|
||||
'Error Code: '+CompliterMem^.error_code.ToString);
|
||||
Res:=FasmAssembleFileToFile('..\Tests\Test1.ASM','..\Tests\Test1.bin');
|
||||
if Res.Error<>FASM_OK then
|
||||
Fail('Error in test1:'+sLineBreak+
|
||||
'Condition: '+Res.OutStr+sLineBreak+
|
||||
'Error Code: '+IntToStr(Res.Error)+sLineBreak);
|
||||
Res:=FasmAssemble('add eax,0');
|
||||
if Res.Error<>FASM_OK then
|
||||
Fail('Error in test2:'+sLineBreak+
|
||||
'Condition: '+Res.OutStr+sLineBreak+
|
||||
'Error Code: '+IntToStr(Res.Error)+sLineBreak);
|
||||
Res:=FasmAssembleFile('..\Fasm4Delphi\FasmDll\FASM.ASH');
|
||||
if Res.Error=FASM_OK then
|
||||
Fail('Error in test3:'+sLineBreak+
|
||||
'FASM is compiling something that it is can not compile at all.');
|
||||
Res:=FasmAssembleToFile('add eax,0','test');
|
||||
if Res.Error<>FASM_OK then
|
||||
Fail('Error in test4:'+sLineBreak+
|
||||
'Condition: '+Res.OutStr+sLineBreak+
|
||||
'Error Code:'+IntToStr(Res.Error)+sLineBreak);
|
||||
end;
|
||||
|
||||
|
||||
|
||||
initialization
|
||||
LoadFASM('..\FasmDll\FASM.DLL');
|
||||
GetMem(CompliterMem,CompliterMemSize);
|
||||
OpenFASM('..\fasmw172\FASM.EXE');
|
||||
RegisterTest(TTestCase1);
|
||||
end.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
unit FasmOnDelphi platform;
|
||||
unit FasmOnDelphi;
|
||||
|
||||
{Delphi Translation&Tests:Artyom Gavrilov,Vlad Untkin.
|
||||
Donate:https://money.yandex.ru/to/410014959153552}
|
||||
@@ -20,9 +20,9 @@ interface
|
||||
{$ENDIF}
|
||||
|
||||
uses
|
||||
System.SysUtils,
|
||||
SysUtils,
|
||||
{$IFDEF USEFasm4Delphi}Fasm4Delphi,{$ENDIF}
|
||||
{$IFDEF USEIOUtils}System.IOUtils{$ENDIF},Windows,Math;
|
||||
{$IFDEF USEIOUtils}System.IOUtils,{$ENDIF}Windows,Math;
|
||||
|
||||
type
|
||||
TFasmVersion={$IFDEF USEFasm4Delphi}Fasm4Delphi.TFasmVersion;
|
||||
@@ -178,12 +178,51 @@ procedure SetFasmTemp(Path:string);
|
||||
|
||||
implementation
|
||||
|
||||
{$IFDEF FPC}
|
||||
function GetLongPathNameA(lpszShortPath: LPSTR; lpszLongPath: LPSTR;
|
||||
cchBuffer: DWORD): DWORD; stdcall;external 'Kernel32.dll';
|
||||
|
||||
function Pos(const SubStr,Str:AnsiString;Offset:Integer): Integer; overload;
|
||||
var
|
||||
I, LIterCnt, L, J: Integer;
|
||||
PSubStr, PS: PAnsiChar;
|
||||
begin
|
||||
L := Length(SubStr);
|
||||
{ Calculate the number of possible iterations. Not valid if Offset < 1. }
|
||||
LIterCnt := Length(Str) - Offset - L + 1;
|
||||
|
||||
{ Only continue if the number of iterations is positive or zero (there is space to check) }
|
||||
if (Offset > 0) and (LIterCnt >= 0) and (L > 0) then
|
||||
begin
|
||||
PSubStr := PAnsiChar(SubStr);
|
||||
PS := PAnsiChar(Str);
|
||||
Inc(PS, Offset - 1);
|
||||
|
||||
for I := 0 to LIterCnt do
|
||||
begin
|
||||
J := 0;
|
||||
while (J >= 0) and (J < L) do
|
||||
begin
|
||||
if PS[I + J] = PSubStr[J] then
|
||||
Inc(J)
|
||||
else
|
||||
J := -1;
|
||||
end;
|
||||
if J >= L then
|
||||
Exit(I + Offset);
|
||||
end;
|
||||
end;
|
||||
|
||||
Result := 0;
|
||||
end;
|
||||
{$ENDIF}
|
||||
|
||||
var
|
||||
FasmLocation:string='FASM';
|
||||
FasmTemp:string;
|
||||
IsDll:boolean=false;
|
||||
|
||||
function RunFasm(Command:string):string;
|
||||
function RunFasm(Command:AnsiString):string;
|
||||
var
|
||||
StartupInfo:TStartupInfo;
|
||||
ProcessInformation:TProcessInformation;
|
||||
@@ -227,7 +266,7 @@ var
|
||||
begin
|
||||
{$IFDEF USEFasm4Delphi}
|
||||
if IsDll then
|
||||
Result:=fasm_GetVersion
|
||||
Result:=fasm_GetVersion()
|
||||
else
|
||||
begin
|
||||
{$ENDIF}
|
||||
@@ -273,26 +312,26 @@ begin
|
||||
Result.Error:=fasm_Assemble(PAnsiChar(Source),Mem,cbMemorySize,nPassesLimit);
|
||||
if Result.Error=FASM_OK then
|
||||
begin
|
||||
GetMem(Result.OutData,Mem.output_length);
|
||||
CopyMemory(Result.OutData,Mem.output_data,Mem.output_length);
|
||||
Result.sb:=Mem.output_length;
|
||||
GetMem(Result.OutData,Mem^.output_length);
|
||||
CopyMemory(Result.OutData,Mem^.output_data,Mem^.output_length);
|
||||
Result.sb:=Mem^.output_length;
|
||||
Result.OutStr:='Success.';
|
||||
end
|
||||
else
|
||||
begin
|
||||
Result.OutData:=nil;
|
||||
Result.sb:=0;
|
||||
Result.OutStr:='Error: '+Mem.error_code.ToString+' '+FasmErrorCodeNames[Mem.error_code];
|
||||
p:=Mem.error_line;
|
||||
Result.OutStr:='Error: '+Mem^.error_code.ToString+' '+FasmErrorCodeNames[Mem^.error_code];
|
||||
p:=Mem^.error_line;
|
||||
nr:=0;
|
||||
while(NativeUInt(p)>=NativeUInt(Mem))and(NativeUInt(Mem)+NativeUInt(cbMemorySize)>=NativeUInt(p))do
|
||||
begin
|
||||
Result.OutStr:=Result.OutStr+sLineBreak+
|
||||
string(p.file_path)+'['+p.line_number.ToString+']';
|
||||
string(p^.file_path)+'['+p^.line_number.ToString+']';
|
||||
inc(nr);
|
||||
SetLength(Result.Lines,nr);
|
||||
Result.Lines[nr-1].Line:=p.line_number;
|
||||
Result.Lines[nr-1].&File:=string(p.file_path);
|
||||
Result.Lines[nr-1].Line:=p^.line_number;
|
||||
Result.Lines[nr-1].&File:=string(p^.file_path);
|
||||
p:=p^.macro_calling_line;
|
||||
end;
|
||||
end;
|
||||
@@ -318,7 +357,7 @@ begin
|
||||
Result.Error:=i0;
|
||||
if Result.Error=FASM_OK then
|
||||
begin
|
||||
FileHandle:=CreateFile(PWideChar(s),GENERIC_READ,0,nil,3,128,0);
|
||||
FileHandle:=CreateFile(PChar(s),GENERIC_READ,0,nil,3,128,0);
|
||||
Result.sb:=GetFileSize(FileHandle,nil);
|
||||
getmem(Result.OutData,Result.sb);
|
||||
ReadFile(FileHandle,Result.OutData,Result.sb,nr,nil);
|
||||
@@ -375,24 +414,24 @@ begin
|
||||
Result.sb:=0;
|
||||
if Result.Error=FASM_OK then
|
||||
begin
|
||||
FileHandle:=CreateFile(PWideChar(OutFile),GENERIC_READ,0,nil,3,128,0);
|
||||
WriteFile(FileHandle,Mem.output_data^,Mem.output_length,nr,nil);
|
||||
FileHandle:=CreateFile(PChar(OutFile),GENERIC_WRITE,0,nil,3,128,0);
|
||||
WriteFile(FileHandle,Mem^.output_data^,Mem^.output_length,nr,nil);
|
||||
CloseHandle(FileHandle);
|
||||
Result.OutStr:='Success.';
|
||||
end
|
||||
else
|
||||
begin
|
||||
Result.OutStr:='Error: '+Mem.error_code.ToString+' '+FasmErrorCodeNames[Mem.error_code];
|
||||
p:=Mem.error_line;
|
||||
Result.OutStr:='Error: '+Mem^.error_code.ToString+' '+FasmErrorCodeNames[Mem^.error_code];
|
||||
p:=Mem^.error_line;
|
||||
nr:=0;
|
||||
while(NativeUInt(p)>=NativeUInt(Mem))and(NativeUInt(Mem)+NativeUInt(cbMemorySize)>=NativeUInt(p))do
|
||||
begin
|
||||
Result.OutStr:=Result.OutStr+sLineBreak+
|
||||
string(p.file_path)+'['+p.line_number.ToString+']';
|
||||
string(p^.file_path)+'['+p^.line_number.ToString+']';
|
||||
inc(nr);
|
||||
SetLength(Result.Lines,nr);
|
||||
Result.Lines[nr-1].Line:=p.line_number;
|
||||
Result.Lines[nr-1].&File:=string(p.file_path);
|
||||
Result.Lines[nr-1].Line:=p^.line_number;
|
||||
Result.Lines[nr-1].&File:=string(p^.file_path);
|
||||
p:=p^.macro_calling_line;
|
||||
end;
|
||||
end;
|
||||
@@ -464,26 +503,26 @@ begin
|
||||
Result.Error:=fasm_AssembleFile(PAnsiChar(Source),Mem,cbMemorySize,nPassesLimit);
|
||||
if Result.Error=FASM_OK then
|
||||
begin
|
||||
GetMem(Result.OutData,Mem.output_length);
|
||||
CopyMemory(Result.OutData,Mem.output_data,Mem.output_length);
|
||||
Result.sb:=Mem.output_length;
|
||||
GetMem(Result.OutData,Mem^.output_length);
|
||||
CopyMemory(Result.OutData,Mem^.output_data,Mem^.output_length);
|
||||
Result.sb:=Mem^.output_length;
|
||||
Result.OutStr:='Success.';
|
||||
end
|
||||
else
|
||||
begin
|
||||
Result.OutData:=nil;
|
||||
Result.sb:=0;
|
||||
Result.OutStr:='Error: '+Mem.error_code.ToString+' '+FasmErrorCodeNames[Mem.error_code];
|
||||
p:=Mem.error_line;
|
||||
Result.OutStr:='Error: '+Mem^.error_code.ToString+' '+FasmErrorCodeNames[Mem^.error_code];
|
||||
p:=Mem^.error_line;
|
||||
nr:=0;
|
||||
while(NativeUInt(p)>=NativeUInt(Mem))and(NativeUInt(Mem)+NativeUInt(cbMemorySize)>=NativeUInt(p))do
|
||||
begin
|
||||
Result.OutStr:=Result.OutStr+sLineBreak+
|
||||
string(p.file_path)+'['+p.line_number.ToString+']';
|
||||
string(p^.file_path)+'['+p^.line_number.ToString+']';
|
||||
inc(nr);
|
||||
SetLength(Result.Lines,nr);
|
||||
Result.Lines[nr-1].Line:=p.line_number;
|
||||
Result.Lines[nr-1].&File:=string(p.file_path);
|
||||
Result.Lines[nr-1].Line:=p^.line_number;
|
||||
Result.Lines[nr-1].&File:=string(p^.file_path);
|
||||
p:=p^.macro_calling_line;
|
||||
end;
|
||||
end;
|
||||
@@ -505,7 +544,7 @@ begin
|
||||
Result.Error:=i0;
|
||||
if Result.Error=FASM_OK then
|
||||
begin
|
||||
FileHandle:=CreateFile(PWideChar(s),GENERIC_READ,0,nil,3,128,0);
|
||||
FileHandle:=CreateFile(PChar(s),GENERIC_READ,0,nil,3,128,0);
|
||||
Result.sb:=GetFileSize(FileHandle,nil);
|
||||
getmem(Result.OutData,Result.sb);
|
||||
ReadFile(FileHandle,Result.OutData,Result.sb,nr,nil);
|
||||
@@ -562,8 +601,8 @@ begin
|
||||
Result.sb:=0;
|
||||
if Result.Error=FASM_OK then
|
||||
begin
|
||||
FileHandle:=CreateFile(PWideChar(OutFile),GENERIC_READ,0,nil,3,128,0);
|
||||
WriteFile(FileHandle,Mem.output_data^,Mem.output_length,nr,nil);
|
||||
FileHandle:=CreateFile(PChar(OutFile),GENERIC_READ,0,nil,3,128,0);
|
||||
WriteFile(FileHandle,Mem^.output_data^,Mem^.output_length,nr,nil);
|
||||
CloseHandle(FileHandle);
|
||||
Result.OutStr:='Success.';
|
||||
end
|
||||
@@ -571,17 +610,17 @@ begin
|
||||
begin
|
||||
Result.OutData:=nil;
|
||||
Result.sb:=0;
|
||||
Result.OutStr:='Error: '+Mem.error_code.ToString+' '+FasmErrorCodeNames[Mem.error_code];
|
||||
p:=Mem.error_line;
|
||||
Result.OutStr:='Error: '+Mem^.error_code.ToString+' '+FasmErrorCodeNames[Mem^.error_code];
|
||||
p:=Mem^.error_line;
|
||||
nr:=0;
|
||||
while(NativeUInt(p)>=NativeUInt(Mem))and(NativeUInt(Mem)+NativeUInt(cbMemorySize)>=NativeUInt(p))do
|
||||
begin
|
||||
Result.OutStr:=Result.OutStr+sLineBreak+
|
||||
string(p.file_path)+'['+p.line_number.ToString+']';
|
||||
string(p^.file_path)+'['+p^.line_number.ToString+']';
|
||||
inc(nr);
|
||||
SetLength(Result.Lines,nr);
|
||||
Result.Lines[nr-1].Line:=p.line_number;
|
||||
Result.Lines[nr-1].&File:=string(p.file_path);
|
||||
Result.Lines[nr-1].Line:=p^.line_number;
|
||||
Result.Lines[nr-1].&File:=string(p^.file_path);
|
||||
p:=p^.macro_calling_line;
|
||||
end;
|
||||
end;
|
||||
@@ -658,12 +697,12 @@ initialization
|
||||
{$IFDEF FPC}
|
||||
{$IFDEF WINDOWS}
|
||||
begin
|
||||
SetLength(Result,MAX_PATH);
|
||||
SetLength(FasmTemp,MAX_PATH);
|
||||
Len:=GetTempPath(MAX_PATH,PChar(FasmTemp));
|
||||
if Len<>0 then
|
||||
begin
|
||||
Len:=GetLongPathName(PChar(FasmTemp),nil,0);
|
||||
GetLongPathName(PChar(FasmTemp),PChar(FasmTemp),Len);
|
||||
Len:=GetLongPathNameA(PChar(FasmTemp),nil,0);
|
||||
GetLongPathNameA(PChar(FasmTemp),PChar(FasmTemp),Len);
|
||||
SetLength(FasmTemp,Len-1);
|
||||
end
|
||||
else
|
||||
|
||||
@@ -22,12 +22,6 @@ type
|
||||
[Test]
|
||||
procedure Test4;
|
||||
end;
|
||||
|
||||
const
|
||||
CompliterMemSize=$10000;
|
||||
|
||||
var
|
||||
CompliterMem:PFASM_STATE;
|
||||
|
||||
implementation
|
||||
|
||||
@@ -45,8 +39,8 @@ var
|
||||
begin
|
||||
Res:=FasmAssembleFileToFile('..\..\Test1.ASM','..\..\Test1..bin');
|
||||
if Res.Error<>FASM_OK then
|
||||
raise Exception.Create('Condition: '+CompliterMem^.condition.ToString+sLineBreak+
|
||||
'Error Code: '+CompliterMem^.error_code.ToString+sLineBreak);
|
||||
raise Exception.Create('Condition: '+Res.OutStr+sLineBreak+
|
||||
'Error Code: '+IntToStr(Res.Error)+sLineBreak);
|
||||
end;
|
||||
|
||||
procedure TMyTestObject.Test2;
|
||||
@@ -74,12 +68,11 @@ var
|
||||
begin
|
||||
Res:=FasmAssembleToFile('add eax,0','test');
|
||||
if Res.Error<>FASM_OK then
|
||||
raise Exception.Create('Condition: '+Res.OutStr+sLineBreak+
|
||||
'Error Code: '+IntToStr(Res.Error)+sLineBreak);
|
||||
raise Exception.Create('Condition: '+Res.OutStr+sLineBreak+
|
||||
'Error Code:'+IntToStr(Res.Error)+sLineBreak);
|
||||
end;
|
||||
|
||||
initialization
|
||||
TDUnitX.RegisterTestFixture(TMyTestObject);
|
||||
OpenFASM('..\..\..\fasmw172\FASM.EXE');
|
||||
GetMem(CompliterMem,CompliterMemSize);
|
||||
end.
|
||||
|
||||
Reference in New Issue
Block a user