* fixed crash with empty array constructor

This commit is contained in:
peter 1999-05-31 12:42:43 +00:00
parent c4334007df
commit e79d80a971

View File

@ -731,9 +731,10 @@ implementation
if not p^.cargs then if not p^.cargs then
begin begin
reset_reference(p^.location.reference); reset_reference(p^.location.reference);
{ Allocate always a temp, also if no elements are required, to
ensure that location is valid (PFV) }
if parraydef(p^.resulttype)^.highrange=-1 then if parraydef(p^.resulttype)^.highrange=-1 then
begin gettempofsizereference(8,p^.location.reference)
end
else else
gettempofsizereference((parraydef(p^.resulttype)^.highrange+1)*8,p^.location.reference); gettempofsizereference((parraydef(p^.resulttype)^.highrange+1)*8,p^.location.reference);
href:=p^.location.reference; href:=p^.location.reference;
@ -741,80 +742,89 @@ implementation
hp:=p; hp:=p;
while assigned(hp) do while assigned(hp) do
begin begin
secondpass(hp^.left); if assigned(hp^.left) then
if codegenerror then begin
exit; secondpass(hp^.left);
{ find the correct vtype value } if codegenerror then
vtype:=$ff; exit;
vaddr:=false; { find the correct vtype value }
lt:=hp^.left^.resulttype; vtype:=$ff;
case lt^.deftype of vaddr:=false;
enumdef, lt:=hp^.left^.resulttype;
orddef : begin case lt^.deftype of
if (lt^.deftype=enumdef) or enumdef,
is_integer(lt) then orddef :
vtype:=vtInteger begin
else if (lt^.deftype=enumdef) or
if is_boolean(lt) then is_integer(lt) then
vtype:=vtBoolean vtype:=vtInteger
else else
if is_boolean(lt) then
vtype:=vtBoolean
else
if (lt^.deftype=orddef) and (porddef(lt)^.typ=uchar) then if (lt^.deftype=orddef) and (porddef(lt)^.typ=uchar) then
vtype:=vtChar; vtype:=vtChar;
end; end;
floatdef : begin floatdef :
vtype:=vtExtended; begin
vtype:=vtExtended;
vaddr:=true;
end;
procvardef,
pointerdef :
begin
if is_pchar(lt) then
vtype:=vtPChar
else
vtype:=vtPointer;
end;
classrefdef :
vtype:=vtClass;
objectdef :
begin
vtype:=vtObject;
end;
stringdef :
begin
if is_shortstring(lt) then
begin
vtype:=vtString;
vaddr:=true; vaddr:=true;
end; end
procvardef, else
pointerdef : begin if is_ansistring(lt) then
if is_pchar(lt) then vtype:=vtAnsiString;
vtype:=vtPChar end;
else end;
vtype:=vtPointer; if vtype=$ff then
end; internalerror(14357);
classrefdef : vtype:=vtClass; { write C style pushes or an pascal array }
objectdef : begin if p^.cargs then
vtype:=vtObject;
end;
stringdef : begin
if is_shortstring(lt) then
begin
vtype:=vtString;
vaddr:=true;
end
else
if is_ansistring(lt) then
vtype:=vtAnsiString;
end;
end;
if vtype=$ff then
internalerror(14357);
{ write C style pushes or an pascal array }
if p^.cargs then
begin
if vaddr then
begin begin
emit_to_reference(hp^.left); if vaddr then
emit_push_lea_loc(hp^.left^.location); begin
emit_to_reference(hp^.left);
emit_push_lea_loc(hp^.left^.location);
end
else
emit_push_loc(hp^.left^.location);
end end
else else
emit_push_loc(hp^.left^.location);
end
else
begin
{ update href to the vtype field and write it }
exprasmlist^.concat(new(pai386,op_const_ref(A_MOV,S_L,
vtype,newreference(href))));
inc(href.offset,4);
{ write changing field update href to the next element }
if vaddr then
begin begin
emit_to_reference(hp^.left); { update href to the vtype field and write it }
emit_lea_loc_ref(hp^.left^.location,href); exprasmlist^.concat(new(pai386,op_const_ref(A_MOV,S_L,
end vtype,newreference(href))));
else inc(href.offset,4);
emit_mov_loc_ref(hp^.left^.location,href); { write changing field update href to the next element }
inc(href.offset,4); if vaddr then
begin
emit_to_reference(hp^.left);
emit_lea_loc_ref(hp^.left^.location,href);
end
else
emit_mov_loc_ref(hp^.left^.location,href);
inc(href.offset,4);
end;
end; end;
{ load next entry } { load next entry }
hp:=hp^.right; hp:=hp^.right;
@ -825,7 +835,10 @@ implementation
end. end.
{ {
$Log$ $Log$
Revision 1.59 1999-05-27 19:44:14 peter Revision 1.60 1999-05-31 12:42:43 peter
* fixed crash with empty array constructor
Revision 1.59 1999/05/27 19:44:14 peter
* removed oldasm * removed oldasm
* plabel -> pasmlabel * plabel -> pasmlabel
* -a switches to source writing automaticly * -a switches to source writing automaticly