[PATCH 060/188] adding a traverse command

From 925d019b817d2d8b154d237370fffa2b924f5c6d Mon Sep 17 00:00:00 2001
From: Dmitry Boyarintsev <skalogryz.lists@gmail.com>
Date: Tue, 3 Mar 2020 10:32:33 -0500

git-svn-id: branches/wasm@46056 -
This commit is contained in:
nickysn 2020-08-03 12:59:48 +00:00
parent 22a229fa21
commit 45ca2127d7

View File

@ -31,7 +31,7 @@ begin
end;
end;
procedure Run(const fn: string);
procedure Run(const fn: string; const doTraverse: Boolean);
var
st : TFileStream;
s : string;
@ -45,7 +45,10 @@ begin
SetLength(s, st.Size);
if length(s)>0 then st.Read(s[1], length(s));
p.SetSource(s);
//Traverse(p);
if doTraverse then begin
Traverse(p);
Exit;
end;
m := TWasmModule.Create;
try
if not ParseModule(p, m, err) then
@ -62,19 +65,40 @@ begin
end;
var
fn : string;
gFn : string;
gCommand : string = '';
procedure ParseParams;
var
i : integer;
s : string;
begin
if ParamCount=0 then begin
i:=1;
while i<=ParamCount do begin
s := ParamStr(i);
if (s<>'') and (s[1]='-') then
gCommand:=AnsiLowerCase(s)
else
gFn := s;
inc(i);
end;
end;
begin
ParseParams;
if (gFn='') then begin
writeln('please sepcify the input .wat file');
writeln('other use:');
writeln(' -compile %inpfn%');
writeln(' -traverse %inpfn%');
exit;
end;
fn:=ParamStr(1);
if not FileExists(fn) then begin
writeln('file doesn''t exist: ', fn);
if not FileExists(gFn) then begin
writeln('file doesn''t exist: ', gFn);
exit;
end;
try
Run(fn);
Run(gFn, gCommand = '-traverse');
except
on e: exception do
writeln(e.message);