codetools: ppu parser: clean up

git-svn-id: trunk@48649 -
This commit is contained in:
mattias 2015-04-06 16:47:17 +00:00
parent 3bf0f2e328
commit 98ec5b2edc
2 changed files with 21 additions and 14 deletions

View File

@ -30,7 +30,7 @@ unit PPUCodeTools;
interface interface
uses uses
Classes, SysUtils, PPUParser, CodeCache, AVL_Tree, FileProcs; Classes, SysUtils, PPUParser, AVL_Tree, FileProcs;
type type

View File

@ -720,11 +720,11 @@ type
function ReadEntryAInt(const Msg: string): int64; function ReadEntryAInt(const Msg: string): int64;
function ReadEntryASizeInt: int64; function ReadEntryASizeInt: int64;
function ReadEntryASizeInt(const Msg: string): int64; function ReadEntryASizeInt(const Msg: string): int64;
procedure ReadEntrySmallSet(var s); procedure ReadEntrySmallSet(out s);
procedure ReadEntryNormalSet(var s); procedure ReadEntryNormalSet(out s);
procedure ReadUsedUnits; procedure ReadUsedUnits;
procedure ReadModuleOptions; procedure ReadModuleOptions;
procedure ReadLinkContainer(Nr: byte); procedure ReadLinkContainer(aContainerType: byte);
procedure ReadResources; procedure ReadResources;
procedure ReadImportSymbols; procedure ReadImportSymbols;
procedure ReadDerefData; procedure ReadDerefData;
@ -1078,7 +1078,7 @@ end;
function PPULinkContainerFlagToStr(Flags: longint): string; function PPULinkContainerFlagToStr(Flags: longint): string;
const const
{ link options } { link options }
link_none = $0; //link_none = $0;
link_always = $1; link_always = $1;
link_static = $2; link_static = $2;
link_smart = $4; link_smart = $4;
@ -1427,7 +1427,9 @@ end;
procedure TPPU.ReadDefinitions; procedure TPPU.ReadDefinitions;
type type
{
tsettype = (normset,smallset,varset); tsettype = (normset,smallset,varset);
tordtype = ( tordtype = (
uvoid, uvoid,
u8bit,u16bit,u32bit,u64bit, u8bit,u16bit,u32bit,u64bit,
@ -1448,6 +1450,7 @@ type
tvarianttype = ( tvarianttype = (
vt_normalvariant,vt_olevariant vt_normalvariant,vt_olevariant
); );
}
tprocinfoflag=( tprocinfoflag=(
{# procedure uses asm } {# procedure uses asm }
@ -1461,7 +1464,7 @@ type
{# procedure contains data which needs to be finalized } {# procedure contains data which needs to be finalized }
pi_needs_implicit_finally pi_needs_implicit_finally
); );
tprocinfoflags=set of tprocinfoflag; //tprocinfoflags=set of tprocinfoflag;
tsystemcpu= tsystemcpu=
( (
@ -1598,7 +1601,7 @@ begin
end; end;
procedure TPPU.ReadSymbols; procedure TPPU.ReadSymbols;
type {type
pguid = ^tguid; pguid = ^tguid;
tguid = packed record tguid = packed record
D1: LongWord; D1: LongWord;
@ -1623,7 +1626,7 @@ type
constresourcestring, constresourcestring,
constwstring, constwstring,
constguid constguid
); );}
var var
EntryNr: Byte; EntryNr: Byte;
begin begin
@ -2283,26 +2286,26 @@ begin
debugln([Msg,Result]); debugln([Msg,Result]);
end; end;
procedure TPPU.ReadEntrySmallSet(var s); procedure TPPU.ReadEntrySmallSet(out s);
var var
i: longint; i: longint;
begin begin
if FEntryPos+4>FEntry.size then if FEntryPos+4>FEntry.size then
Error('TPPU.ReadEntryLongint: out of bytes'); Error('TPPU.ReadEntryLongint: out of bytes');
System.Move(PByte(FEntryBuf+FEntryPos)^,s,4); System.Move(PByte(FEntryBuf+FEntryPos)^,s{%H-},4);
inc(FEntryPos,4); inc(FEntryPos,4);
if fChangeEndian then if fChangeEndian then
for i:=0 to 3 do for i:=0 to 3 do
Pbyte(@s)[i]:=reverse_byte(Pbyte(@s)[i]); Pbyte(@s)[i]:=reverse_byte(Pbyte(@s)[i]);
end; end;
procedure TPPU.ReadEntryNormalSet(var s); procedure TPPU.ReadEntryNormalSet(out s);
var var
i: longint; i: longint;
begin begin
if FEntryPos+32>FEntry.size then if FEntryPos+32>FEntry.size then
Error('TPPU.ReadEntryLongint: out of bytes'); Error('TPPU.ReadEntryLongint: out of bytes');
System.Move(PByte(FEntryBuf+FEntryPos)^,s,32); System.Move(PByte(FEntryBuf+FEntryPos)^,s{%H-},32);
inc(FEntryPos,32); inc(FEntryPos,32);
if fChangeEndian then if fChangeEndian then
for i:=0 to 31 do for i:=0 to 31 do
@ -2346,11 +2349,12 @@ type
mo_has_deprecated_msg mo_has_deprecated_msg
); );
tmoduleoptions = set of tmoduleoption; tmoduleoptions = set of tmoduleoption;
{$IFDEF VerbosePPUParser}
type
tmoduleopt=record tmoduleopt=record
mask : tmoduleoption; mask : tmoduleoption;
str : string[30]; str : string[30];
end; end;
{$IFDEF VerbosePPUParser}
const const
moduleopts=6; moduleopts=6;
moduleopt : array[1..moduleopts] of tmoduleopt=( moduleopt : array[1..moduleopts] of tmoduleopt=(
@ -2391,7 +2395,7 @@ begin
end; end;
end; end;
procedure TPPU.ReadLinkContainer(Nr: byte); procedure TPPU.ReadLinkContainer(aContainerType: byte);
{$IFDEF VerbosePPUParser} {$IFDEF VerbosePPUParser}
var var
Desc: String; Desc: String;
@ -2400,6 +2404,9 @@ var
Flags: LongInt; Flags: LongInt;
{$ENDIF} {$ENDIF}
begin begin
{$IFNDEF VerbosePPUParser}
if aContainerType=0 then ;
{$ENDIF}
while not EndOfEntry do begin while not EndOfEntry do begin
{$IFDEF VerbosePPUParser}Filename:={$ENDIF}ReadEntryShortstring; {$IFDEF VerbosePPUParser}Filename:={$ENDIF}ReadEntryShortstring;
{$IFDEF VerbosePPUParser}Flags:={$ENDIF}ReadEntryLongint; {$IFDEF VerbosePPUParser}Flags:={$ENDIF}ReadEntryLongint;