Browse Source

[PATCH 011/188] updating wasm tool

From 4d7dd3df4d47130a435e7d9f9b3ff97b7d0f0020 Mon Sep 17 00:00:00 2001
From: Dmitry Boyarintsev <[email protected]>
Date: Thu, 26 Sep 2019 09:37:52 -0400

git-svn-id: branches/wasm@46007 -
nickysn 5 years ago
parent
commit
24acc96458
1 changed files with 65 additions and 8 deletions
  1. 65 8
      utils/wasmbin/wasmtool.lpr

+ 65 - 8
utils/wasmbin/wasmtool.lpr

@@ -20,20 +20,77 @@ begin
   writeln('  --symbolflag @inputfile');
 end;
 
+type
+
+  { TToolActions }
+
+  TToolActions = class(TObject)
+    action   : string; // action to take place
+    inputFn  : string; // input file name
+    constructor Create(const aaction, afilename: string);
+  end;
+
+procedure ProcessParams(acts: TList; const inputFn: string);
+begin
+
+end;
+
+var
+  acts: TList = nil;
+  inputFn: string = '';
+
+procedure ParseParams;
+var
+  i : integer;
+  s : string;
+  ls : string;
+  fn : string;
+begin
+  i:=1;
+  while i<=ParamCount do begin
+    s := ParamStr(i);
+    ls := AnsiLowerCase(s);
+    inc(i);
+    if Pos('--',ls)=1 then begin
+      inc(i);
+      if i<=ParamCount then
+        fn:=ParamStr(i)
+      else
+        fn := '';
+      if fn <> '' then
+        acts.Add( TToolActions.Create(ls, fn));
+    end else begin
+      if inputFn ='' then
+        inputFn:=s;
+    end;
+  end;
+end;
+
+{ TToolActions }
+
+constructor TToolActions.Create(const aaction, afilename: string);
+begin
+  action := aaction;
+  inputFn := afilename;
+end;
 
 var
-  symfn : string;
+  i : integer;
 begin
   if ParamCount=0 then begin
     PrintHelp;
-
-    exit;
+    Exit;
   end;
-  symfn:='';
-  if ParamCount>1 then symfn:=ParamStr(2);
 
-  //ReadWasmFile(ParamStr(1));
-  //ProcessWasmFile(ParamStr(1), symfn);
-  ProcessWasmSection(ParamStr(1), symfn);
+  ParseParams;
+  acts := TList.Create;
+  try
+    ParseParams;
+    ProcessParams(acts, inputFn);
+  finally
+    for i:=0 to acts.Count-1 do
+      TObject(acts[i]).Free;
+    acts.Free;
+  end;
 end.