* factored out the code to create an complete alias for a procdef to

symcreat.create_procdef_alias()

git-svn-id: trunk@35087 -
This commit is contained in:
Jonas Maebe 2016-12-09 13:39:35 +00:00
parent 8af85a16b3
commit d36fe53d85
2 changed files with 35 additions and 17 deletions

View File

@ -1293,26 +1293,15 @@ implementation
tmps:=make_mangledname('WRPR',_class.owner,_class.objname^+'_$_'+
ImplIntf.IntfDef.objname^+'_$_'+tostr(j)+'_$_'+pd.mangledname);
{$ifdef cpuhighleveltarget}
{ bare copy so we don't copy the aliasnames }
wrapperpd:=tprocdef(pd.getcopyas(procdef,pc_bareproc));
{ set the mangled name to the wrapper name }
wrapperpd.setmangledname(tmps);
{ insert the wrapper procdef in the current unit's local
symbol table, but set the owning "struct" to the current
class (so self will have the correct type) }
finish_copied_procdef(wrapperpd,tmps,current_module.localsymtable,_class);
{ now insert self/vmt }
insert_self_and_vmt_para(wrapperpd);
{ and the function result }
insert_funcret_para(wrapperpd);
{ recalculate the parameters now that we've added the above }
wrapperpd.calcparas;
{ set the info required to generate the implementation }
wrapperpd.synthetickind:=tsk_interface_wrapper;
new(wrapperinfo);
wrapperinfo^.pd:=pd;
wrapperinfo^.offset:=ImplIntf.ioffset;
wrapperpd.skpara:=wrapperinfo;
{ insert the wrapper procdef in the current unit's local
symbol table, but set the owning "struct" to the current
class (so self will have the correct type) }
wrapperpd:=create_procdef_alias(pd,tmps,tmps,
current_module.localsymtable,_class,
tsk_interface_wrapper,wrapperinfo);
{$else cpuhighleveltarget}
{ create wrapper code }
new_section(list,sec_code,tmps,target_info.alignment.procalign);

View File

@ -84,6 +84,14 @@ interface
added earlier }
procedure add_synthetic_method_implementations(st: tsymtable);
{ create an alias for a procdef with Pascal name "newrealname",
mangledname "newmangledname", in symtable newparentst, part of the
record/class/.. "newstruct" (nil if none), and with synthetickind "sk" and
synthetic kind para "skpara" to create the implementation (tsk_none and nil
in case not necessary). Returns the new procdef; finish_copied_procdef() is
not required/must not be called for the result. }
function create_procdef_alias(pd: tprocdef; const newrealname: string; const newmangledname: TSymStr; newparentst: tsymtable; newstruct: tabstractrecorddef; sk: tsynthetickind; skpara: pointer): tprocdef;
{ finalize a procdef that has been copied with
tprocdef.getcopyas(procdef,pc_bareproc) }
procedure finish_copied_procdef(var pd: tprocdef; const realname: string; newparentst: tsymtable; newstruct: tabstractrecorddef);
@ -1116,6 +1124,27 @@ implementation
end;
function create_procdef_alias(pd: tprocdef; const newrealname: string; const newmangledname: TSymStr; newparentst: tsymtable; newstruct: tabstractrecorddef;
sk: tsynthetickind; skpara: pointer): tprocdef;
begin
{ bare copy so we don't copy the aliasnames }
result:=tprocdef(pd.getcopyas(procdef,pc_bareproc));
{ set the mangled name to the wrapper name }
result.setmangledname(newmangledname);
{ finish creating the copy }
finish_copied_procdef(result,newrealname,newparentst,newstruct);
{ now insert self/vmt }
insert_self_and_vmt_para(result);
{ and the function result }
insert_funcret_para(result);
{ recalculate the parameters now that we've added the missing ones }
result.calcparas;
{ set the info required to generate the implementation }
result.synthetickind:=sk;
result.skpara:=skpara;
end;
procedure finish_copied_procdef(var pd: tprocdef; const realname: string; newparentst: tsymtable; newstruct: tabstractrecorddef);
var
sym: tsym;