* fixed more bugs in the wasm structured asmlist construction

This commit is contained in:
Nikolay Nikolov 2023-10-05 15:09:05 +03:00
parent fff60f9f67
commit 6ff4031398

View File

@ -272,16 +272,18 @@ uses
p:=tai(srclist.First); p:=tai(srclist.First);
if not assigned(p) then if not assigned(p) then
internalerror(2023100302); internalerror(2023100302);
srclist.Remove(p);
if (p.typ=ait_instruction) and (taicpu(p).opcode in [a_else,a_end_if]) then if (p.typ=ait_instruction) and (taicpu(p).opcode in [a_else,a_end_if]) then
case taicpu(p).opcode of begin
a_else: srclist.Remove(p);
begin case taicpu(p).opcode of
a_else:
begin
ThenDone:=True;
ElsePresent:=True;
end;
a_end_if:
ThenDone:=True; ThenDone:=True;
ElsePresent:=True; end;
end;
a_end_if:
ThenDone:=True;
end end
else else
then_asmlist.Concat(wasm_convert_first_item_to_structured(srclist)); then_asmlist.Concat(wasm_convert_first_item_to_structured(srclist));
@ -295,9 +297,11 @@ uses
p:=tai(srclist.First); p:=tai(srclist.First);
if not assigned(p) then if not assigned(p) then
internalerror(2023100303); internalerror(2023100303);
srclist.Remove(p);
if (p.typ=ait_instruction) and (taicpu(p).opcode=a_end_if) then if (p.typ=ait_instruction) and (taicpu(p).opcode=a_end_if) then
ElseDone:=True begin
srclist.Remove(p);
ElseDone:=True;
end
else else
else_asmlist.Concat(wasm_convert_first_item_to_structured(srclist)); else_asmlist.Concat(wasm_convert_first_item_to_structured(srclist));
until ElseDone; until ElseDone;
@ -350,9 +354,11 @@ uses
p:=tai(srclist.First); p:=tai(srclist.First);
if not assigned(p) then if not assigned(p) then
internalerror(2023100305); internalerror(2023100305);
srclist.Remove(p);
if (p.typ=ait_instruction) and (taicpu(p).opcode=a_end_block) then if (p.typ=ait_instruction) and (taicpu(p).opcode=a_end_block) then
Done:=True begin
srclist.Remove(p);
Done:=True;
end
else else
inner_asmlist.Concat(wasm_convert_first_item_to_structured(srclist)); inner_asmlist.Concat(wasm_convert_first_item_to_structured(srclist));
until Done; until Done;
@ -398,9 +404,11 @@ uses
p:=tai(srclist.First); p:=tai(srclist.First);
if not assigned(p) then if not assigned(p) then
internalerror(2023100307); internalerror(2023100307);
srclist.Remove(p);
if (p.typ=ait_instruction) and (taicpu(p).opcode=a_end_loop) then if (p.typ=ait_instruction) and (taicpu(p).opcode=a_end_loop) then
Done:=True begin
srclist.Remove(p);
Done:=True;
end
else else
inner_asmlist.Concat(wasm_convert_first_item_to_structured(srclist)); inner_asmlist.Concat(wasm_convert_first_item_to_structured(srclist));
until Done; until Done;
@ -443,9 +451,11 @@ uses
p:=tai(srclist.First); p:=tai(srclist.First);
if not assigned(p) then if not assigned(p) then
internalerror(2023100308); internalerror(2023100308);
srclist.Remove(p);
if (p.typ=ait_instruction) and (taicpu(p).opcode in [a_end_try,a_catch,a_catch_all,a_delegate]) then if (p.typ=ait_instruction) and (taicpu(p).opcode in [a_end_try,a_catch,a_catch_all,a_delegate]) then
Done:=True begin
srclist.Remove(p);
Done:=True;
end
else else
tmp_asmlist.Concat(wasm_convert_first_item_to_structured(srclist)); tmp_asmlist.Concat(wasm_convert_first_item_to_structured(srclist));
until Done; until Done;
@ -502,9 +512,11 @@ uses
Done:=False; Done:=False;
repeat repeat
pp:=tai(srclist.First); pp:=tai(srclist.First);
srclist.Remove(pp);
if (pp.typ=ait_instruction) and (taicpu(pp).opcode in [a_catch,a_catch_all,a_end_try]) then if (pp.typ=ait_instruction) and (taicpu(pp).opcode in [a_catch,a_catch_all,a_end_try]) then
Done:=True begin
srclist.Remove(pp);
Done:=True;
end
else else
al.Concat(wasm_convert_first_item_to_structured(srclist)); al.Concat(wasm_convert_first_item_to_structured(srclist));
until Done; until Done;
@ -519,9 +531,9 @@ uses
Done:=False; Done:=False;
repeat repeat
pp:=tai(srclist.First); pp:=tai(srclist.First);
srclist.Remove(pp);
if (pp.typ=ait_instruction) and (taicpu(pp).opcode in [a_catch,a_catch_all,a_end_try]) then if (pp.typ=ait_instruction) and (taicpu(pp).opcode in [a_catch,a_catch_all,a_end_try]) then
begin begin
srclist.Remove(pp);
Done:=True; Done:=True;
if taicpu(pp).opcode in [a_catch,a_catch_all] then if taicpu(pp).opcode in [a_catch,a_catch_all] then
internalerror(2023100313); internalerror(2023100313);