ocarina-backends-pn-printer.adb 7.14 KB
Newer Older
1 2 3 4 5 6 7 8
------------------------------------------------------------------------------
--                                                                          --
--                           OCARINA COMPONENTS                             --
--                                                                          --
--          O C A R I N A . B A C K E N D S . P N . P R I N T E R           --
--                                                                          --
--                                 B o d y                                  --
--                                                                          --
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
--    Copyright (C) 2008-2009 Telecom ParisTech, 2010-2015 ESA & ISAE.      --
--                                                                          --
-- 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.                     --
--                                                                          --
-- 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 34 35 36 37 38 39 40 41 42 43
--                                                                          --
------------------------------------------------------------------------------

with Ocarina.Backends.PN.Nodes;
with Ocarina.Backends.PN.Nutils;

package body Ocarina.Backends.PN.Printer is

   package OPN renames Ocarina.Backends.PN.Nodes;
   package OPU renames Ocarina.Backends.PN.Nutils;

   --------------------
   --  Set_Printers  --
   --------------------

44 45 46 47
   procedure Set_Printers
     (P_Place    : P_Print_Place;
      P_Trans    : P_Print_Trans;
      P_Form_Inf : P_Print_Formalism_Information)
48 49
   is
   begin
50 51
      Proc_Print_Place                 := P_Place;
      Proc_Print_Trans                 := P_Trans;
52 53 54 55 56 57 58
      Proc_Print_Formalism_Information := P_Form_Inf;
   end Set_Printers;

   --------------------------
   --  Print_Pn_Generated  --
   --------------------------

yoogx's avatar
yoogx committed
59
   procedure Print_Pn_Generated (Pn_Generated : Node_Id) is
60 61 62 63 64 65 66 67 68
   begin
      Proc_Print_Formalism_Information.all (Pn_Generated);
      Print_Pn_Box (Pn_Generated);
   end Print_Pn_Generated;

   --------------------
   --  Print_Pn_Box  --
   --------------------

yoogx's avatar
yoogx committed
69
   procedure Print_Pn_Box (Pn_Generated : Node_Id) is
70 71 72 73 74 75
      use OPN;
      use OPU;

      Node_Iter : Node_Id;
   begin
      if not Is_Empty (Pn_Subcomponents (Pn_Box (Pn_Generated))) then
76 77
         Node_Iter :=
           OPN.First_Node (Pn_Subcomponents (Pn_Box (Pn_Generated)));
78 79 80 81 82 83 84 85 86 87 88
         while Present (Node_Iter) loop
            if OPN.Kind (Node_Iter) = K_Thread_Pattern then
               Print_Thread (Node_Iter, Pn_Generated);
            else
               Print_Component (Node_Iter, Pn_Generated);
            end if;

            Node_Iter := OPN.Next_Node (Node_Iter);
         end loop;
      end if;
      if not Is_Empty (Pn_Interconnections (Pn_Box (Pn_Generated))) then
89 90
         Node_Iter :=
           OPN.First_Node (Pn_Interconnections (Pn_Box (Pn_Generated)));
91 92 93 94 95 96 97 98 99 100 101
         while Present (Node_Iter) loop
            Proc_Print_Place.all (Pn_Generated, Node_Iter);
            Node_Iter := OPN.Next_Node (Node_Iter);
         end loop;
      end if;
   end Print_Pn_Box;

   --------------------
   --  Print_Thread  --
   --------------------

yoogx's avatar
yoogx committed
102
   procedure Print_Thread (Pn_Thread : Node_Id; Pn_Generated : Node_Id) is
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
      use OPN;
      use OPU;

      Node_Iter : Node_Id;
   begin
      Print_Component (Pn_Thread, Pn_Generated);

      --  call sequences
      if not Is_Empty (Call_Seq (Pn_Thread)) then
         Node_Iter := OPN.First_Node (Call_Seq (Pn_Thread));
         while Present (Node_Iter) loop
            Print_Call_Seq (Node_Iter, Pn_Generated);
            Node_Iter := OPN.Next_Node (Node_Iter);
         end loop;
      end if;

      --  in ports
      if not Is_Empty (In_Ports (Pn_Thread)) then
         Node_Iter := OPN.First_Node (In_Ports (Pn_Thread));
         while Present (Node_Iter) loop
            Print_Component (Node_Iter, Pn_Generated);
            Node_Iter := OPN.Next_Node (Node_Iter);
         end loop;
      end if;

      --  out ports
      if not Is_Empty (Out_Ports (Pn_Thread)) then
         Node_Iter := OPN.First_Node (Out_Ports (Pn_Thread));
         while Present (Node_Iter) loop
            Print_Component (Node_Iter, Pn_Generated);
            Node_Iter := OPN.Next_Node (Node_Iter);
         end loop;
      end if;

   end Print_Thread;

   ----------------------
   --  Print_Call_Seq  --
   ----------------------

yoogx's avatar
yoogx committed
143
   procedure Print_Call_Seq (Pn_Call : Node_Id; Pn_Generated : Node_Id) is
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161
      use OPN;
      use OPU;

      Node_Iter : Node_Id;
   begin
      if not Is_Empty (Spg_Call (Pn_Call)) then
         Node_Iter := OPN.First_Node (Spg_Call (Pn_Call));
         while Present (Node_Iter) loop
            Print_Component (Node_Iter, Pn_Generated);
            Node_Iter := OPN.Next_Node (Node_Iter);
         end loop;
      end if;
   end Print_Call_Seq;

   -----------------------
   --  Print_Component  --
   -----------------------

yoogx's avatar
yoogx committed
162
   procedure Print_Component (Pn_Sub : Node_Id; Pn_Generated : Node_Id) is
163 164 165 166 167 168 169 170 171 172 173
      use OPN;
      use OPU;

      Node_Iter : Node_Id;
   begin
      if not Is_Empty (Public_Interfaces (Pn_Sub)) then
         Node_Iter := OPN.First_Node (Public_Interfaces (Pn_Sub));
         while Present (Node_Iter) loop
            Proc_Print_Trans.all (Pn_Generated, Node_Iter);
            Node_Iter := OPN.Next_Node (Node_Iter);
         end loop;
yoogx's avatar
yoogx committed
174

175 176 177 178 179 180 181 182
      end if;
      if not Is_Empty (Internal_Transitions (Pn_Sub)) then
         Node_Iter := OPN.First_Node (Internal_Transitions (Pn_Sub));
         while Present (Node_Iter) loop
            Proc_Print_Trans.all (Pn_Generated, Node_Iter);
            Node_Iter := OPN.Next_Node (Node_Iter);
         end loop;
      end if;
yoogx's avatar
yoogx committed
183

184 185 186 187 188 189 190 191 192 193
      if not Is_Empty (Internal_Places (Pn_Sub)) then
         Node_Iter := OPN.First_Node (Internal_Places (Pn_Sub));
         while Present (Node_Iter) loop
            Proc_Print_Place.all (Pn_Generated, Node_Iter);
            Node_Iter := OPN.Next_Node (Node_Iter);
         end loop;
      end if;
   end Print_Component;

end Ocarina.Backends.PN.Printer;