ocarina-be_aadl_ba-identifiers.adb 5.04 KB
Newer Older
1 2 3 4 5 6 7 8
------------------------------------------------------------------------------
--                                                                          --
--                           OCARINA COMPONENTS                             --
--                                                                          --
--       O C A R I N A . B E _ A A D L _ B A . I D E N T I F I E R S        --
--                                                                          --
--                                 B o d y                                  --
--                                                                          --
9
--       Copyright (C) 2009 Telecom ParisTech, 2010-2016 ESA & ISAE.        --
10
--                                                                          --
11 12 13 14 15 16
-- Ocarina  is free software; you can redistribute it and/or modify under   --
-- terms of the  GNU General Public License as published  by the Free Soft- --
-- ware  Foundation;  either version 3,  or (at your option) any later ver- --
-- sion. Ocarina is distributed in the hope that it will be useful, but     --
-- WITHOUT ANY WARRANTY; without even the implied warranty of               --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                     --
17
--                                                                          --
18 19 20 21 22 23 24 25
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception,   --
-- version 3.1, as published by the Free Software Foundation.               --
--                                                                          --
-- You should have received a copy of the GNU General Public License and    --
-- a copy of the GCC Runtime Library Exception along with this program;     --
-- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    --
-- <http://www.gnu.org/licenses/>.                                          --
26
--                                                                          --
jhugues's avatar
jhugues committed
27 28
--                 Ocarina is maintained by the TASTE project               --
--                      (taste-users@lists.tuxfamily.org)                   --
29 30 31
--                                                                          --
------------------------------------------------------------------------------

32 33
with Ocarina.Namet;
with Ocarina.Output;
34 35 36 37 38 39 40

with Ocarina.ME_AADL_BA.BA_Tree.Nodes;
with Ocarina.ME_AADL_BA.BA_Tree.Nutils;
with Ocarina.BE_AADL_BA.Expressions;

package body Ocarina.BE_AADL_BA.Identifiers is

41 42
   use Ocarina.Namet;
   use Ocarina.Output;
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
   use Ocarina.ME_AADL_BA.BA_Tree.Nodes;
   use Ocarina.ME_AADL_BA.BA_Tree.Nutils;
   use Ocarina.BE_AADL_BA.Expressions;

   ----------------------
   -- Print_Identifier --
   ----------------------

   procedure Print_Identifier (Node : Node_Id) is
      pragma Assert (Kind (Node) = K_Identifier);
   begin
      Write_Name (Display_Name (Node));
   end Print_Identifier;

   ---------------------------------
   -- Print_Identifier_With_Value --
   ---------------------------------

   procedure Print_Identifier_With_Value (Node : Node_Id) is
62 63
      pragma Assert (Kind (Node) = K_Identifier
                       or else Kind (Node) = K_Identifier_With_Value);
64 65 66 67 68 69 70 71
   begin
      Write_Name (Display_Name (Node));

      if Kind (Node) = K_Identifier_With_Value then
         Print_Token (T_Left_Parenthesis);

         if Present (Value_Constant (Node)) then
            case Kind (Value_Constant (Node)) is
72 73 74 75 76 77 78
               when K_Literal           => Print_Literal
                                                      (Value_Constant (Node));
               when K_Property_Constant => Print_Property_Constant
                                                      (Value_Constant (Node));
               when K_Identifier        => Print_Identifier
                                                      (Value_Constant (Node));
               when others              => Write_Line (Bug_Str);
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
            end case;

         elsif Is_Others (Node) then
            Print_Token (T_Others);
         end if;

         Print_Token (T_Right_Parenthesis);
      end if;
   end Print_Identifier_With_Value;

   ------------------------------------
   -- Print_Component_Classifier_Ref --
   ------------------------------------

   procedure Print_Component_Classifier_Ref (Node : Node_Id) is
      pragma Assert (Kind (Node) = K_Component_Classifier_Ref);

      List_Node : Node_Id;
   begin
      if not Is_Empty (Package_Name (Node)) then
         List_Node := First_Node (Package_Name (Node));

         while Present (List_Node) loop
            Print_Identifier (List_Node);
            Print_Token (T_Colon_Colon);

            List_Node := Next_Node (List_Node);
         end loop;
      end if;

      if Present (Component_Type (Node)) then
         Print_Identifier (Component_Type (Node));
      end if;

      if Present (Component_Impl (Node)) then
         Print_Token (T_Dot);
         Print_Identifier (Component_Impl (Node));
      end if;

   end Print_Component_Classifier_Ref;

end Ocarina.BE_AADL_BA.Identifiers;