Commit 9a969aaa authored by Bechir Zalila's avatar Bechir Zalila

* (ocarina-backends.ad?): relocate the backend fetching code to a new

	subprogram (Get_Backend) as it will be used elsewhere.

	* (ocarina-fe_aadl-parser-annexes.adb, ocarina-be_aadl-annexes.adb):
	Always keep track of the annex raw text to allow displaying it during
	pretty printing
parent e5c8f156
......@@ -115,25 +115,21 @@ package body Ocarina.Backends is
-- given in the instance root system.
if Backend_Name /= No_Name then
for B in Backend_Table.First .. Backend_Table.Last loop
if Backend_Table.Table (B).Name = Backend_Name then
Current_Backend := B;
Current_Backend_Kind := Backend_Table.Table (B).Kind;
exit;
end if;
end loop;
Current_Backend := Get_Backend (Backend_Name);
if Current_Backend /= 0 then
Current_Backend_Kind := Backend_Table.Table (Current_Backend).Kind;
end if;
elsif Current_Backend_Name = No_Name then
Display_Error ("No backend name specified", Fatal => True);
else
for B in Backend_Table.First .. Backend_Table.Last loop
if Backend_Table.Table (B).Name = Current_Backend_Name then
Current_Backend := B;
Current_Backend_Kind := Backend_Table.Table (B).Kind;
exit;
end if;
end loop;
Current_Backend := Get_Backend (Current_Backend_Name);
if Current_Backend /= 0 then
Current_Backend_Kind := Backend_Table.Table (Current_Backend).Kind;
end if;
end if;
if Current_Backend = 0 then
......@@ -151,6 +147,26 @@ package body Ocarina.Backends is
Errors.Display_Bug_Box (E);
end Generate_Code;
-----------------
-- Get_Backend --
-----------------
function Get_Backend (Backend_Name : Name_Id := No_Name) return Natural is
Current_Backend : Natural := 0;
begin
if Backend_Name /= No_Name then
for B in Backend_Table.First .. Backend_Table.Last loop
if Backend_Table.Table (B).Name = Backend_Name then
Current_Backend := B;
exit;
end if;
end loop;
end if;
return Current_Backend;
end Get_Backend;
------------------------------
-- Get_Current_Backend_Kind --
------------------------------
......
......@@ -91,6 +91,10 @@ package Ocarina.Backends is
-- set in the command line. If the backend name and the current
-- backend name are set, backend name has the priority.
function Get_Backend (Backend_Name : Name_Id := No_Name) return Natural;
-- Return the index of the backend corresponding to the given
-- name. 0 means no backend was found.
procedure Init;
-- Initialize the Backends module by registering the several
-- implemented code generators.
......
......@@ -80,7 +80,13 @@ package body Ocarina.BE_AADL.Annexes is
case AADL_Version is
when AADL_V2 =>
if Present (Corresponding_Annex (Node)) then
if Present (Corresponding_Annex (Node))
and then Get_Backend (Name (Identifier (Node))) /= 0
then
-- Pretty print Annexe if we can parse them and if
-- there is a pretty printer. Should one of these two
-- condition fail, we fall back to dumping raw text.
Print_Token (T_Begin_Annex);
Generate_Code
(Corresponding_Annex (Node),
......
......@@ -100,15 +100,12 @@ package body Ocarina.FE_AADL.Parser.Annexes is
Namespace);
end if;
-- Do not display error message if No_Node because if there are
-- errors when annex parsing, errors messages were already displaying
-- so continue to parse AADL_Specification and just raise a warning
if No (Annex_Root) then
Restore_Lexer (Loc_Start_Annex);
Scan_Raw_Text (T_End_Annex);
Annex_Content := Raw_Text_Value;
end if;
-- Keep the raw text of the annex in case we do not have a
-- pretty printer for the current annex.
Restore_Lexer (Loc_Start_Annex);
Scan_Raw_Text (T_End_Annex);
Annex_Content := Raw_Text_Value;
Scan_Token;
if Token /= T_End_Annex then
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment