+ Patch from peter to fix wrong pushing of ansistring function results in open array

This commit is contained in:
michael 2003-04-29 07:28:52 +00:00
parent dfd469b7a3
commit cf68b27bb9
5 changed files with 54 additions and 23 deletions

View File

@ -337,8 +337,8 @@ unit cgobj;
}
procedure g_copyshortstring(list : taasmoutput;const source,dest : treference;len:byte;delsource,loadref : boolean);
procedure g_incrrefcount(list : taasmoutput;t: tdef; const ref: treference);
procedure g_decrrefcount(list : taasmoutput;t: tdef; const ref: treference);
procedure g_incrrefcount(list : taasmoutput;t: tdef; const ref: treference;loadref : boolean);
procedure g_decrrefcount(list : taasmoutput;t: tdef; const ref: treference;loadref : boolean);
procedure g_initialize(list : taasmoutput;t : tdef;const ref : treference;loadref : boolean);
procedure g_finalize(list : taasmoutput;t : tdef;const ref : treference;loadref : boolean);
@ -1296,7 +1296,7 @@ unit cgobj;
end;
procedure tcg.g_incrrefcount(list : taasmoutput;t: tdef; const ref: treference);
procedure tcg.g_incrrefcount(list : taasmoutput;t: tdef; const ref: treference;loadref : boolean);
var
href : treference;
incrfunc : string;
@ -1316,20 +1316,26 @@ unit cgobj;
{ call the special incr function or the generic addref }
if incrfunc<>'' then
begin
a_param_ref(list,OS_ADDR,ref,paramanager.getintparaloc(1));
if loadref then
a_param_ref(list,OS_ADDR,ref,paramanager.getintparaloc(1))
else
a_paramaddr_ref(list,ref,paramanager.getintparaloc(1));
a_call_name(list,incrfunc);
end
else
begin
reference_reset_symbol(href,tstoreddef(t).get_rtti_label(initrtti),0);
a_paramaddr_ref(list,href,paramanager.getintparaloc(2));
a_paramaddr_ref(list,ref,paramanager.getintparaloc(1));
if loadref then
a_param_ref(list,OS_ADDR,ref,paramanager.getintparaloc(1))
else
a_paramaddr_ref(list,ref,paramanager.getintparaloc(1));
a_call_name(list,'FPC_ADDREF');
end;
end;
procedure tcg.g_decrrefcount(list : taasmoutput;t: tdef; const ref: treference);
procedure tcg.g_decrrefcount(list : taasmoutput;t: tdef; const ref: treference; loadref:boolean);
var
href : treference;
decrfunc : string;
@ -1357,14 +1363,20 @@ unit cgobj;
reference_reset_symbol(href,tstoreddef(t).get_rtti_label(initrtti),0);
a_paramaddr_ref(list,href,paramanager.getintparaloc(2));
end;
a_paramaddr_ref(list,ref,paramanager.getintparaloc(1));
if loadref then
a_param_ref(list,OS_ADDR,ref,paramanager.getintparaloc(1))
else
a_paramaddr_ref(list,ref,paramanager.getintparaloc(1));
a_call_name(list,decrfunc);
end
else
begin
reference_reset_symbol(href,tstoreddef(t).get_rtti_label(initrtti),0);
a_paramaddr_ref(list,href,paramanager.getintparaloc(2));
a_paramaddr_ref(list,ref,paramanager.getintparaloc(1));
if loadref then
a_param_ref(list,OS_ADDR,ref,paramanager.getintparaloc(1))
else
a_paramaddr_ref(list,ref,paramanager.getintparaloc(1));
a_call_name(list,'FPC_DECREF');
end;
end;
@ -1398,7 +1410,7 @@ unit cgobj;
if is_ansistring(t) or
is_widestring(t) or
is_interfacecom(t) then
g_decrrefcount(list,t,ref)
g_decrrefcount(list,t,ref,loadref)
else
begin
reference_reset_symbol(href,tstoreddef(t).get_rtti_label(initrtti),0);
@ -1853,7 +1865,10 @@ finalization
end.
{
$Log$
Revision 1.92 2003-04-27 11:21:32 peter
Revision 1.93 2003-04-29 07:28:52 michael
+ Patch from peter to fix wrong pushing of ansistring function results in open array
Revision 1.92 2003/04/27 11:21:32 peter
* aktprocdef renamed to current_procdef
* procinfo renamed to current_procinfo
* procinfo will now be stored in current_module so it can be

View File

@ -890,12 +890,12 @@ implementation
if is_widestring(resulttype.def) then
begin
tg.GetTemp(exprasmlist,pointer_size,tt_widestring,refcountedtemp);
cg.g_decrrefcount(exprasmlist,resulttype.def,refcountedtemp);
cg.g_decrrefcount(exprasmlist,resulttype.def,refcountedtemp,false);
end
else if is_ansistring(resulttype.def) then
begin
tg.GetTemp(exprasmlist,pointer_size,tt_ansistring,refcountedtemp);
cg.g_decrrefcount(exprasmlist,resulttype.def,refcountedtemp);
cg.g_decrrefcount(exprasmlist,resulttype.def,refcountedtemp,false);
end;
if (procdefinition.proccalloption in [pocall_cdecl,pocall_cppdecl,pocall_stdcall]) then
@ -1438,7 +1438,10 @@ begin
end.
{
$Log$
Revision 1.55 2003-04-27 11:21:33 peter
Revision 1.56 2003-04-29 07:28:52 michael
+ Patch from peter to fix wrong pushing of ansistring function results in open array
Revision 1.55 2003/04/27 11:21:33 peter
* aktprocdef renamed to current_procdef
* procinfo renamed to current_procinfo
* procinfo will now be stored in current_module so it can be

View File

@ -717,7 +717,7 @@ implementation
useless for string constants }
if (left.resulttype.def.needs_inittable) and
(left.nodetype<>stringconstn) then
cg.g_incrrefcount(exprasmlist,left.resulttype.def,left.location.reference);
cg.g_incrrefcount(exprasmlist,left.resulttype.def,left.location.reference,false);
{ the result of left is not needed anymore after this
node }
location_freetemp(exprasmlist,left.location);
@ -1531,7 +1531,10 @@ begin
end.
{
$Log$
Revision 1.56 2003-04-27 11:21:33 peter
Revision 1.57 2003-04-29 07:29:14 michael
+ Patch from peter to fix wrong pushing of ansistring function results in open array
Revision 1.56 2003/04/27 11:21:33 peter
* aktprocdef renamed to current_procdef
* procinfo renamed to current_procinfo
* procinfo will now be stored in current_module so it can be

View File

@ -445,7 +445,7 @@ implementation
useless for string constants}
if (right.resulttype.def.needs_inittable) and
(right.nodetype<>stringconstn) then
cg.g_incrrefcount(exprasmlist,right.resulttype.def,right.location.reference);
cg.g_incrrefcount(exprasmlist,right.resulttype.def,right.location.reference,false);
if codegenerror then
exit;
@ -462,7 +462,7 @@ implementation
secondpass(left);
{ decrement destination reference counter }
if (left.resulttype.def.needs_inittable) then
cg.g_decrrefcount(exprasmlist,left.resulttype.def,left.location.reference);
cg.g_decrrefcount(exprasmlist,left.resulttype.def,left.location.reference,false);
{$ifndef newra}
maybe_restore(exprasmlist,right.location,pushedregs);
{$endif newra}
@ -479,7 +479,7 @@ implementation
secondpass(left);
{ decrement destination reference counter }
if (left.resulttype.def.needs_inittable) then
cg.g_decrrefcount(exprasmlist,left.resulttype.def,left.location.reference);
cg.g_decrrefcount(exprasmlist,left.resulttype.def,left.location.reference,false);
if codegenerror then
exit;
end;
@ -494,7 +494,7 @@ implementation
useless for string constants}
if (right.resulttype.def.needs_inittable) and
(right.nodetype<>stringconstn) then
cg.g_incrrefcount(exprasmlist,right.resulttype.def,right.location.reference);
cg.g_incrrefcount(exprasmlist,right.resulttype.def,right.location.reference,false);
{$ifndef newra}
maybe_restore(exprasmlist,left.location,pushedregs);
{$endif}
@ -917,6 +917,10 @@ implementation
else
{ normal array constructor of the same type }
begin
if is_ansistring(left.resulttype.def) or
is_widestring(left.resulttype.def) or
(left.resulttype.def.deftype=variantdef) then
freetemp:=false;
location_release(exprasmlist,hp.left.location);
case hp.left.location.loc of
LOC_FPUREGISTER,
@ -953,7 +957,10 @@ begin
end.
{
$Log$
Revision 1.54 2003-04-27 11:21:33 peter
Revision 1.55 2003-04-29 07:29:14 michael
+ Patch from peter to fix wrong pushing of ansistring function results in open array
Revision 1.54 2003/04/27 11:21:33 peter
* aktprocdef renamed to current_procdef
* procinfo renamed to current_procinfo
* procinfo will now be stored in current_module so it can be

View File

@ -1049,7 +1049,7 @@ implementation
-tvarsym(p).localvarsym.address+tvarsym(p).localvarsym.owner.address_fixup)
else
reference_reset_base(href,current_procinfo.framepointer,tvarsym(p).address+tvarsym(p).owner.address_fixup);
cg.g_incrrefcount(list,tvarsym(p).vartype.def,href);
cg.g_incrrefcount(list,tvarsym(p).vartype.def,href,is_open_array(tvarsym(p).vartype.def));
end;
vs_out :
begin
@ -1090,7 +1090,7 @@ implementation
-tvarsym(p).localvarsym.address+tvarsym(p).localvarsym.owner.address_fixup)
else
reference_reset_base(href,current_procinfo.framepointer,tvarsym(p).address+tvarsym(p).owner.address_fixup);
cg.g_decrrefcount(list,tvarsym(p).vartype.def,href);
cg.g_decrrefcount(list,tvarsym(p).vartype.def,href,is_open_array(tvarsym(p).vartype.def));
end;
end;
end;
@ -2006,7 +2006,10 @@ implementation
end.
{
$Log$
Revision 1.94 2003-04-28 21:17:38 peter
Revision 1.95 2003-04-29 07:28:52 michael
+ Patch from peter to fix wrong pushing of ansistring function results in open array
Revision 1.94 2003/04/28 21:17:38 peter
* do not finalize function results
Revision 1.93 2003/04/27 16:30:34 jonas