mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-21 09:09:30 +02:00
+ getsingletonarraydef() function to get a (reused if possible) def for
an array of one element of the specified type git-svn-id: branches/jvmbackend@18773 -
This commit is contained in:
parent
ee77d5a6f2
commit
d1f424561e
@ -144,6 +144,7 @@ interface
|
||||
deflist,
|
||||
symlist : TFPObjectList;
|
||||
ptrdefs : THashSet; { list of pointerdefs created in this module so we can reuse them (not saved/restored) }
|
||||
arraydefs : THashSet; { list of single-element-arraydefs created in this module so we can reuse them (not saved/restored) }
|
||||
wpoinfo : tunitwpoinfobase; { whole program optimization-related information that is generated during the current run for this unit }
|
||||
globalsymtable, { pointer to the global symtable of this unit }
|
||||
localsymtable : TSymtable;{ pointer to the local symtable of this unit }
|
||||
@ -527,6 +528,7 @@ implementation
|
||||
deflist:=TFPObjectList.Create(false);
|
||||
symlist:=TFPObjectList.Create(false);
|
||||
ptrdefs:=THashSet.Create(64,true,false);
|
||||
arraydefs:=THashSet.Create(64,true,false);
|
||||
wpoinfo:=nil;
|
||||
checkforwarddefs:=TFPObjectList.Create(false);
|
||||
extendeddefs := TFPHashObjectList.Create(true);
|
||||
@ -643,6 +645,7 @@ implementation
|
||||
deflist.free;
|
||||
symlist.free;
|
||||
ptrdefs.free;
|
||||
arraydefs.free;
|
||||
wpoinfo.free;
|
||||
checkforwarddefs.free;
|
||||
globalsymtable.free;
|
||||
@ -704,6 +707,8 @@ implementation
|
||||
symlist:=TFPObjectList.Create(false);
|
||||
ptrdefs.free;
|
||||
ptrdefs:=THashSet.Create(64,true,false);
|
||||
arraydefs.free;
|
||||
arraydefs:=THashSet.Create(64,true,false);
|
||||
wpoinfo.free;
|
||||
wpoinfo:=nil;
|
||||
checkforwarddefs.free;
|
||||
|
@ -963,6 +963,9 @@ interface
|
||||
{ returns a pointerdef for def, reusing an existing one in case it exists
|
||||
in the current module }
|
||||
function getpointerdef(def: tdef): tpointerdef;
|
||||
{ returns an arraydef for an array containing a single array of def, resuing
|
||||
an existing one in case it exists in the current module }
|
||||
function getsingletonarraydef(def: tdef): tarraydef;
|
||||
|
||||
implementation
|
||||
|
||||
@ -6639,4 +6642,25 @@ implementation
|
||||
result:=tpointerdef(res^.Data);
|
||||
end;
|
||||
|
||||
|
||||
function getsingletonarraydef(def: tdef): tarraydef;
|
||||
var
|
||||
res: PHashSetItem;
|
||||
begin
|
||||
if not assigned(current_module) then
|
||||
internalerror(2011081301);
|
||||
res:=current_module.arraydefs.FindOrAdd(@def,sizeof(def));
|
||||
if not assigned(res^.Data) then
|
||||
begin
|
||||
{ since these arraydef can be reused anywhere in the current
|
||||
unit, add them to the global/staticsymtable }
|
||||
symtablestack.push(current_module.localsymtable);
|
||||
res^.Data:=tarraydef.create(0,1,s32inttype);
|
||||
tarraydef(res^.Data).elementdef:=def;
|
||||
symtablestack.pop(current_module.localsymtable);
|
||||
end;
|
||||
result:=tarraydef(res^.Data);
|
||||
end;
|
||||
|
||||
|
||||
end.
|
||||
|
Loading…
Reference in New Issue
Block a user