mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-16 20:39:13 +02:00
* fixed allocation of dimension buffer for setlength(dynarr)
This commit is contained in:
parent
8f70c34b33
commit
965835354c
@ -397,6 +397,7 @@ implementation
|
|||||||
paras : tnode;
|
paras : tnode;
|
||||||
npara,
|
npara,
|
||||||
ppn : tcallparanode;
|
ppn : tcallparanode;
|
||||||
|
dims,
|
||||||
counter : integer;
|
counter : integer;
|
||||||
isarray : boolean;
|
isarray : boolean;
|
||||||
def : tdef;
|
def : tdef;
|
||||||
@ -417,7 +418,7 @@ implementation
|
|||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
counter:=0;
|
dims:=0;
|
||||||
if assigned(paras) then
|
if assigned(paras) then
|
||||||
begin
|
begin
|
||||||
{ check type of lengths }
|
{ check type of lengths }
|
||||||
@ -426,11 +427,11 @@ implementation
|
|||||||
begin
|
begin
|
||||||
set_varstate(ppn.left,vs_used,true);
|
set_varstate(ppn.left,vs_used,true);
|
||||||
inserttypeconv(ppn.left,s32bittype);
|
inserttypeconv(ppn.left,s32bittype);
|
||||||
inc(counter);
|
inc(dims);
|
||||||
ppn:=tcallparanode(ppn.right);
|
ppn:=tcallparanode(ppn.right);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
if counter=0 then
|
if dims=0 then
|
||||||
begin
|
begin
|
||||||
CGMessage(parser_e_wrong_parameter_size);
|
CGMessage(parser_e_wrong_parameter_size);
|
||||||
paras.free;
|
paras.free;
|
||||||
@ -453,7 +454,7 @@ implementation
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
{ only dynamic arrays accept more dimensions }
|
{ only dynamic arrays accept more dimensions }
|
||||||
if (counter>1) then
|
if (dims>1) then
|
||||||
begin
|
begin
|
||||||
if (not isarray) then
|
if (not isarray) then
|
||||||
CGMessage(type_e_mismatch)
|
CGMessage(type_e_mismatch)
|
||||||
@ -461,6 +462,7 @@ implementation
|
|||||||
begin
|
begin
|
||||||
{ check if the amount of dimensions is valid }
|
{ check if the amount of dimensions is valid }
|
||||||
def := tarraydef(destppn.resulttype.def).elementtype.def;
|
def := tarraydef(destppn.resulttype.def).elementtype.def;
|
||||||
|
counter:=dims;
|
||||||
while counter > 1 do
|
while counter > 1 do
|
||||||
begin
|
begin
|
||||||
if not(is_dynamic_array(def)) then
|
if not(is_dynamic_array(def)) then
|
||||||
@ -481,7 +483,7 @@ implementation
|
|||||||
newblock:=internalstatements(newstatement);
|
newblock:=internalstatements(newstatement);
|
||||||
|
|
||||||
{ get temp for array of lengths }
|
{ get temp for array of lengths }
|
||||||
temp := ctempcreatenode.create(s32bittype,counter*s32bittype.def.size,tt_persistent);
|
temp := ctempcreatenode.create(s32bittype,dims*s32bittype.def.size,tt_persistent);
|
||||||
addstatement(newstatement,temp);
|
addstatement(newstatement,temp);
|
||||||
|
|
||||||
{ load array of lengths }
|
{ load array of lengths }
|
||||||
@ -732,7 +734,10 @@ implementation
|
|||||||
end.
|
end.
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.25 2003-11-29 16:19:54 peter
|
Revision 1.26 2004-01-22 16:44:35 peter
|
||||||
|
* fixed allocation of dimension buffer for setlength(dynarr)
|
||||||
|
|
||||||
|
Revision 1.25 2003/11/29 16:19:54 peter
|
||||||
* Initialize() added
|
* Initialize() added
|
||||||
|
|
||||||
Revision 1.24 2003/11/10 22:02:52 peter
|
Revision 1.24 2003/11/10 22:02:52 peter
|
||||||
|
Loading…
Reference in New Issue
Block a user