From 0e39e7c12de0812c6daa343796c4d2fd148b1b32 Mon Sep 17 00:00:00 2001 From: Nikolay Nikolov Date: Wed, 18 Oct 2023 01:47:42 +0300 Subject: [PATCH] * moved the preparation of the locals asm list in tcpuprocinfo.postprocess_code to a local subroutine --- compiler/wasm32/cpupi.pas | 52 +++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 24 deletions(-) diff --git a/compiler/wasm32/cpupi.pas b/compiler/wasm32/cpupi.pas index 48aa490629..862883493a 100644 --- a/compiler/wasm32/cpupi.pas +++ b/compiler/wasm32/cpupi.pas @@ -650,32 +650,36 @@ implementation asmlist:=l2; end; - var - localslist: TAsmList; - l : TWasmLocal; - first, labels_resolved: Boolean; - local: tai_local; - first_tai_functype: tai_functype; - begin - first_tai_functype:=findfirst_tai_functype(aktproccode); - - localslist:=TAsmList.create; - local:=nil; - first:=true; - l:=ttgwasm(tg).localvars.first; - FFirstFreeLocal:=Length(first_tai_functype.functype.params); - while Assigned(l) do + function prepare_locals: TAsmList; + var + local: tai_local; + first: Boolean; + l : TWasmLocal; begin - local:=tai_local.create(l.typ); - local.first:=first; - first:=false; - localslist.Concat(local); - l:=l.nextseq; - Inc(FFirstFreeLocal); + result:=TAsmList.create; + local:=nil; + first:=true; + l:=ttgwasm(tg).localvars.first; + FFirstFreeLocal:=Length(findfirst_tai_functype(aktproccode).functype.params); + while Assigned(l) do + begin + local:=tai_local.create(l.typ); + local.first:=first; + first:=false; + result.Concat(local); + l:=l.nextseq; + Inc(FFirstFreeLocal); + end; + if assigned(local) then + local.last:=true; end; - if assigned(local) then - local.last:=true; - aktproccode.insertListAfter(first_tai_functype,localslist); + + var + localslist: TAsmList; + labels_resolved: Boolean; + begin + localslist:=prepare_locals; + aktproccode.insertListAfter(findfirst_tai_functype(aktproccode),localslist); localslist.Free; replace_local_frame_pointer(aktproccode);