Commit 50f14063 authored by yoogx's avatar yoogx

* Clean up command line interfaces, concentrate all machinery

          in new package Ocarina.Cmd_Line, rework all
          frontend/backends to avoid code duplication.

          For issue #33

          Also fix for issue #54
parent aa036ede
...@@ -37,9 +37,6 @@ with Ocarina.Backends.Utils; ...@@ -37,9 +37,6 @@ with Ocarina.Backends.Utils;
with Ocarina.Backends.XML_Tree.Nodes; with Ocarina.Backends.XML_Tree.Nodes;
with Ocarina.Backends.XML_Tree.Nutils; with Ocarina.Backends.XML_Tree.Nutils;
with Ocarina.Backends.XML_Tree.Generator; with Ocarina.Backends.XML_Tree.Generator;
with GNAT.Command_Line; use GNAT.Command_Line;
with Ocarina.Namet; use Ocarina.Namet;
package body Ocarina.Backends.AADL_XML is package body Ocarina.Backends.AADL_XML is
...@@ -51,8 +48,6 @@ package body Ocarina.Backends.AADL_XML is ...@@ -51,8 +48,6 @@ package body Ocarina.Backends.AADL_XML is
package XTN renames Ocarina.Backends.XML_Tree.Nodes; package XTN renames Ocarina.Backends.XML_Tree.Nodes;
package XTU renames Ocarina.Backends.XML_Tree.Nutils; package XTU renames Ocarina.Backends.XML_Tree.Nutils;
Generated_Sources_Directory : Name_Id := No_Name;
procedure Visit_Architecture_Instance (E : Node_Id); procedure Visit_Architecture_Instance (E : Node_Id);
-- Most top level visitor routine. E is the root of the AADL -- Most top level visitor routine. E is the root of the AADL
-- instance tree. The procedure does a traversal for each -- instance tree. The procedure does a traversal for each
...@@ -99,27 +94,6 @@ package body Ocarina.Backends.AADL_XML is ...@@ -99,27 +94,6 @@ package body Ocarina.Backends.AADL_XML is
procedure Init is procedure Init is
begin begin
Generated_Sources_Directory := Get_String_Name (".");
Initialize_Option_Scan;
loop
case Getopt ("* o:") is
when ASCII.NUL =>
exit;
when 'o' =>
declare
D : constant String := Parameter;
begin
if D'Length /= 0 then
Generated_Sources_Directory := Get_String_Name (D);
end if;
end;
when others =>
null;
end case;
end loop;
Register_Backend ("aadl_xml", Generate'Access, AADLXML); Register_Backend ("aadl_xml", Generate'Access, AADLXML);
end Init; end Init;
......
...@@ -37,7 +37,6 @@ with Ocarina.Instances; use Ocarina.Instances; ...@@ -37,7 +37,6 @@ with Ocarina.Instances; use Ocarina.Instances;
with Ocarina.ME_AADL.AADL_Instances.Entities; with Ocarina.ME_AADL.AADL_Instances.Entities;
use Ocarina.ME_AADL.AADL_Instances.Entities; use Ocarina.ME_AADL.AADL_Instances.Entities;
with GNAT.Command_Line;
with Ocarina.Backends.Utils; with Ocarina.Backends.Utils;
with Ada.Text_IO; with Ada.Text_IO;
...@@ -224,9 +223,8 @@ package body Ocarina.Backends.Alloy is ...@@ -224,9 +223,8 @@ package body Ocarina.Backends.Alloy is
-------------- --------------
procedure Generate (AADL_Root : Node_Id) is procedure Generate (AADL_Root : Node_Id) is
use GNAT.Command_Line;
Instance_Root : Node_Id; Instance_Root : Node_Id;
begin begin
-- Instantiate the AADL tree -- Instantiate the AADL tree
...@@ -235,18 +233,6 @@ package body Ocarina.Backends.Alloy is ...@@ -235,18 +233,6 @@ package body Ocarina.Backends.Alloy is
raise Program_Error; raise Program_Error;
end if; end if;
Initialize_Option_Scan;
loop
case Getopt ("* ") is
when ASCII.NUL =>
exit;
when others =>
null;
end case;
end loop;
-- Open a new .als file -- Open a new .als file
Create (File => FD, Name => "con_model.als"); Create (File => FD, Name => "con_model.als");
......
...@@ -44,8 +44,6 @@ with Ocarina.Backends.ARINC653_Conf.System_HM; ...@@ -44,8 +44,6 @@ with Ocarina.Backends.ARINC653_Conf.System_HM;
with Ocarina.Backends.ARINC653_Conf.Module_HM; with Ocarina.Backends.ARINC653_Conf.Module_HM;
with Ocarina.Backends.Utils; with Ocarina.Backends.Utils;
with GNAT.Command_Line; use GNAT.Command_Line;
with Ocarina.Namet; use Ocarina.Namet; with Ocarina.Namet; use Ocarina.Namet;
package body Ocarina.Backends.ARINC653_Conf is package body Ocarina.Backends.ARINC653_Conf is
...@@ -59,9 +57,6 @@ package body Ocarina.Backends.ARINC653_Conf is ...@@ -59,9 +57,6 @@ package body Ocarina.Backends.ARINC653_Conf is
package XTN renames Ocarina.Backends.XML_Tree.Nodes; package XTN renames Ocarina.Backends.XML_Tree.Nodes;
package XTU renames Ocarina.Backends.XML_Tree.Nutils; package XTU renames Ocarina.Backends.XML_Tree.Nutils;
Remove_Generated_Sources : Boolean := False;
Generated_Sources_Directory : Name_Id := No_Name;
-------------- --------------
-- Generate -- -- Generate --
-------------- --------------
...@@ -107,30 +102,6 @@ package body Ocarina.Backends.ARINC653_Conf is ...@@ -107,30 +102,6 @@ package body Ocarina.Backends.ARINC653_Conf is
procedure Init is procedure Init is
begin begin
Generated_Sources_Directory := Get_String_Name (".");
Initialize_Option_Scan;
loop
case Getopt ("* b z o:") is
when ASCII.NUL =>
exit;
when 'z' =>
Remove_Generated_Sources := True;
when 'o' =>
declare
D : constant String := Parameter;
begin
if D'Length /= 0 then
Generated_Sources_Directory := Get_String_Name (D);
end if;
end;
when others =>
null;
end case;
end loop;
Register_Backend ("ARINC653_Conf", Generate'Access, Statistics); Register_Backend ("ARINC653_Conf", Generate'Access, Statistics);
end Init; end Init;
......
...@@ -36,16 +36,9 @@ with Ocarina.Backends.ASN1_Tree.Generator; ...@@ -36,16 +36,9 @@ with Ocarina.Backends.ASN1_Tree.Generator;
with Ocarina.Backends.ASN1_Tree.Nutils; with Ocarina.Backends.ASN1_Tree.Nutils;
with Ocarina.Backends.ASN1.Deployment; with Ocarina.Backends.ASN1.Deployment;
with Ocarina.Backends.Utils; with Ocarina.Backends.Utils;
with GNAT.Command_Line;
with Ocarina.Namet;
package body Ocarina.Backends.ASN1 is package body Ocarina.Backends.ASN1 is
use GNAT.Command_Line;
use Ocarina.Namet;
use Ocarina.Backends.Messages; use Ocarina.Backends.Messages;
use Ocarina.Backends.ASN1_Tree.Generator; use Ocarina.Backends.ASN1_Tree.Generator;
use Ocarina.Backends.ASN1_Tree.Nutils; use Ocarina.Backends.ASN1_Tree.Nutils;
...@@ -53,8 +46,6 @@ package body Ocarina.Backends.ASN1 is ...@@ -53,8 +46,6 @@ package body Ocarina.Backends.ASN1 is
use Ocarina.Backends.Expander; use Ocarina.Backends.Expander;
use Ocarina.Instances; use Ocarina.Instances;
Generated_Sources_Directory : Name_Id := No_Name;
procedure Visit_Architecture_Instance (E : Node_Id); procedure Visit_Architecture_Instance (E : Node_Id);
-- Most top level visitor routine. E is the root of the AADL -- Most top level visitor routine. E is the root of the AADL
-- instance tree. The procedure does a traversal for each -- instance tree. The procedure does a traversal for each
...@@ -99,27 +90,6 @@ package body Ocarina.Backends.ASN1 is ...@@ -99,27 +90,6 @@ package body Ocarina.Backends.ASN1 is
procedure Init is procedure Init is
begin begin
ASN1_Tree.Nutils.Initialize; ASN1_Tree.Nutils.Initialize;
Generated_Sources_Directory := Get_String_Name (".");
Initialize_Option_Scan;
loop
case Getopt ("* b z ec er o: perf") is
when ASCII.NUL =>
exit;
when 'o' =>
declare
D : constant String := Parameter;
begin
if D'Length /= 0 then
Generated_Sources_Directory := Get_String_Name (D);
end if;
end;
when others =>
null;
end case;
end loop;
Register_Backend ("asn1_deployment", Generate'Access, ASN1_Deployment); Register_Backend ("asn1_deployment", Generate'Access, ASN1_Deployment);
end Init; end Init;
......
...@@ -39,7 +39,7 @@ with Ocarina.Instances; use Ocarina.Instances; ...@@ -39,7 +39,7 @@ with Ocarina.Instances; use Ocarina.Instances;
with Ocarina.ME_AADL.AADL_Instances.Entities; with Ocarina.ME_AADL.AADL_Instances.Entities;
with Ocarina.Backends.Properties; use Ocarina.Backends.Properties; with Ocarina.Backends.Properties; use Ocarina.Backends.Properties;
with Ocarina.Options; use Ocarina.Options; with Ocarina.Options; use Ocarina.Options;
with GNAT.Command_Line;
with Utils; use Utils; with Utils; use Utils;
with Ada.Text_IO; with Ada.Text_IO;
...@@ -290,8 +290,6 @@ package body Ocarina.Backends.BoundT is ...@@ -290,8 +290,6 @@ package body Ocarina.Backends.BoundT is
procedure Init is procedure Init is
begin begin
-- Registration of the generator
Register_Backend ("boundt", Generate'Access, Bound_T); Register_Backend ("boundt", Generate'Access, Bound_T);
end Init; end Init;
...@@ -300,9 +298,8 @@ package body Ocarina.Backends.BoundT is ...@@ -300,9 +298,8 @@ package body Ocarina.Backends.BoundT is
-------------- --------------
procedure Generate (AADL_Root : Node_Id) is procedure Generate (AADL_Root : Node_Id) is
use GNAT.Command_Line;
Instance_Root : Node_Id; Instance_Root : Node_Id;
begin begin
-- Instantiate the AADL tree -- Instantiate the AADL tree
...@@ -311,23 +308,6 @@ package body Ocarina.Backends.BoundT is ...@@ -311,23 +308,6 @@ package body Ocarina.Backends.BoundT is
raise Program_Error; raise Program_Error;
end if; end if;
Initialize_Option_Scan;
loop
case Getopt ("* boundt_process:") is
when ASCII.NUL =>
exit;
when 'b' =>
if Full_Switch = "boundt_process" then
Boundt_Process := To_Lower (Get_String_Name (Parameter));
end if;
when others =>
null;
end case;
end loop;
-- Open a new TPO file -- Open a new TPO file
if Boundt_Process = No_Name then if Boundt_Process = No_Name then
......
...@@ -37,7 +37,6 @@ with Ocarina.Backends.Utils; ...@@ -37,7 +37,6 @@ with Ocarina.Backends.Utils;
with Ocarina.Backends.XML_Tree.Nodes; with Ocarina.Backends.XML_Tree.Nodes;
with Ocarina.Backends.XML_Tree.Nutils; with Ocarina.Backends.XML_Tree.Nutils;
with Ocarina.Backends.XML_Tree.Generator; with Ocarina.Backends.XML_Tree.Generator;
with GNAT.Command_Line; use GNAT.Command_Line;
with Ocarina.Namet; use Ocarina.Namet; with Ocarina.Namet; use Ocarina.Namet;
...@@ -51,9 +50,6 @@ package body Ocarina.Backends.Carts is ...@@ -51,9 +50,6 @@ package body Ocarina.Backends.Carts is
package XTN renames Ocarina.Backends.XML_Tree.Nodes; package XTN renames Ocarina.Backends.XML_Tree.Nodes;
package XTU renames Ocarina.Backends.XML_Tree.Nutils; package XTU renames Ocarina.Backends.XML_Tree.Nutils;
Generated_Sources_Directory : Name_Id := No_Name;
Remove_Generated_Sources : Boolean := False;
procedure Visit_Architecture_Instance (E : Node_Id); procedure Visit_Architecture_Instance (E : Node_Id);
-- Most top level visitor routine. E is the root of the AADL -- Most top level visitor routine. E is the root of the AADL
-- instance tree. The procedure does a traversal for each -- instance tree. The procedure does a traversal for each
...@@ -97,30 +93,6 @@ package body Ocarina.Backends.Carts is ...@@ -97,30 +93,6 @@ package body Ocarina.Backends.Carts is
procedure Init is procedure Init is
begin begin
Generated_Sources_Directory := Get_String_Name (".");
Initialize_Option_Scan;
loop
case Getopt ("* z o:") is
when ASCII.NUL =>
exit;
when 'z' =>
Remove_Generated_Sources := True;
when 'o' =>
declare
D : constant String := Parameter;
begin
if D'Length /= 0 then
Generated_Sources_Directory := Get_String_Name (D);
end if;
end;
when others =>
null;
end case;
end loop;
Register_Backend ("carts", Generate'Access, Carts_XML); Register_Backend ("carts", Generate'Access, Carts_XML);
end Init; end Init;
......
...@@ -38,10 +38,6 @@ with Ocarina.Backends.XML_Tree.Nodes; ...@@ -38,10 +38,6 @@ with Ocarina.Backends.XML_Tree.Nodes;
with Ocarina.Backends.XML_Tree.Nutils; with Ocarina.Backends.XML_Tree.Nutils;
with Ocarina.Backends.XML_Tree.Generator; with Ocarina.Backends.XML_Tree.Generator;
with GNAT.Command_Line; use GNAT.Command_Line;
with Ocarina.Namet; use Ocarina.Namet;
package body Ocarina.Backends.Cheddar is package body Ocarina.Backends.Cheddar is
use Ocarina.Instances; use Ocarina.Instances;
...@@ -52,8 +48,6 @@ package body Ocarina.Backends.Cheddar is ...@@ -52,8 +48,6 @@ package body Ocarina.Backends.Cheddar is
package XTN renames Ocarina.Backends.XML_Tree.Nodes; package XTN renames Ocarina.Backends.XML_Tree.Nodes;
package XTU renames Ocarina.Backends.XML_Tree.Nutils; package XTU renames Ocarina.Backends.XML_Tree.Nutils;
Generated_Sources_Directory : Name_Id := No_Name;
procedure Visit_Architecture_Instance (E : Node_Id); procedure Visit_Architecture_Instance (E : Node_Id);
-- Most top level visitor routine. E is the root of the AADL -- Most top level visitor routine. E is the root of the AADL
-- instance tree. The procedure does a traversal for each -- instance tree. The procedure does a traversal for each
...@@ -102,27 +96,6 @@ package body Ocarina.Backends.Cheddar is ...@@ -102,27 +96,6 @@ package body Ocarina.Backends.Cheddar is
procedure Init is procedure Init is
begin begin
Generated_Sources_Directory := Get_String_Name (".");
Initialize_Option_Scan;
loop
case Getopt ("* b o:") is
when ASCII.NUL =>
exit;
when 'o' =>
declare
D : constant String := Parameter;
begin
if D'Length /= 0 then
Generated_Sources_Directory := Get_String_Name (D);
end if;
end;
when others =>
null;
end case;
end loop;
Register_Backend ("cheddar", Generate'Access, Cheddar_XML); Register_Backend ("cheddar", Generate'Access, Cheddar_XML);
end Init; end Init;
......
...@@ -36,10 +36,6 @@ with Ocarina.Backends.XML_Tree.Generator; ...@@ -36,10 +36,6 @@ with Ocarina.Backends.XML_Tree.Generator;
with Ocarina.Backends.Utils; with Ocarina.Backends.Utils;
with Ocarina.Backends.Connection_Matrix.Main; with Ocarina.Backends.Connection_Matrix.Main;
with GNAT.Command_Line; use GNAT.Command_Line;
with Ocarina.Namet; use Ocarina.Namet;
package body Ocarina.Backends.Connection_Matrix is package body Ocarina.Backends.Connection_Matrix is
use Ocarina.Instances; use Ocarina.Instances;
...@@ -48,9 +44,6 @@ package body Ocarina.Backends.Connection_Matrix is ...@@ -48,9 +44,6 @@ package body Ocarina.Backends.Connection_Matrix is
use Ocarina.Backends.XML_Tree.Generator; use Ocarina.Backends.XML_Tree.Generator;
use Ocarina.Backends.Utils; use Ocarina.Backends.Utils;
Remove_Generated_Sources : Boolean := False;
Generated_Sources_Directory : Name_Id := No_Name;
procedure Visit_Architecture_Instance (E : Node_Id); procedure Visit_Architecture_Instance (E : Node_Id);
-- Most top level visitor routine. E is the root of the AADL -- Most top level visitor routine. E is the root of the AADL
-- instance tree. The procedure does a traversal for each -- instance tree. The procedure does a traversal for each
...@@ -99,30 +92,6 @@ package body Ocarina.Backends.Connection_Matrix is ...@@ -99,30 +92,6 @@ package body Ocarina.Backends.Connection_Matrix is
procedure Init is procedure Init is
begin begin
Generated_Sources_Directory := Get_String_Name (".");
Initialize_Option_Scan;
loop
case Getopt ("* b z o:") is
when ASCII.NUL =>
exit;
when 'z' =>
Remove_Generated_Sources := True;
when 'o' =>
declare
D : constant String := Parameter;
begin
if D'Length /= 0 then
Generated_Sources_Directory := Get_String_Name (D);
end if;
end;
when others =>
null;
end case;
end loop;
Register_Backend Register_Backend
("Connection_Matrix", ("Connection_Matrix",
Generate'Access, Generate'Access,
......
...@@ -41,8 +41,6 @@ with Ocarina.Backends.Deos_Conf.Naming; ...@@ -41,8 +41,6 @@ with Ocarina.Backends.Deos_Conf.Naming;
with Ocarina.Backends.Deos_Conf.Partitions; with Ocarina.Backends.Deos_Conf.Partitions;
with Ocarina.Backends.Utils; with Ocarina.Backends.Utils;
with GNAT.Command_Line; use GNAT.Command_Line;
with Ocarina.Namet; use Ocarina.Namet; with Ocarina.Namet; use Ocarina.Namet;
package body Ocarina.Backends.Deos_Conf is package body Ocarina.Backends.Deos_Conf is
...@@ -58,9 +56,6 @@ package body Ocarina.Backends.Deos_Conf is ...@@ -58,9 +56,6 @@ package body Ocarina.Backends.Deos_Conf is
package XTN renames Ocarina.Backends.XML_Tree.Nodes; package XTN renames Ocarina.Backends.XML_Tree.Nodes;
package XTU renames Ocarina.Backends.XML_Tree.Nutils; package XTU renames Ocarina.Backends.XML_Tree.Nutils;
Remove_Generated_Sources : Boolean := False;
Generated_Sources_Directory : Name_Id := No_Name;
-------------- --------------
-- Generate -- -- Generate --
-------------- --------------
...@@ -106,30 +101,6 @@ package body Ocarina.Backends.Deos_Conf is ...@@ -106,30 +101,6 @@ package body Ocarina.Backends.Deos_Conf is
procedure Init is procedure Init is
begin begin
Generated_Sources_Directory := Get_String_Name (".");
Initialize_Option_Scan;
loop
case Getopt ("* b z o:") is
when ASCII.NUL =>
exit;
when 'z' =>
Remove_Generated_Sources := True;
when 'o' =>
declare
D : constant String := Parameter;
begin
if D'Length /= 0 then
Generated_Sources_Directory := Get_String_Name (D);
end if;
end;
when others =>
null;
end case;
end loop;
Register_Backend ("Deos_Conf", Generate'Access, Deos_XML); Register_Backend ("Deos_Conf", Generate'Access, Deos_XML);
end Init; end Init;
......
...@@ -36,10 +36,6 @@ with Ocarina.Backends.XML_Tree.Generator; ...@@ -36,10 +36,6 @@ with Ocarina.Backends.XML_Tree.Generator;
with Ocarina.Backends.Utils; with Ocarina.Backends.Utils;
with Ocarina.Backends.Functions_Matrix.Main; with Ocarina.Backends.Functions_Matrix.Main;
with GNAT.Command_Line; use GNAT.Command_Line;
with Ocarina.Namet; use Ocarina.Namet;
package body Ocarina.Backends.Functions_Matrix is package body Ocarina.Backends.Functions_Matrix is
use Ocarina.Instances; use Ocarina.Instances;
...@@ -48,9 +44,6 @@ package body Ocarina.Backends.Functions_Matrix is ...@@ -48,9 +44,6 @@ package body Ocarina.Backends.Functions_Matrix is
use Ocarina.Backends.XML_Tree.Generator; use Ocarina.Backends.XML_Tree.Generator;
use Ocarina.Backends.Utils; use Ocarina.Backends.Utils;
Remove_Generated_Sources : Boolean := False;
Generated_Sources_Directory : Name_Id := No_Name;
procedure Visit_Architecture_Instance (E : Node_Id); procedure Visit_Architecture_Instance (E : Node_Id);
-- Most top level visitor routine. E is the root of the AADL -- Most top level visitor routine. E is the root of the AADL
-- instance tree. The procedure does a traversal for each -- instance tree. The procedure does a traversal for each
...@@ -101,34 +94,8 @@ package body Ocarina.Backends.Functions_Matrix is ...@@ -101,34 +94,8 @@ package body Ocarina.Backends.Functions_Matrix is
procedure Init is procedure Init is
begin begin
Generated_Sources_Directory := Get_String_Name (".");
Initialize_Option_Scan;
loop
case Getopt ("* b z o:") is
when ASCII.NUL =>
exit;
when 'z' =>
Remove_Generated_Sources := True;
when 'o' =>
declare
D : constant String := Parameter;
begin
if D'Length /= 0 then
Generated_Sources_Directory := Get_String_Name (D);
end if;
end;
when others =>
null;
end case;
end loop;
Register_Backend Register_Backend
("Function_Matrix", ("Function_Matrix", Generate'Access, Functions_Matrix_Analysis);
Generate'Access,
Functions_Matrix_Analysis);
end Init; end Init;
----------- -----------
......
...@@ -33,11 +33,9 @@ with Ocarina.Instances; ...@@ -33,11 +33,9 @@ with Ocarina.Instances;
with Ocarina.Backends.Expander; with Ocarina.Backends.Expander;
with Ocarina.Backends.Messages; with Ocarina.Backends.Messages;
with Ocarina.Backends.Utils; with Ocarina.Backends.Utils;
-- with Ocarina.Backends.MAST_Tree.Nodes;
with Ocarina.Backends.MAST_Tree.Nutils; with Ocarina.Backends.MAST_Tree.Nutils;
with Ocarina.Backends.MAST.Main; with Ocarina.Backends.MAST.Main;
with Ocarina.Backends.MAST_Tree.Generator; with Ocarina.Backends.MAST_Tree.Generator;
with GNAT.Command_Line; use GNAT.Command_Line;
with Ocarina.Namet; use Ocarina.Namet; with Ocarina.Namet; use Ocarina.Namet;
...@@ -48,12 +46,8 @@ package body Ocarina.Backends.MAST is ...@@ -48,12 +46,8 @@ package body Ocarina.Backends.MAST is
use Ocarina.Backends.Utils; use Ocarina.Backends.Utils;
use Ocarina.Backends.Expander;