From 70088d12a887e81f50a862889abd4d13c9599243 Mon Sep 17 00:00:00 2001 From: marco Date: Sun, 30 Mar 2014 12:03:10 +0000 Subject: [PATCH] * eliminate classes unit from the compiler by copying an array of string based extractstrings to cclasses. git-svn-id: trunk@27372 - --- compiler/cclasses.pas | 64 ++++++++++++++++++++++++++++++++++++++++++- compiler/optdead.pas | 9 +++--- 2 files changed, 67 insertions(+), 6 deletions(-) diff --git a/compiler/cclasses.pas b/compiler/cclasses.pas index a5b611ed53..0930634cb4 100644 --- a/compiler/cclasses.pas +++ b/compiler/cclasses.pas @@ -76,7 +76,7 @@ type TListSortCompare = function (Item1, Item2: Pointer): Integer; TListCallback = procedure(data,arg:pointer) of object; TListStaticCallback = procedure(data,arg:pointer); - + TDynStringArray = Array Of String; TFPList = class(TObject) private FList: PPointerList; @@ -589,12 +589,74 @@ type function FPHash(const s:shortstring):LongWord; inline; function FPHash(const a:ansistring):LongWord; inline; + function ExtractStrings(Separators, WhiteSpace: TSysCharSet; Content: PChar; var Strings: TDynStringArray; AddEmptyStrings : Boolean = False): Integer; implementation {***************************************************************************** Memory debug *****************************************************************************} + function ExtractStrings(Separators, WhiteSpace: TSysCharSet; Content: PChar; var Strings: TDynStringArray; AddEmptyStrings : Boolean = False): Integer; + var + b, c : pchar; + + procedure SkipWhitespace; + begin + while (c^ in Whitespace) do + inc (c); + end; + + procedure AddString; + var + l : integer; + s : string; + begin + l := c-b; + if (l > 0) or AddEmptyStrings then + begin + setlength(s, l); + if l>0 then + move (b^, s[1],l*SizeOf(char)); + l:=length(Strings); + setlength(Strings,l+1); + Strings[l]:=S; + inc (result); + end; + end; + + var + quoted : char; + begin + result := 0; + c := Content; + Quoted := #0; + Separators := Separators + [#13, #10] - ['''','"']; + SkipWhitespace; + b := c; + while (c^ <> #0) do + begin + if (c^ = Quoted) then + begin + if ((c+1)^ = Quoted) then + inc (c) + else + Quoted := #0 + end + else if (Quoted = #0) and (c^ in ['''','"']) then + Quoted := c^; + if (Quoted = #0) and (c^ in Separators) then + begin + AddString; + inc (c); + SkipWhitespace; + b := c; + end + else + inc (c); + end; + if (c <> b) then + AddString; + end; constructor tmemdebug.create(const s:string); begin diff --git a/compiler/optdead.pas b/compiler/optdead.pas index 827df77b87..576696ba42 100644 --- a/compiler/optdead.pas +++ b/compiler/optdead.pas @@ -28,7 +28,7 @@ unit optdead; uses globtype, - classes,cclasses, + cclasses, symtype, wpobase; @@ -71,7 +71,7 @@ unit optdead; fsymnamepos : longint; fsymfile : text; fsymfilename : tcmdstr; - aixstrings : tstringlist; + aixstrings : TDynStringArray; fuseaixextractstrings : boolean; function parselinenm(const line: ansistring): boolean; function parselineobjdump(const line: ansistring): boolean; @@ -229,7 +229,7 @@ const (aixstrings[0][1]='.') then fsymbols.add(copy(aixstrings[0],2,length(aixstrings[0])),pointer(1)); end; - aixstrings.clear; + setlength(aixstrings,0); end else begin @@ -330,7 +330,7 @@ const if not(line[1] in ['0'..'9','a'..'f','A'..'F']) then begin fuseaixextractstrings:=true; - aixstrings:=tstringlist.create; + setlength(aixstrings,0); result:=true; exit; end; @@ -462,7 +462,6 @@ const destructor twpodeadcodeinfofromexternallinker.destroy; begin - aixstrings.free; inherited destroy; end;