diff --git a/.gitattributes b/.gitattributes index 097c0bd684..083ecbaee6 100644 --- a/.gitattributes +++ b/.gitattributes @@ -18990,3 +18990,5 @@ utils/wasmbin/wasmtool.lpi svneol=native#text/plain utils/wasmbin/wasmtool.lpr svneol=native#text/plain utils/wasmbin/wasmtoolutils.pas svneol=native#text/plain utils/wasmbin/watparser.pas svneol=native#text/plain +utils/wasmbin/wattest.lpi svneol=native#text/plain +utils/wasmbin/wattest.lpr svneol=native#text/plain diff --git a/utils/wasmbin/wattest.lpi b/utils/wasmbin/wattest.lpi new file mode 100644 index 0000000000..176b1f7e53 --- /dev/null +++ b/utils/wasmbin/wattest.lpi @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + <UseAppBundle Value="False"/> + <ResourceType Value="res"/> + </General> + <BuildModes> + <Item Name="Default" Default="True"/> + </BuildModes> + <PublishOptions> + <Version Value="2"/> + <UseFileFilters Value="True"/> + </PublishOptions> + <RunParams> + <FormatVersion Value="2"/> + <Modes Count="0"/> + </RunParams> + <Units> + <Unit> + <Filename Value="wattest.lpr"/> + <IsPartOfProject Value="True"/> + </Unit> + </Units> + </ProjectOptions> + <CompilerOptions> + <Version Value="11"/> + <PathDelim Value="\"/> + <Target> + <Filename Value="wattest"/> + </Target> + <SearchPaths> + <IncludeFiles Value="$(ProjOutDir)"/> + <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/> + </SearchPaths> + </CompilerOptions> + <Debugging> + <Exceptions Count="3"> + <Item1> + <Name Value="EAbort"/> + </Item1> + <Item2> + <Name Value="ECodetoolError"/> + </Item2> + <Item3> + <Name Value="EFOpenError"/> + </Item3> + </Exceptions> + </Debugging> +</CONFIG> diff --git a/utils/wasmbin/wattest.lpr b/utils/wasmbin/wattest.lpr new file mode 100644 index 0000000000..f588c9d49f --- /dev/null +++ b/utils/wasmbin/wattest.lpr @@ -0,0 +1,55 @@ +program wattest; + +{$mode objfpc}{$H+} + +uses + SysUtils, Classes, watparser; + +procedure Traverse(p: TWatScanner); +begin + while p.Next do begin + write(p.token,' ', p.resText); + if p.token = weInstr then + write('; inst = $', IntToHex(p.instrCode,2)) + else if p.token = weError then begin + writeln('offset = ',p.ofs,' ',p.resText); + break; + end; + writeln; + end; +end; + +procedure Run(const fn: string); +var + st : TFileStream; + s : string; + p : TWatScanner; +begin + st := TFileStream.Create(fn, fmOpenRead or fmShareDenyNone); + p := TWatScanner.Create; + try + SetLength(s, st.Size); + if length(s)>0 then st.Read(s[1], length(s)); + p.SetSource(s); + Traverse(p); + finally + p.Free; + st.Free; + end; +end; + +var + fn : string; +begin + if ParamCount=0 then begin + writeln('please sepcify the input .wat file'); + exit; + end; + fn:=ParamStr(1); + if not FileExists(fn) then begin + writeln('file doesn''t exist: ', fn); + exit; + end; + Run(fn); +end. +