mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-10-25 10:41:42 +02:00
codetools: ppuparser: read ansistring
git-svn-id: trunk@47064 -
This commit is contained in:
parent
999e922a30
commit
0c37a917cb
@ -179,6 +179,26 @@ type
|
|||||||
cpu_i8086 { 15 }
|
cpu_i8086 { 15 }
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const
|
||||||
|
PPU_CPUNames : array[tsystemcpu] of string[9]=
|
||||||
|
('none',
|
||||||
|
'i386',
|
||||||
|
'm68k',
|
||||||
|
'alpha',
|
||||||
|
'powerpc',
|
||||||
|
'sparc',
|
||||||
|
'vis',
|
||||||
|
'ia64',
|
||||||
|
'x86_64',
|
||||||
|
'mips',
|
||||||
|
'arm',
|
||||||
|
'powerpc64',
|
||||||
|
'avr',
|
||||||
|
'mipsel',
|
||||||
|
'jvm',
|
||||||
|
'i8086'
|
||||||
|
);
|
||||||
|
|
||||||
// from ppu.pas
|
// from ppu.pas
|
||||||
{ We need to use the correct size of aint and pint for
|
{ We need to use the correct size of aint and pint for
|
||||||
the target CPU }
|
the target CPU }
|
||||||
@ -584,6 +604,7 @@ type
|
|||||||
|
|
||||||
TPPU = class
|
TPPU = class
|
||||||
private
|
private
|
||||||
|
FAIntSize: integer; // size of aint
|
||||||
fChangeEndian: boolean;
|
fChangeEndian: boolean;
|
||||||
FHeader: TPPUHeader;
|
FHeader: TPPUHeader;
|
||||||
FEntry: TPPUEntry;
|
FEntry: TPPUEntry;
|
||||||
@ -617,6 +638,8 @@ type
|
|||||||
function ReadEntryByte(const Msg: string): byte;
|
function ReadEntryByte(const Msg: string): byte;
|
||||||
function ReadEntryShortstring: shortstring;
|
function ReadEntryShortstring: shortstring;
|
||||||
function ReadEntryShortstring(const Msg: string): shortstring;
|
function ReadEntryShortstring(const Msg: string): shortstring;
|
||||||
|
function ReadEntryAnsistring: ansistring;
|
||||||
|
function ReadEntryAnsistring(const Msg: string): ansistring;
|
||||||
function ReadEntryLongint: longint;
|
function ReadEntryLongint: longint;
|
||||||
function ReadEntryLongint(const Msg: string): longint;
|
function ReadEntryLongint(const Msg: string): longint;
|
||||||
function ReadEntryDWord: cardinal;
|
function ReadEntryDWord: cardinal;
|
||||||
@ -627,6 +650,8 @@ type
|
|||||||
function ReadEntryInt64(const Msg: string): int64;
|
function ReadEntryInt64(const Msg: string): int64;
|
||||||
function ReadEntryQWord: QWord;
|
function ReadEntryQWord: QWord;
|
||||||
function ReadEntryQWord(const Msg: string): QWord;
|
function ReadEntryQWord(const Msg: string): QWord;
|
||||||
|
function ReadEntryAInt: int64;
|
||||||
|
function ReadEntryAInt(const Msg: string): int64;
|
||||||
procedure ReadEntrySmallSet(var s);
|
procedure ReadEntrySmallSet(var s);
|
||||||
procedure ReadEntryNormalSet(var s);
|
procedure ReadEntryNormalSet(var s);
|
||||||
procedure ReadUsedUnits;
|
procedure ReadUsedUnits;
|
||||||
@ -849,31 +874,9 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
function PPUCpuToStr(w:longint):string;
|
function PPUCpuToStr(w:longint):string;
|
||||||
type
|
|
||||||
{ Copied from systems.pas }
|
|
||||||
tsystemcpu=
|
|
||||||
(
|
|
||||||
cpu_no, { 0 }
|
|
||||||
cpu_i386, { 1 }
|
|
||||||
cpu_m68k, { 2 }
|
|
||||||
cpu_alpha, { 3 }
|
|
||||||
cpu_powerpc, { 4 }
|
|
||||||
cpu_sparc, { 5 }
|
|
||||||
cpu_vm, { 6 }
|
|
||||||
cpu_iA64, { 7 }
|
|
||||||
cpu_x86_64, { 8 }
|
|
||||||
cpu_mips, { 9 }
|
|
||||||
cpu_arm, { 10 }
|
|
||||||
cpu_powerpc64, { 11 }
|
|
||||||
cpu_avr { 12 }
|
|
||||||
);
|
|
||||||
const
|
|
||||||
CpuTxt : array[tsystemcpu] of string[9]=
|
|
||||||
('none','i386','m68k','alpha','powerpc','sparc','vis','ia64',
|
|
||||||
'x86_64','mips','arm','powerpc64','avr');
|
|
||||||
begin
|
begin
|
||||||
if w<=ord(high(tsystemcpu)) then
|
if w<=ord(high(tsystemcpu)) then
|
||||||
Result:=CpuTxt[tsystemcpu(w)]
|
Result:=PPU_CPUNames[tsystemcpu(w)]
|
||||||
else
|
else
|
||||||
Result:='<!! Unknown cpu value '+IntToStr(w)+'>';
|
Result:='<!! Unknown cpu value '+IntToStr(w)+'>';
|
||||||
end;
|
end;
|
||||||
@ -1150,6 +1153,8 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TPPU.ReadHeader;
|
procedure TPPU.ReadHeader;
|
||||||
|
var
|
||||||
|
cpu: tsystemcpu;
|
||||||
begin
|
begin
|
||||||
fChangeEndian:=PPUIsEndianBig;
|
fChangeEndian:=PPUIsEndianBig;
|
||||||
// read ID
|
// read ID
|
||||||
@ -1179,6 +1184,13 @@ begin
|
|||||||
FEntryPos:=0;
|
FEntryPos:=0;
|
||||||
FillByte(FEntry,SizeOf(FEntry),0);
|
FillByte(FEntry,SizeOf(FEntry),0);
|
||||||
|
|
||||||
|
{$R-}
|
||||||
|
cpu:=tsystemcpu(FHeader.cpu);
|
||||||
|
if (cpu<low(tsystemcpu)) or (cpu>high(tsystemcpu)) then
|
||||||
|
cpu:=tsystemcpu(FHeader.cpu);
|
||||||
|
{$R+}
|
||||||
|
FAIntSize:=CpuAluBitSize[cpu];
|
||||||
|
|
||||||
{$IFDEF VerbosePPUParser}
|
{$IFDEF VerbosePPUParser}
|
||||||
DumpHeader('');
|
DumpHeader('');
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
@ -1980,6 +1992,32 @@ begin
|
|||||||
debugln([Msg,Result]);
|
debugln([Msg,Result]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TPPU.ReadEntryAnsistring: ansistring;
|
||||||
|
var
|
||||||
|
l: longint;
|
||||||
|
|
||||||
|
procedure ErrorOutOfBytes;
|
||||||
|
begin
|
||||||
|
Error('TPPU.ReadEntryAnsistring: out of bytes. needed='+IntToStr(l)+', found='+IntToStr(FEntry.size-FEntryPos));
|
||||||
|
end;
|
||||||
|
|
||||||
|
begin
|
||||||
|
l:=ReadEntryLongint;
|
||||||
|
SetLength(Result,l);
|
||||||
|
if l>0 then begin
|
||||||
|
if FEntryPos+l>FEntry.size then
|
||||||
|
ErrorOutOfBytes;
|
||||||
|
System.Move(Pointer(FEntryBuf+FEntryPos)^,Result[1],l);
|
||||||
|
end;
|
||||||
|
inc(FEntryPos,l);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TPPU.ReadEntryAnsistring(const Msg: string): ansistring;
|
||||||
|
begin
|
||||||
|
Result:=ReadEntryAnsistring();
|
||||||
|
debugln([Msg,Result]);
|
||||||
|
end;
|
||||||
|
|
||||||
function TPPU.ReadEntryLongint: longint;
|
function TPPU.ReadEntryLongint: longint;
|
||||||
begin
|
begin
|
||||||
if FEntryPos+SizeOf(Longint)>FEntry.size then
|
if FEntryPos+SizeOf(Longint)>FEntry.size then
|
||||||
@ -2046,6 +2084,24 @@ begin
|
|||||||
debugln([Msg,Result]);
|
debugln([Msg,Result]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TPPU.ReadEntryAInt: int64;
|
||||||
|
begin
|
||||||
|
case FAIntSize of
|
||||||
|
8: result:=ReadEntryInt64;
|
||||||
|
4: result:=ReadEntryLongint;
|
||||||
|
2: result:=smallint(ReadEntryWord);
|
||||||
|
1: result:=shortint(ReadEntryByte);
|
||||||
|
else
|
||||||
|
Result:=0;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TPPU.ReadEntryAInt(const Msg: string): int64;
|
||||||
|
begin
|
||||||
|
Result:=ReadEntryAInt();
|
||||||
|
debugln([Msg,Result]);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TPPU.ReadEntrySmallSet(var s);
|
procedure TPPU.ReadEntrySmallSet(var s);
|
||||||
var
|
var
|
||||||
i: longint;
|
i: longint;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user