From eea8f3277211a2df7cc299dacd03cf600dcd48b5 Mon Sep 17 00:00:00 2001 From: Nikolay Nikolov Date: Sun, 19 Sep 2021 20:56:06 +0300 Subject: [PATCH] + introduced TWasmObjSection.IsCode and .IsData --- compiler/ogwasm.pas | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/compiler/ogwasm.pas b/compiler/ogwasm.pas index a9ce012b65..746f442804 100644 --- a/compiler/ogwasm.pas +++ b/compiler/ogwasm.pas @@ -43,6 +43,9 @@ interface { TWasmObjSection } TWasmObjSection = class(TObjSection) + public + function IsCode: Boolean; + function IsData: Boolean; end; { TWasmObjData } @@ -74,6 +77,23 @@ interface implementation +{**************************************************************************** + TWasmObjSection +****************************************************************************} + + function TWasmObjSection.IsCode: Boolean; + const + CodePrefix = '.text'; + begin + result:=(Length(Name)>=Length(CodePrefix)) and + (Copy(Name,1,Length(CodePrefix))=CodePrefix); + end; + + function TWasmObjSection.IsData: Boolean; + begin + result:=not IsCode; + end; + {**************************************************************************** TWasmObjData ****************************************************************************} @@ -244,7 +264,7 @@ implementation function TWasmObjOutput.writeData(Data:TObjData):boolean; var i: Integer; - objsec: TObjSection; + objsec: TWasmObjSection; begin Writer.write(WasmModuleMagic,SizeOf(WasmModuleMagic)); Writer.write(WasmVersion,SizeOf(WasmVersion)); @@ -252,8 +272,8 @@ implementation Writeln('ObjSectionList:'); for i:=0 to Data.ObjSectionList.Count-1 do begin - objsec:=TObjSection(Data.ObjSectionList[i]); - Writeln(objsec.Name, ' Size=', objsec.Size, ' MemPos=', objsec.MemPos, ' Data.Size=', objsec.Data.size, ' DataPos=', objsec.DataPos); + objsec:=TWasmObjSection(Data.ObjSectionList[i]); + Writeln(objsec.Name, ' IsCode=', objsec.IsCode, ' IsData=', objsec.IsData, ' Size=', objsec.Size, ' MemPos=', objsec.MemPos, ' Data.Size=', objsec.Data.size, ' DataPos=', objsec.DataPos); end; result:=true;