* refactored TOmfLibObjectWriter, so it keeps all object modules in a

TFPObjectList. This will allow implementing omf library page size optimization
  later.

git-svn-id: trunk@39192 -
This commit is contained in:
nickysn 2018-06-07 15:03:05 +00:00
parent af5e6e182d
commit 4bcfe8dbb2

View File

@ -41,6 +41,19 @@ type
strict private strict private
type type
{ TOmfLibObjectModule }
TOmfLibObjectModule=class
strict private
FObjFileName: string;
FObjData: TDynamicArray;
public
constructor Create(const fn:string);
destructor Destroy; override;
property ObjData: TDynamicArray read FObjData;
end;
{ TOmfLibDictionaryEntry } { TOmfLibDictionaryEntry }
TOmfLibDictionaryEntry=class(TFPHashObject) TOmfLibDictionaryEntry=class(TFPHashObject)
@ -54,10 +67,10 @@ type
FPageSize: Integer; FPageSize: Integer;
FLibName: string; FLibName: string;
FLibData: TDynamicArray; FLibData: TDynamicArray;
FObjFileName: string;
FObjData: TDynamicArray;
FObjStartPage: Word; FObjStartPage: Word;
FDictionary: TFPHashObjectList; FDictionary: TFPHashObjectList;
FObjectModules: TFPObjectList;
FCurrentModule: TOmfLibObjectModule;
procedure WriteHeader(DictStart: DWord; DictBlocks: Word); procedure WriteHeader(DictStart: DWord; DictBlocks: Word);
procedure WriteFooter; procedure WriteFooter;
@ -135,6 +148,22 @@ implementation
Result:=modnm; Result:=modnm;
end; end;
{*****************************************************************************
TOmfLibObjectWriter.TOmfLibObjectModule
*****************************************************************************}
constructor TOmfLibObjectWriter.TOmfLibObjectModule.Create(const fn: string);
begin
FObjFileName:=fn;
FObjData:=TDynamicArray.Create(objbufsize);
end;
destructor TOmfLibObjectWriter.TOmfLibObjectModule.Destroy;
begin
FObjData.Free;
inherited Destroy;
end;
{***************************************************************************** {*****************************************************************************
TOmfLibObjectWriter.TOmfLibDictionaryEntry TOmfLibObjectWriter.TOmfLibDictionaryEntry
*****************************************************************************} *****************************************************************************}
@ -161,6 +190,8 @@ implementation
FLibName:=Aarfn; FLibName:=Aarfn;
FLibData:=TDynamicArray.Create(libbufsize); FLibData:=TDynamicArray.Create(libbufsize);
FDictionary:=TFPHashObjectList.Create; FDictionary:=TFPHashObjectList.Create;
FObjectModules:=TFPObjectList.Create(True);
FCurrentModule:=nil;
{ header is at page 0, so first module starts at page 1 } { header is at page 0, so first module starts at page 1 }
FObjStartPage:=1; FObjStartPage:=1;
end; end;
@ -171,7 +202,7 @@ implementation
if Errorcount=0 then if Errorcount=0 then
WriteLib; WriteLib;
FLibData.Free; FLibData.Free;
FObjData.Free; FObjectModules.Free;
FDictionary.Free; FDictionary.Free;
inherited destroy; inherited destroy;
end; end;
@ -179,9 +210,8 @@ implementation
function TOmfLibObjectWriter.createfile(const fn: string): boolean; function TOmfLibObjectWriter.createfile(const fn: string): boolean;
begin begin
FObjFileName:=fn; FCurrentModule:=TOmfLibObjectModule.Create(fn);
FreeAndNil(FObjData); FObjectModules.Add(FCurrentModule);
FObjData:=TDynamicArray.Create(objbufsize);
createfile:=true; createfile:=true;
fobjsize:=0; fobjsize:=0;
end; end;
@ -193,10 +223,10 @@ implementation
ObjHeader: TOmfRecord_THEADR; ObjHeader: TOmfRecord_THEADR;
begin begin
FLibData.seek(FObjStartPage*FPageSize); FLibData.seek(FObjStartPage*FPageSize);
FObjData.seek(0); FCurrentModule.ObjData.seek(0);
RawRec:=TOmfRawRecord.Create; RawRec:=TOmfRawRecord.Create;
repeat repeat
RawRec.ReadFrom(FObjData); RawRec.ReadFrom(FCurrentModule.ObjData);
if RawRec.RecordType=RT_THEADR then if RawRec.RecordType=RT_THEADR then
begin begin
ObjHeader:=TOmfRecord_THEADR.Create; ObjHeader:=TOmfRecord_THEADR.Create;
@ -224,7 +254,7 @@ implementation
begin begin
inc(fobjsize,len); inc(fobjsize,len);
inc(fsize,len); inc(fsize,len);
FObjData.write(b,len); FCurrentModule.ObjData.write(b,len);
end; end;
procedure TOmfLibObjectWriter.WriteHeader(DictStart: DWord; DictBlocks: Word); procedure TOmfLibObjectWriter.WriteHeader(DictStart: DWord; DictBlocks: Word);