|
@@ -1128,6 +1128,8 @@ interface
|
|
|
an existing one in case it exists in the current module }
|
|
|
function getsingletonarraydef(def: tdef): tarraydef;
|
|
|
function getarraydef(def: tdef; elecount: asizeint): tarraydef;
|
|
|
+ { returns a procvardef that represents the address of a procdef }
|
|
|
+ function getprocaddressprocvar(def: tabstractprocdef): tprocvardef;
|
|
|
|
|
|
function getansistringcodepage:tstringencoding; inline;
|
|
|
function getansistringdef:tstringdef;
|
|
@@ -7651,4 +7653,30 @@ implementation
|
|
|
end;
|
|
|
|
|
|
|
|
|
+ function getprocaddressprocvar(def: tabstractprocdef): tprocvardef;
|
|
|
+ var
|
|
|
+ res: PHashSetItem;
|
|
|
+ oldsymtablestack: tsymtablestack;
|
|
|
+ begin
|
|
|
+ if not assigned(current_module) then
|
|
|
+ internalerror(2011081301);
|
|
|
+ res:=current_module.procaddrdefs.FindOrAdd(@def,sizeof(def));
|
|
|
+ if not assigned(res^.Data) then
|
|
|
+ begin
|
|
|
+ { since these pointerdefs can be reused anywhere in the current
|
|
|
+ unit, add them to the global/staticsymtable }
|
|
|
+ oldsymtablestack:=symtablestack;
|
|
|
+ { do not simply push/pop current_module.localsymtable, because
|
|
|
+ that can have side-effects (e.g., it removes helpers) }
|
|
|
+ symtablestack:=nil;
|
|
|
+ res^.Data:=def.getcopyas(procvardef,pc_address_only);
|
|
|
+ if assigned(current_module.localsymtable) then
|
|
|
+ current_module.localsymtable.insertdef(tdef(res^.Data))
|
|
|
+ else
|
|
|
+ current_module.globalsymtable.insertdef(tdef(res^.Data));
|
|
|
+ symtablestack:=oldsymtablestack;
|
|
|
+ end;
|
|
|
+ result:=tprocvardef(res^.Data);
|
|
|
+ end;
|
|
|
+
|
|
|
end.
|