* when creating a bare procdef copy, don't copy the funcret parameter.

This is useful if you want to change the calling convention of the copy.
   o call insert_funcret_para() after creating a bare copy
  * don't copy aliasnames of copied procdefs either (can at best result
    in duplicate symbol errors)

git-svn-id: trunk@28227 -
This commit is contained in:
Jonas Maebe 2014-07-18 09:09:11 +00:00
parent 256f2fcf69
commit 627c83e828
2 changed files with 24 additions and 16 deletions

View File

@ -505,6 +505,7 @@ implementation
methoddef:=tprocdef(tprocvardef(def).getcopyas(procdef,pc_bareproc));
finish_copied_procdef(methoddef,'invoke',pvclass.symtable,pvclass);
insert_self_and_vmt_para(methoddef);
insert_funcret_para(methoddef);
methoddef.synthetickind:=tsk_jvm_procvar_invoke;
methoddef.calcparas;
@ -539,6 +540,7 @@ implementation
methoddef:=tprocdef(tprocvardef(def).getcopyas(procdef,pc_bareproc));
finish_copied_procdef(methoddef,name+'Callback',pvintf.symtable,pvintf);
insert_self_and_vmt_para(methoddef);
insert_funcret_para(methoddef);
{ can't be final/static/private/protected, and must be virtual
since it's an interface method }
methoddef.procoptions:=methoddef.procoptions-[po_staticmethod,po_finalmethod];
@ -680,6 +682,7 @@ implementation
{ since it was a bare copy, insert the self parameter (we can't just
copy the vmt parameter from the constructor, that's different) }
insert_self_and_vmt_para(wrapperpd);
insert_funcret_para(wrapperpd);
wrapperpd.calcparas;
{ implementation: call through to the constructor
Exception: if the current class is abstract, do not call the

View File

@ -4453,7 +4453,7 @@ implementation
{ in case of bare proc, don't copy self, vmt or framepointer
parameters }
if (copytyp=pc_bareproc) and
(([vo_is_self,vo_is_vmt,vo_is_parentfp,vo_is_result]*pvs.varoptions)<>[]) then
(([vo_is_self,vo_is_vmt,vo_is_parentfp,vo_is_result,vo_is_funcret]*pvs.varoptions)<>[]) then
continue;
npvs:=cparavarsym.create(pvs.realname,pvs.paranr,pvs.varspez,
pvs.vardef,pvs.varoptions);
@ -5188,24 +5188,29 @@ implementation
tprocdef(result).deprecatedmsg:=stringdup(deprecatedmsg^);
{ will have to be associated with appropriate procsym }
tprocdef(result).procsym:=nil;
{ don't create aliases for bare copies, nor copy the funcretsym as
the function result parameter will be inserted again if necessary
(e.g. if the calling convention is changed) }
if copytyp<>pc_bareproc then
tprocdef(result).aliasnames.concatListcopy(aliasnames);
if assigned(funcretsym) then
begin
if funcretsym.owner=parast then
tprocdef(result).aliasnames.concatListcopy(aliasnames);
if assigned(funcretsym) then
begin
j:=parast.symlist.indexof(funcretsym);
if j<0 then
internalerror(2011040606);
tprocdef(result).funcretsym:=tsym(tprocdef(result).parast.symlist[j]);
end
else if funcretsym.owner=localst then
begin
{ nothing to do, will be inserted for the new procdef while
parsing its body (by pdecsub.insert_funcret_local) }
end
else
internalerror(2011040605);
if funcretsym.owner=parast then
begin
j:=parast.symlist.indexof(funcretsym);
if j<0 then
internalerror(2011040606);
tprocdef(result).funcretsym:=tsym(tprocdef(result).parast.symlist[j]);
end
else if funcretsym.owner=localst then
begin
{ nothing to do, will be inserted for the new procdef while
parsing its body (by pdecsub.insert_funcret_local) }
end
else
internalerror(2011040605);
end;
end;
{ will have to be associated with a new struct }
tprocdef(result).struct:=nil;