buildsupport.adb 66 KB
Newer Older
Maxime Perrotin's avatar
Maxime Perrotin committed
1
--  *************************** buildsupport ****************************  --
Maxime Perrotin's avatar
Maxime Perrotin committed
2
--  (c) 2017 European Space Agency - maxime.perrotin@esa.int
Maxime Perrotin's avatar
Maxime Perrotin committed
3 4 5
--  LGPL license, see LICENSE file

--  pragma Style_Checks (Off);
Maxime Perrotin's avatar
Maxime Perrotin committed
6 7 8 9 10 11 12 13
with Ada.Strings.Unbounded,
     Ada.Characters.Handling,
     Ada.Command_Line,
     Ada.Text_IO,
     Ada.Containers.Indefinite_Vectors,
     GNAT.OS_Lib,
     Errors,
     Locations,
Maxime Perrotin's avatar
Maxime Perrotin committed
14 15
     Ocarina.Namet,
     Ocarina.Types,
Maxime Perrotin's avatar
Maxime Perrotin committed
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
     System.Assertions,
     Ocarina.Analyzer,
     Ocarina.Backends.Properties,
     Ocarina.Configuration,
     Ocarina.Files,
     Ocarina.Options,
     Ocarina.Instances,
     Ocarina.Instances.Queries,
     Ocarina.ME_AADL.AADL_Tree.Nodes,
     Ocarina.ME_AADL.AADL_Instances.Entities,
     Ocarina.ME_AADL.AADL_Instances.Nodes,
     Ocarina.ME_AADL.AADL_Instances.Nutils,
     Ocarina.Parser,
     Ocarina.FE_AADL.Parser,
     Imported_Routines,
     Buildsupport_Utils,
     Ocarina.Backends.Utils;

use Ada.Strings.Unbounded,
    Ada.Text_IO,
    Ada.Characters.Handling,
    Locations,
Maxime Perrotin's avatar
Maxime Perrotin committed
38 39
    Ocarina.Namet,
    Ocarina.Types,
Maxime Perrotin's avatar
Maxime Perrotin committed
40 41 42 43 44 45 46 47 48 49 50 51 52
    Ocarina,
    Ocarina.Analyzer,
    Ocarina.Backends.Properties,
    Ocarina.Instances,
    Ocarina.Instances.Queries,
    Ocarina.ME_AADL,
    Ocarina.ME_AADL.AADL_Instances.Entities,
    Ocarina.ME_AADL.AADL_Instances.Nodes,
    Ocarina.ME_AADL.AADL_Instances.Nutils,
    Ocarina.Backends.Properties,
    Buildsupport_Utils,
    GNAT.OS_Lib,
    Imported_Routines;
Maxime Perrotin's avatar
Maxime Perrotin committed
53 54 55 56 57 58 59 60 61

procedure BuildSupport is

   package ATN renames Ocarina.ME_AADL.AADL_Tree.Nodes;

   AADL_Language : Name_Id;

   Interface_Root    : Node_Id := No_Node;
   Deployment_root   : Node_Id := No_Node;
62
   Dataview_root     : Node_ID := No_Node;
Maxime Perrotin's avatar
Maxime Perrotin committed
63 64 65
   Success           : Boolean;
   OutDir            : Integer := 0;
   Stack_Val         : Integer := 0;
66
   Timer_Resolution  : Integer := 0;
Maxime Perrotin's avatar
Maxime Perrotin committed
67 68 69 70 71 72 73 74 75 76
   Subs              : Node_id;
   Interface_view    : Integer := 0;
   Concurrency_view  : Integer := 0;
   Data_View         : Integer := 0;
   Generate_glue     : Boolean := false;
   Keep_case         : Boolean := false;
   AADL_Version      : AADL_Version_Type := Ocarina.AADL_V2;

   procedure Parse_Command_Line;
   procedure Process_Deployment_View (My_Root : Node_Id);
77
   --  procedure Process_DataView (My_Root : Node_Id);
Maxime Perrotin's avatar
Maxime Perrotin committed
78 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 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156
   procedure Process_Interface_View (My_System : Node_Id);
   procedure Browse_Deployment_View_System
                  (My_System : Node_Id; NodeName : String);

   --  Find the bus that is connected to a device through a require
   --  access.

   ------------------------
   -- Find_Connected_Bus --
   ------------------------

   procedure Find_Connected_Bus (Device : Node_Id;
                                 Accessed_Bus : out Node_Id;
                                 Accessed_Port : out Node_Id) is
      F : Node_Id;
      Src : Node_Id;
   begin
      Accessed_Bus := No_Node;
      Accessed_Port := No_Node;
      if not Is_Empty (Features (Device)) then
         F := First_Node (Features (Device));

         while Present (F) loop
            --  The sources of F

            if not Is_Empty (Sources (F)) then
               Src := First_Node (Sources (F));

               if Src /= No_Node then
                  if Item (Src) /= No_Node and then
                     not Is_Empty (Sources (Item (Src))) and then
                     First_Node (Sources (Item (Src))) /= No_Node
                  then

                     Src := Item (First_Node (Sources (Item (Src))));
                     Accessed_Bus := Src;
                     Accessed_Port := F;
                  end if;
               end if;
            end if;
            F := Next_Node (F);
         end loop;
      end if;
   end Find_Connected_Bus;

   ----------------------------
   -- Process_Interface_View --
   ----------------------------

   procedure Process_Interface_View (My_System : Node_Id) is
      Len_Name          : Integer;
      Len_Type          : Integer;
      Current_Function  : Node_Id;
      FV_Subco          : Node_Id;
      CI                : Node_Id;
      Connection_I      : Node_Id;
      Distant_FV        : Node_Id;
      If_I              : Node_Id;
      RI_To_Add         : Node_Id;
      Local_RI_Name     : Name_Id;
      Distant_PI_Name   : Name_Id;
      Param_I           : Node_Id;
      ASN1_Module       : Name_Id;
      ASN1_Filename     : Name_Id := No_Name;
      Operation_Kind    : Supported_RCM_Operation_Kind;
      Sub_I             : Node_Id;
      Encoding          : Supported_ASN1_Encoding;
      Asntype           : Node_Id;
      Basic_Type        : Supported_ASN1_Basic_Type;

   begin

      Exit_On_Error
         (No (My_System),
         "Internal Error, cannot instantiate model");

      if not Is_Empty (Subcomponents (My_System)) then
         --  Set the output directory
         if OutDir > 0 then
Maxime Perrotin's avatar
Maxime Perrotin committed
157 158
            C_Set_OutDir (Ada.Command_Line.Argument (Outdir),
                          Ada.Command_Line.Argument (Outdir)'Length);
Maxime Perrotin's avatar
Maxime Perrotin committed
159 160 161 162
         end if;

         --  Set the stack value
         if Stack_Val > 0 then
Maxime Perrotin's avatar
Maxime Perrotin committed
163 164
            C_Set_Stack (Ada.Command_Line.Argument (stack_val),
                         Ada.Command_Line.Argument (stack_val)'Length);
Maxime Perrotin's avatar
Maxime Perrotin committed
165 166
         end if;

167 168
         --  Set the timer resolution value
         if Timer_Resolution > 0 then
Maxime Perrotin's avatar
Maxime Perrotin committed
169
            C_Set_Timer_Resolution
170 171 172 173
              (Ada.Command_Line.Argument (Timer_Resolution),
               Ada.Command_Line.Argument (Timer_Resolution)'Length);
         end if;

Maxime Perrotin's avatar
Maxime Perrotin committed
174 175 176 177 178 179 180 181 182
         --  Current_function is read from the list of system subcomponents
         Current_function := First_Node (Subcomponents (My_System));

         while Present (Current_Function) loop
            CI := Corresponding_Instance (Current_Function);

            if Get_Category_Of_Component (CI) = CC_System then

               --  Call C function "New_FV" and set the language
Maxime Perrotin's avatar
Maxime Perrotin committed
183 184
               --  Read the implementation language of the current
               --  FV from the Source_Language property
Maxime Perrotin's avatar
Maxime Perrotin committed
185

Maxime Perrotin's avatar
Maxime Perrotin committed
186 187
               declare
                  --  Read the name of the function
Maxime Perrotin's avatar
Maxime Perrotin committed
188 189
                  FV_Name_L : constant String := AIN_Lower (Current_Function);
                  FV_Name   : constant String := AIN_Case (Current_Function);
Maxime Perrotin's avatar
Maxime Perrotin committed
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217
                  --  Read the source language
                  Source_Language : constant Supported_Source_Language :=
                      Get_Source_Language (CI);
                  --  To get the zipfile name where user code is stored
                  SourceText : constant Name_Array := Get_Source_Text (CI);
                  ZipId : Name_Id := No_Name;
               begin
                  C_New_FV (FV_Name_L, FV_Name'Length, FV_Name);

                  case Source_Language is
                     when Language_Ada_95        => C_Set_Language_To_Ada;
                     when Language_C             => C_Set_Language_To_C;
                     when Language_CPP           => C_Set_Language_To_CPP;
                     when Language_VDM           => C_Set_Language_To_VDM;
                     when Language_SDL_OpenGEODE => C_Set_Language_To_SDL;
                     when Language_Scade         => C_Set_Language_To_Scade;
                     when Language_Lustre        => C_Set_Language_To_Scade;
                     when Language_SDL           => C_Set_Language_To_SDL;
                     when Language_SDL_RTDS      => C_Set_Language_To_RTDS;
                     when Language_Simulink      => C_Set_Language_To_Simulink;
                     when Language_Rhapsody      => C_Set_Language_To_Rhapsody;
                     when Language_Gui           => C_Set_Language_To_GUI;
                     when Language_VHDL          => C_Set_Language_To_VHDL;
                     when Language_System_C      => C_Set_Language_To_System_C;
                     when Language_Device        =>
                                             C_Set_Language_To_BlackBox_Device;
                     when Language_QGenAda       => C_Set_Language_To_QGenAda;
                     when Language_QGenC         => C_Set_Language_To_QGenC;
218 219
                     when Language_MicroPython   =>
                                             C_Set_Language_To_MicroPython;
Maxime Perrotin's avatar
Maxime Perrotin committed
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234
                     when others                 => Exit_On_Error (True,
                         "Language is currently not supported: "
                         & Source_Language'Img);
                  end case;

                  --  Retrieve the ZIP file (optionally set by the user)
                  if SourceText'Length /= 0 then
                     ZipId := SourceText (1);
                  end if;
                  if ZipId /= No_Name then
                     C_Set_Zipfile (Get_Name_String (ZipId),
                                    Get_Name_String (ZipId)'Length);
                  end if;
               end;

235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253
                  declare
                     InstanceOf : constant Name_Id :=
                       Get_Instance_Of (CI);
                  begin
                     if InstanceOf /= No_Name then
                        C_Set_Instance_Of (Get_Name_String (InstanceOf),
                           Get_Name_String (InstanceOf)'Length);
                     end if;
                  end;

                  declare
                     IsComponent : constant Boolean :=
                       Get_Is_Component_Type (CI);
                  begin
                     if IsComponent then
                        C_Set_Is_Component_Type;
                     end if;
                  end;

Maxime Perrotin's avatar
Maxime Perrotin committed
254 255 256 257 258 259 260 261 262 263 264 265 266
               --  Parse the functional states of this FV
               if not Is_Empty (Subcomponents (CI)) then
                  FV_Subco := First_Node (Subcomponents (CI));
                  while Present (FV_Subco) loop
                     if Get_Category_Of_Component (FV_Subco) = CC_Data
                     then
                        --  Check that the value of the FS is set
                        Exit_On_Error (Get_String_Property
                           (Corresponding_Instance (FV_Subco),
                              "taste::fs_default_value") = No_Name,
                           "Error: Missing value for context parameter " &
                           Get_Name_String
                              (Name (Identifier (FV_Subco))) &
Maxime Perrotin's avatar
Maxime Perrotin committed
267
                           " in function " & AIN_Case (Current_Function));
Maxime Perrotin's avatar
Maxime Perrotin committed
268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310
                        declare
                           --  Name of the variable
                           FS_name : constant String :=
                            Get_Name_String (Name (Identifier (FV_Subco)));
                           --  Name of the variable respecting case
                           FS_fullname : constant String :=
                            Get_Name_String (Display_Name (Identifier
                                (FV_Subco)));
                           --  ASN.1 type
                           Asn1type : constant Node_Id :=
                            Corresponding_Instance (FV_Subco);

                           FS_type : constant String :=
                                      Get_Name_String
                                          (Get_Type_Source_Name (Asn1type));
                           --  Variable default value
                           FS_value : constant String :=
                                  Get_Name_String (Get_String_Property
                                     (Asn1type, "taste::fs_default_value"));
                           FS_module : constant String :=
                                            Get_ASN1_Module_Name (Asn1type);
                           --  ASN.1 filename
                           NA : constant Name_Array :=
                                                 Get_Source_Text (Asn1type);
                           FS_File : Unbounded_String;
                        begin
                           --  Some special DATA components have no
                           --  Source_Text property in DataView.aadl
                           --  (TASTE-Directive and Tunable Parameter)
                           if NA'Length > 0 then
                              FS_File := US (Get_Name_String (NA (1)));
                           else
                              FS_File := US ("dummy");
                           end if;
                           C_Set_Context_Variable
                                            (FS_name, FS_name'Length,
                                             FS_type, FS_type'Length,
                                             FS_value, FS_value'Length,
                                             FS_module, FS_module'Length,
                                             To_String (FS_file),
                                             To_String (FS_file)'Length,
                                             FS_Fullname);
                        end;
Maxime Perrotin's avatar
Maxime Perrotin committed
311
                     end if;
Maxime Perrotin's avatar
Maxime Perrotin committed
312 313 314 315 316 317 318
                     FV_Subco := Next_Node (FV_Subco);
                  end loop;
               end if;

               --  Parse the interfaces of the FV
               if not Is_Empty (Features (CI)) then
                  If_I := First_Node (Features (CI));
Maxime Perrotin's avatar
Maxime Perrotin committed
319

Maxime Perrotin's avatar
Maxime Perrotin committed
320 321 322 323 324 325 326 327 328
                  while Present (If_I) loop
                     Sub_I := Get_RCM_Operation (If_I);

                     if Present (Sub_I) then
                        --  Call backend Add_PI or Add_RI and for each
                        --  parameter call C function Add_In_Param or
                        --  Add_Out_Param
                        if Is_Subprogram_Access (If_I) and
                                                   Is_Provided (If_I)
Maxime Perrotin's avatar
Maxime Perrotin committed
329 330
                        then
                           declare
Maxime Perrotin's avatar
Maxime Perrotin committed
331 332 333 334
                              PI_string : String :=
                               Get_Name_string
                                (Display_Name (Identifier (If_I)));
                              PI_Name : Name_Id;
Maxime Perrotin's avatar
Maxime Perrotin committed
335
                           begin
Maxime Perrotin's avatar
Maxime Perrotin committed
336 337 338 339
                              PI_Name := Get_Interface_Name (If_I);
                              if PI_Name /= No_Name then
                                 C_Add_PI (Get_Name_String (PI_Name),
                                          Get_Name_String (PI_Name)'Length);
Maxime Perrotin's avatar
Maxime Perrotin committed
340
                              else
Maxime Perrotin's avatar
Maxime Perrotin committed
341 342 343 344 345
                                 --  Keep compatibility with V1.2
                                 if not Keep_case then
                                    PI_string := to_lower (PI_string);
                                 end if;
                                 C_Add_PI (PI_String, PI_String'Length);
Maxime Perrotin's avatar
Maxime Perrotin committed
346 347 348
                              end if;
                           end;

Maxime Perrotin's avatar
Maxime Perrotin committed
349 350 351 352 353 354 355 356 357 358 359
                           if Kind (If_I) = K_Subcomponent_Access_Instance
                              and then
                              Is_Defined_Property
                              (Corresponding_Instance (If_I),
                              "taste::associated_queue_size")
                           then
                              C_Set_Interface_Queue_Size
                                 (Get_Integer_Property
                                    (Corresponding_Instance (If_I),
                                    "taste::associated_queue_size"));
                           end if;
Maxime Perrotin's avatar
Maxime Perrotin committed
360

Maxime Perrotin's avatar
Maxime Perrotin committed
361 362 363 364 365 366 367 368
                           --  Set Provided Interface RCM kind
                           --  (cyclic, sporadic, etc).
                           Operation_Kind := Get_RCM_Operation_Kind (If_I);

                           case Operation_Kind is
                              when Cyclic_Operation =>
                                 C_Set_Cyclic_IF;

369
                              when Sporadic_Operation | Any_Operation =>
Maxime Perrotin's avatar
Maxime Perrotin committed
370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391
                                 C_Set_Sporadic_IF;

                              when Protected_Operation =>
                                 C_Set_Protected_IF;

                              when Unprotected_Operation =>
                                 C_Set_Unprotected_IF;
                           end case;

                           --  Set the period or MIAT of the PI
                           C_Set_Period (Get_RCM_Period (If_I));

                           --  Set the WCET of the PI
                           if Is_Subprogram_Access (If_I) and then
                              Sources (If_I) /= No_List and then
                              First_Node (Sources (If_I)) /= No_Node
                              and then
                              Get_Execution_Time
                                 (Corresponding_Instance
                                    (Item
                                       (First_Node (Sources (If_I)))))
                              /= Empty_Time_Array
Maxime Perrotin's avatar
Maxime Perrotin committed
392 393
                           then
                              declare
Maxime Perrotin's avatar
Maxime Perrotin committed
394 395 396 397 398 399
                                 use Ocarina.Backends.Utils;
                                 Exec_Time : constant Time_Array :=
                                 Get_Execution_Time
                                    (Corresponding_Instance
                                    (Item
                                       (First_Node (Sources (If_I)))));
Maxime Perrotin's avatar
Maxime Perrotin committed
400
                              begin
Maxime Perrotin's avatar
Maxime Perrotin committed
401 402 403
                                 C_Set_Compute_Time
                                  (To_Milliseconds (Exec_Time (0)), "ms", 2,
                                  To_Milliseconds (Exec_Time (1)), "ms", 2);
Maxime Perrotin's avatar
Maxime Perrotin committed
404
                              end;
Maxime Perrotin's avatar
Maxime Perrotin committed
405 406 407 408
                           else
                              C_Set_Compute_Time (0, "ms", 2, 0, "ms", 2);
                              --  Default !
                           end if;
Maxime Perrotin's avatar
Maxime Perrotin committed
409

Maxime Perrotin's avatar
Maxime Perrotin committed
410 411 412 413
                        --   Required interface:
                        elsif Is_Subprogram_Access (If_I) and
                              not (Is_Provided (If_I))
                        then
Maxime Perrotin's avatar
Maxime Perrotin committed
414

Maxime Perrotin's avatar
Maxime Perrotin committed
415 416
                           --  the name of the feature (RI identifier) is:
                           --  Get_Name_String (Name (Identifier (If_I)));
Maxime Perrotin's avatar
Maxime Perrotin committed
417

Maxime Perrotin's avatar
Maxime Perrotin committed
418 419
                           --  Find the distant PI connected to this RI
                           --  and the distant function
Maxime Perrotin's avatar
Maxime Perrotin committed
420

Maxime Perrotin's avatar
Maxime Perrotin committed
421
                           Distant_Fv := No_Node;
Maxime Perrotin's avatar
Maxime Perrotin committed
422

Maxime Perrotin's avatar
Maxime Perrotin committed
423 424 425 426 427 428
                           if Present (Connections (My_System)) then
                              Connection_I := First_Node
                                 (Connections (My_System));
                           else
                              Connection_I := No_Node;
                           end if;
Maxime Perrotin's avatar
Maxime Perrotin committed
429

Maxime Perrotin's avatar
Maxime Perrotin committed
430 431 432 433 434
                           while Present (Connection_I) loop
                              if Corresponding_instance
                                (Get_Referenced_Entity
                                   (Source (Connection_I))) =
                                      Corresponding_Instance (If_I)
Maxime Perrotin's avatar
Maxime Perrotin committed
435
                              then
Maxime Perrotin's avatar
Maxime Perrotin committed
436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465
                                 Distant_FV := Item (First_Node
                                                     (Path
                                                      (Source
                                                       (Connection_I))));
                                 --  Get InterfaceName property if any
                                 Distant_PI_Name := Get_Interface_Name
                                       (Get_Referenced_Entity (
                                         Source (Connection_I)));
                                 --  Get RCM kind from remote PI
                                 Operation_Kind :=
                                       Get_RCM_Operation_Kind
                                          (Get_Referenced_Entity
                                              (Source (Connection_I)));
                              end if;
                              Connection_I := Next_Node (Connection_I);
                           end loop;
                           --  Found Distant PI name and distant function

                           RI_To_Add := Corresponding_Instance (If_I);
                           --  a RI can have a local name which is different
                           --  from the name of the PI it is connected to.
                           Local_RI_Name := Get_Interface_Name (If_I);
                           if Local_RI_Name = No_Name
                                   or Distant_PI_Name = No_Name
                           then
                              if Keep_case then
                                 Local_RI_Name :=
                                    Display_Name (Identifier (If_I));
                                 Distant_PI_Name :=
                                    Display_Name (Identifier (RI_To_Add));
Maxime Perrotin's avatar
Maxime Perrotin committed
466
                              else
Maxime Perrotin's avatar
Maxime Perrotin committed
467 468 469 470
                                 Local_RI_Name :=
                                    Name (Identifier (If_I));
                                 Distant_PI_Name :=
                                    Name (Identifier (RI_To_Add));
Maxime Perrotin's avatar
Maxime Perrotin committed
471
                              end if;
Maxime Perrotin's avatar
Maxime Perrotin committed
472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496
                           end if;
                           --   The 3 arguments to C_Add_RI are:
                           --   (1) the name of the local RI (feature)
                           --   (2) the name of the distant function
                           --   (3) the name of the corresponding PI
                           if Present (Distant_FV) then
                              C_Add_RI
                                 (Get_Name_String (Local_RI_Name),
                                  Get_Name_String (Local_RI_Name)'Length,
                                  Get_Name_String
                                    (Name (Identifier (Distant_FV))),
                                  Get_Name_String
                                   (Name
                                      (Identifier (Distant_FV)))'Length,
                                  Get_Name_String (Distant_PI_Name),
                                  Get_Name_String (Distant_PI_Name)'Length);
                           else
                              C_Add_RI
                                 (Get_Name_String (Local_RI_Name),
                                  Get_Name_String (Local_RI_Name)'Length,
                                  Get_Name_String (Local_RI_Name),
                                  0,
                                  Get_Name_String (Local_RI_Name),
                                  Get_Name_String (Local_RI_Name)'Length);
                           end if;
Maxime Perrotin's avatar
Maxime Perrotin committed
497

Maxime Perrotin's avatar
Maxime Perrotin committed
498 499 500 501
                           case Operation_Kind is
                              when Sporadic_Operation =>
                                 C_Set_ASync_IF;
                                 C_Set_Sporadic_IF;
Maxime Perrotin's avatar
Maxime Perrotin committed
502

Maxime Perrotin's avatar
Maxime Perrotin committed
503 504 505
                              when Protected_Operation =>
                                 C_Set_Sync_IF;
                                 C_Set_Protected_IF;
Maxime Perrotin's avatar
Maxime Perrotin committed
506

Maxime Perrotin's avatar
Maxime Perrotin committed
507 508 509
                              when Unprotected_Operation =>
                                 C_Set_Sync_IF;
                                 C_Set_Unprotected_IF;
Maxime Perrotin's avatar
Maxime Perrotin committed
510

Maxime Perrotin's avatar
Maxime Perrotin committed
511 512 513 514 515 516
                              when others =>
                                 Exit_On_Error (True,
                                            "Unsupported kind of RI: "
                                            & Get_Name_String (Local_RI_Name));
                           end case;
                        end if;
Maxime Perrotin's avatar
Maxime Perrotin committed
517

Maxime Perrotin's avatar
Maxime Perrotin committed
518
                        --  Parse the list of parameters
Maxime Perrotin's avatar
Maxime Perrotin committed
519

Maxime Perrotin's avatar
Maxime Perrotin committed
520 521
                        if not Is_Empty (Features (Sub_I)) then
                           Param_I := First_Node (Features (Sub_I));
Maxime Perrotin's avatar
Maxime Perrotin committed
522

Maxime Perrotin's avatar
Maxime Perrotin committed
523 524 525 526
                           while Present (Param_I) loop
                              if Kind (Param_I) = K_Parameter_Instance then
                                 Asntype := Corresponding_Instance
                                    (Param_I);
Maxime Perrotin's avatar
Maxime Perrotin committed
527

Maxime Perrotin's avatar
Maxime Perrotin committed
528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578
                                 declare
                                    NA : constant Name_Array
                                       := Get_Source_Text (Asntype);
                                 begin
                                    ASN1_Filename := NA (1);
                                 end;

                                 Exit_On_Error
                                   (ASN1_Filename = No_Name,
                                    "Error: Source_Text not defined");

                                 Len_Name := Get_Name_String
                                   (Name (Identifier (Param_I)))'Length;
                                 Len_Type := Get_Name_String
                                   (Name (Identifier (Asntype)))'Length;
                                 ASN1_Module := Get_Ada_Package_Name
                                    (Asntype);
                                 Exit_On_Error
                                   (ASN1_Module = No_Name,
                                    "Error: Data Model is incorrect.");

                                 if Is_In (Param_I) then
                                    C_Add_In_Param
                                      (Get_Name_String
                                         (Display_Name
                                             (Identifier (Param_I))),
                                       Len_Name,
                                       Get_Name_String
                                         (Get_Type_Source_Name (Asntype)),
                                       Len_Type,
                                       Get_Name_String (ASN1_Module),
                                       Get_Name_String
                                          (ASN1_Module)'Length,
                                       Get_Name_String (ASN1_Filename),
                                       Get_Name_String
                                          (ASN1_Filename)'Length);
                                 else
                                    C_Add_Out_Param
                                      (Get_Name_String
                                         (Display_Name
                                             (Identifier (Param_I))),
                                       Len_Name,
                                       Get_Name_String
                                         (Get_Type_Source_Name (Asntype)),
                                       Len_Type,
                                       Get_Name_String (ASN1_Module),
                                       Get_Name_String
                                          (ASN1_Module)'Length,
                                       Get_Name_String (ASN1_Filename),
                                       Get_Name_String
                                          (ASN1_Filename)'Length);
Maxime Perrotin's avatar
Maxime Perrotin committed
579 580
                                 end if;

Maxime Perrotin's avatar
Maxime Perrotin committed
581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622
                                 --  Get the Encoding property:

                                 Encoding := Get_ASN1_Encoding (Param_I);
                                 case Encoding is
                                    when Native => C_Set_Native_Encoding;
                                    when UPER   => C_Set_UPER_Encoding;
                                    when ACN    => C_Set_ACN_Encoding;
                                    when others => null;
                                 end case;

                                 --  Get ASN.1 basic type of the parameter
                                 Basic_type := Get_ASN1_Basic_Type
                                    (Asntype);
                                 case Basic_Type is
                                    pragma Style_Checks (Off);
                                    when Asn1_Sequence =>
                                       C_Set_ASN1_BasicType_Sequence;
                                    when ASN1_SequenceOf =>
                                       C_Set_ASN1_BasicType_SequenceOf;
                                    when ASN1_Enumerated =>
                                       C_Set_ASN1_BasicType_Enumerated;
                                    when ASN1_Set =>
                                       C_Set_ASN1_BasicType_Set;
                                    when ASN1_SetOf =>
                                       C_Set_ASN1_BasicType_SetOf;
                                    when ASN1_Integer =>
                                       C_Set_ASN1_BasicType_Integer;
                                    when ASN1_Boolean =>
                                       C_Set_ASN1_BasicType_Boolean;
                                    when ASN1_Real =>
                                       C_Set_ASN1_BasicType_Real;
                                    when ASN1_OctetString =>
                                       C_Set_ASN1_BasicType_OctetString;
                                    when ASN1_Choice =>
                                       C_Set_ASN1_BasicType_Choice;
                                    when ASN1_String =>
                                       C_Set_ASN1_BasicType_String;
                                    when others =>
                                       C_Set_ASN1_BasicType_Unknown;
                                       pragma Style_Checks (On);
                                 end case;
                              end if;
Maxime Perrotin's avatar
Maxime Perrotin committed
623

Maxime Perrotin's avatar
Maxime Perrotin committed
624 625 626
                              Param_I := Next_Node (Param_I);
                           end loop;
                        end if; -- End processing parameters.
Maxime Perrotin's avatar
Maxime Perrotin committed
627

Maxime Perrotin's avatar
Maxime Perrotin committed
628 629
                        C_End_IF;
                     end if;
Maxime Perrotin's avatar
Maxime Perrotin committed
630

Maxime Perrotin's avatar
Maxime Perrotin committed
631 632 633 634 635
                     If_I := Next_Node (If_I);
                  end loop; -- Go to next interface of this FV

               end if;
               C_End_FV;
Maxime Perrotin's avatar
Maxime Perrotin committed
636 637 638 639 640 641
            end if;
            Current_Function := Next_Node (Current_Function);
         end loop;
      end if;
   end Process_Interface_View;

642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664
   -----------------------------
   -- Process_DataView --
   -----------------------------

--  procedure Process_DataView (My_Root : Node_Id) is
--     CI             : Node_Id;
--  begin
--     Subs := My_Root;
--     while Present (Subs) loop
--        CI := Subs;
--        if Get_Category_Of_Component (CI) = CC_Data then
--           declare
--              SourceText : constant Name_Array := Get_Source_Text (CI);
--           begin
--              if SourceText'Length > 0 then
--                 Put_Line (Get_Name_String (SourceText (1)));
--              end if;
--           end;
--        end if;
--        Subs := Next_Node (Subs);
--     end loop;
--  end Process_DataView;

Maxime Perrotin's avatar
Maxime Perrotin committed
665 666 667 668 669 670 671 672 673 674
   -----------------------------
   -- Process_Deployment_View --
   -----------------------------

   procedure Process_Deployment_View (My_Root : Node_Id) is
      My_Root_System : Node_Id;
      CI             : Node_Id;
      Root_Instance  : Node_Id;
   begin

675
      if My_Root /= No_Node and then Concurrency_view /= 0 then
Maxime Perrotin's avatar
Maxime Perrotin committed
676 677 678 679 680 681 682 683 684
         --  Analyze the tree

         Success := Ocarina.Analyzer.Analyze (AADL_Language, My_Root);
         Exit_On_Error (not Success, "[ERROR] Deployment view is incorrect");
         if Success then
            --  After making sure that the Deployment view is correct, set
            --  the Glue flag

            if generate_glue then
Maxime Perrotin's avatar
Maxime Perrotin committed
685
               C_Set_Glue;
Maxime Perrotin's avatar
Maxime Perrotin committed
686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709
            end if;

            --  Put_Line (Get_Name_String
            --    (Get_Ellidiss_Tool_Version (My_Root)));

            Ocarina.Options.Root_System_Name :=
                  Get_String_Name ("deploymentview.others");

            --  Instantiate AADL tree
            Root_Instance := Instantiate_Model (Root => My_Root);

            My_Root_System := Root_System (Root_Instance);

            --  Name of the ROOT SYSTEM (not implementation)

            declare
               My_Root_System_Name : constant String :=
                 Get_Name_String
                 (Ocarina.ME_AADL.AADL_Tree.Nodes.Name
                    (Ocarina.ME_AADL.AADL_Tree.Nodes.
                       Component_Type_Identifier
                       (Corresponding_Declaration
                        (My_Root_System))));
            begin
Maxime Perrotin's avatar
Maxime Perrotin committed
710 711
               C_Set_Root_node
                   (My_Root_System_Name, My_Root_System_Name'Length);
Maxime Perrotin's avatar
Maxime Perrotin committed
712 713 714 715 716 717 718 719 720 721 722 723 724
            end;

            if not Is_Empty (Subcomponents (My_Root_System)) then
               Subs := First_Node (Subcomponents (My_Root_System));

               while Present (Subs) loop
                  CI := Corresponding_Instance (Subs);

                  if Get_Category_Of_Component (CI) = CC_System then
                     Browse_Deployment_View_System
                         (CI, Get_Name_String (Name (Identifier (Subs))));
                  elsif Get_Category_Of_Component (CI) = CC_Bus then
                     declare
Maxime Perrotin's avatar
Maxime Perrotin committed
725
                        --  Get the list of properties attaches to the bus
Maxime Perrotin's avatar
Maxime Perrotin committed
726 727
                        Properties : constant Property_Maps.Map :=
                                                       Get_Properties_Map (CI);
Maxime Perrotin's avatar
Maxime Perrotin committed
728 729 730
                        Bus_Classifier : Name_Id := No_Name;
                        Pkg_Name : Name_Id := No_Name;
                     begin
Maxime Perrotin's avatar
Maxime Perrotin committed
731
                        --  Iterate on the BUS Instance properties
Maxime Perrotin's avatar
Maxime Perrotin committed
732
                        for each in Properties.Iterate loop
Maxime Perrotin's avatar
Maxime Perrotin committed
733 734 735
                           null;
                           --  Put_Line (Property_Maps.Key (each) & " : " &
                           --            Property_Maps.Element (each));
Maxime Perrotin's avatar
Maxime Perrotin committed
736
                        end loop;
Maxime Perrotin's avatar
Maxime Perrotin committed
737 738
                        Set_Str_To_Name_Buffer ("");
                        if ATN.Namespace
Maxime Perrotin's avatar
Maxime Perrotin committed
739
                            (Corresponding_Declaration (CI)) /= No_Node
Maxime Perrotin's avatar
Maxime Perrotin committed
740 741 742 743 744 745 746 747
                        then
                           Set_Str_To_Name_Buffer ("");
                           Get_Name_String
                              (ATN.Name
                                 (ATN.Identifier
                                    (ATN.Namespace
                                       (Corresponding_Declaration (CI)))));
                           Pkg_Name := Name_Find;
Maxime Perrotin's avatar
Maxime Perrotin committed
748
                           C_Add_Package
Maxime Perrotin's avatar
Maxime Perrotin committed
749 750 751 752 753 754 755 756 757 758 759
                              (Get_Name_String (Pkg_Name),
                              Get_Name_String (Pkg_Name)'Length);
                           Set_Str_To_Name_Buffer ("");
                           Get_Name_String (Pkg_Name);
                           Add_Str_To_Name_Buffer ("::");
                           Get_Name_String_And_Append
                              (Name (Identifier (CI)));
                           Bus_Classifier := Name_Find;
                        else
                           Bus_Classifier := Name (Identifier (CI));
                        end if;
Maxime Perrotin's avatar
Maxime Perrotin committed
760
                        C_New_Bus
Maxime Perrotin's avatar
Maxime Perrotin committed
761 762 763 764
                         (Get_Name_String (Name (Identifier (Subs))),
                          Get_Name_String (Name (Identifier (Subs)))'Length,
                          Get_Name_String (Bus_Classifier),
                          Get_Name_String (Bus_Classifier)'Length);
Maxime Perrotin's avatar
Maxime Perrotin committed
765
                        C_End_Bus;
Maxime Perrotin's avatar
Maxime Perrotin committed
766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781
                     end;
                  end if;
                  Subs := Next_Node (Subs);
               end loop;
            end if;
         end if;
      end if;
   end Process_Deployment_View;

   -------------------------------------
   -- Load_Deployment_View_Properties --
   -------------------------------------

   procedure Load_Deployment_View_Properties (Root_Tree : in out Node_Id) is
      Loc : Location;
      F : Name_Id;
Maxime Perrotin's avatar
Maxime Perrotin committed
782 783 784 785 786
      package Vectors is new Ada.Containers.Indefinite_Vectors (Natural,
                                                                String);
      use Vectors;
      AADL_Lib : Vectors.Vector;

Maxime Perrotin's avatar
Maxime Perrotin committed
787 788 789 790
   begin
      if Root_Tree = No_Node then
         return;
      end if;
Maxime Perrotin's avatar
Maxime Perrotin committed
791 792 793 794 795 796 797 798 799 800 801 802
      AADL_Lib := AADL_Lib &
                  Ada.Command_Line.Argument (Interface_View) &
                  "aadl_project.aadl" &
                  "taste_properties.aadl" &
                  "Cheddar_Properties.aadl" &
                  "communication_properties.aadl" &
                  "deployment_properties.aadl" &
                  "thread_properties.aadl" &
                  "timing_properties.aadl" &
                  "programming_properties.aadl" &
                  "memory_properties.aadl" &
                  "modeling_properties.aadl" &
Maxime Perrotin's avatar
Maxime Perrotin committed
803 804
                  "arinc653.aadl" &
                  --  "arinc653_properties.aadl" &
Maxime Perrotin's avatar
Maxime Perrotin committed
805 806 807
                  "base_types.aadl" &
                  "data_model.aadl" &
                  "deployment.aadl";
Maxime Perrotin's avatar
Maxime Perrotin committed
808 809 810

      Ocarina.FE_AADL.Parser.Add_Pre_Prop_Sets := True;

Maxime Perrotin's avatar
Maxime Perrotin committed
811 812 813 814 815 816
      for each of AADL_Lib loop
         Set_Str_To_Name_Buffer (each);
         F := Ocarina.Files.Search_File (Name_Find);
         Loc := Ocarina.Files.Load_File (F);
         Root_Tree := Ocarina.Parser.Parse (AADL_Language, Root_Tree, Loc);
      end loop;
Maxime Perrotin's avatar
Maxime Perrotin committed
817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857
   end Load_Deployment_View_Properties;

   -----------------------------------
   -- Browse_Deployment_View_System --
   -----------------------------------

   procedure Browse_Deployment_View_System
       (My_System : Node_Id; NodeName : String) is
      Processes         : Node_Id;
      Processes2        : Node_Id;
      Tmp_CI            : Node_Id;
      Tmp_CI2           : Node_Id;
      Ref               : Node_Id;
      CPU               : Node_Id;
      CPU_Name          : Name_Id := No_Name;
      Pkg_Name          : Name_Id := No_Name;
      CPU_Classifier    : Name_Id := No_Name;
      CPU_Platform      : Supported_Execution_Platform := Platform_None;
      Conn              : Node_Id;
      Bound_Bus         : Node_Id;
      Src_Port          : Node_Id;
      Src_Name          : Unbounded_String;
      Dst_Name          : Unbounded_String;
      Dst_Port          : Node_Id;
      Bound_Bus_Name    : Name_Id;
      If1_Name          : Name_Id := No_Name;
      If2_Name          : Name_Id := No_Name;
   begin
      if not Is_Empty (Connections (My_System)) then
         Conn := First_Node (Connections (My_System));
         while Present (Conn) loop
            Bound_Bus := Get_Bound_Bus (Conn, False);
            if Bound_Bus /= No_Node then
               Bound_Bus_Name := Name
                  (Identifier (Parent_Subcomponent (Bound_Bus)));
               Src_Port := Get_Referenced_Entity (Source (Conn));
               Dst_Port := Get_Referenced_Entity (Destination (Conn));
               If1_Name := Get_Interface_Name (Src_Port);
               If2_Name := Get_Interface_Name (Dst_Port);
               --  Get_Interface_Name is v1.3.5+ only
               if If1_Name /= No_Name and If2_Name /= No_Name then
Maxime Perrotin's avatar
Maxime Perrotin committed
858 859
                  Src_Name := US (Get_Name_String (If1_Name));
                  Dst_Name := US (Get_Name_String (If2_Name));
Maxime Perrotin's avatar
Maxime Perrotin committed
860 861
               else
                  --  Keep compatibility with v1.2
Maxime Perrotin's avatar
Maxime Perrotin committed
862
                  Src_Name := US (Get_Name_String (Display_Name
Maxime Perrotin's avatar
Maxime Perrotin committed
863 864
                                                  (Identifier (Src_Port))));

Maxime Perrotin's avatar
Maxime Perrotin committed
865
                  Dst_Name := US (Get_Name_String (Display_Name
Maxime Perrotin's avatar
Maxime Perrotin committed
866 867 868
                                                  (Identifier (Dst_Port))));
               end if;
--             Put_Line (To_String (Src_Name) & " -> " & To_String (Dst_Name));
Maxime Perrotin's avatar
Maxime Perrotin committed
869
               C_New_Connection
Maxime Perrotin's avatar
Maxime Perrotin committed
870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892
                  (Get_Name_String
                     (Name (Identifier
                        (Parent_Subcomponent
                           (Parent_Component (Src_Port))))),
                   Get_Name_String
                     (Name (Identifier
                        (Parent_Subcomponent
                           (Parent_Component (Src_Port)))))'Length,
                   To_String (Src_Name),
                   To_String (Src_Name)'Length,
                   Get_Name_String (Bound_Bus_Name),
                   Get_Name_String (Bound_Bus_Name)'Length,
                   Get_Name_String
                      (Name (Identifier
                         (Parent_Subcomponent
                            (Parent_Component (Dst_Port))))),
                   Get_Name_String
                      (Name (Identifier
                         (Parent_Subcomponent
                         (Parent_Component (Dst_Port)))))'Length,
                   To_String (Dst_Name),
                   To_String (Dst_Name)'Length);

Maxime Perrotin's avatar
Maxime Perrotin committed
893
--               C_New_Connection
Maxime Perrotin's avatar
Maxime Perrotin committed
894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919
--                  (Get_Name_String
--                     (Name (Identifier
--                        (Parent_Subcomponent
--                           (Parent_Component (Src_Port))))),
--                   Get_Name_String
--                     (Name (Identifier
--                        (Parent_Subcomponent
--                           (Parent_Component (Src_Port)))))'Length,
--                   Get_Name_String
--                      (Display_Name (Identifier (Src_Port))),
--                   Get_Name_String
--                      (Display_Name (Identifier (Src_Port)))'Length,
--                   Get_Name_String (Bound_Bus_Name),
--                   Get_Name_String (Bound_Bus_Name)'Length,
--                   Get_Name_String
--                      (Name (Identifier
--                         (Parent_Subcomponent
--                            (Parent_Component (Dst_Port))))),
--                   Get_Name_String
--                      (Name (Identifier
--                         (Parent_Subcomponent
--                         (Parent_Component (Dst_Port)))))'Length,
--                   Get_Name_String
--                         (Display_Name (Identifier (Dst_Port))),
--                   Get_Name_String
--                         (Display_Name (Identifier (Dst_Port)))'Length);
Maxime Perrotin's avatar
Maxime Perrotin committed
920
               C_End_Connection;
Maxime Perrotin's avatar
Maxime Perrotin committed
921 922 923 924 925 926
            end if;
            Conn := Next_Node (Conn);
         end loop;
      end if;

      if not Is_Empty (Subcomponents (My_System)) then
Maxime Perrotin's avatar
Maxime Perrotin committed
927
         C_New_Drivers_Section;
Maxime Perrotin's avatar
Maxime Perrotin committed
928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036
         Processes := First_Node (Subcomponents (My_System));

         while Present (Processes) loop
            Tmp_CI := Corresponding_Instance (Processes);

            if Get_Category_Of_Component (Tmp_CI) = CC_Device then
               declare
                  Device_Classifier          : Name_Id   := No_Name;
                  Pkg_Name                   : Name_Id   := No_Name;
                  Associated_Processor_Name  : Name_Id   := No_Name;
                  Accessed_Bus               : Node_Id   := No_Node;
                  Accessed_Port              : Node_Id   := No_Node;
                  Accessed_Bus_Name          : Name_Id   := No_Name;
                  Accessed_Port_Name         : Name_Id   := No_Name;
                  Device_Configuration       : Name_Id   := No_Name;
                  Device_Configuration_Len   : Integer   := 0;
                  Device_ASN1_Filename       : Name_Id   := No_Name;
                  Device_ASN1_Filename_Len   : Integer   := 0;
                  Device_Implementation      : Node_Id   := No_Node;
                  Configuration_Data         : Node_Id   := No_Node;
                  Device_ASN1_Typename       : Name_Id   := No_Name;
                  Device_ASN1_Typename_Len   : Integer   := 0;
                  Device_ASN1_Module         : Name_Id   := No_Name;
                  Device_ASN1_Module_Len     : Integer   := 0;
               begin

                  Device_Implementation := Get_Implementation (Tmp_CI);
                  if Device_Implementation /= No_Node and then
                     Is_Defined_Property (Device_Implementation,
                                          "deployment::configuration_type")
                  then
                     Configuration_Data
                        := Get_Classifier_Property
                           (Device_Implementation,
                           "deployment::configuration_type");
                     if Configuration_Data /= No_Node and then
                        Is_Defined_Property
                           (Configuration_Data, "type_source_name")
                     then
                           Device_ASN1_Typename :=
                              (Get_String_Property
                                 (Configuration_Data, "type_source_name"));

                           Device_ASN1_Typename_Len :=
                              Get_Name_String (Device_ASN1_Typename)'Length;
                           declare
                              ST : constant Name_Array
                                 := Get_Source_Text (Configuration_Data);
                           begin
                              Exit_On_Error
                                 (ST'Length = 0,
                                  "Source_Text property of " &
                                  "configuration data" &
                                  " must have at least one element " &
                                  "(the header file).");

                              for Index in ST'Range loop
                                 Get_Name_String (ST (Index));
                                 if Name_Buffer (Name_Len - 3 .. Name_Len)
                                    = ".asn"
                                 then
                                    Device_ASN1_Filename := Get_String_Name
                                       (Name_Buffer (1 .. Name_Len));
                                    Device_ASN1_Filename_Len :=
                                       Get_Name_String
                                          (Device_ASN1_Filename)'Length;
                                 end if;
                              end loop;

                              Exit_On_Error
                                 (Device_ASN1_Filename = No_Name,
                                 "Cannot find ASN file " &
                                  "that implements the device " &
                                  "configuration type");
                           end;
                     end if;
                     if Configuration_Data /= No_Node and then
                        Is_Defined_Property
                           (Configuration_Data, "deployment::asn1_module_name")
                     then
                        Device_ASN1_Module :=
                         Get_String_Property
                      (Configuration_Data, "deployment::asn1_module_name");
                     else
                        Device_ASN1_Module := Get_String_Name ("nomod");
                     end if;

                     Device_ASN1_Module_Len :=
                       Get_Name_String (Device_ASN1_Module)'Length;

                  else
                     Exit_On_Error (true,
                             "[ERROR] Device configuration is incorrect (" &
                             Get_Name_String (Name (Identifier (Tmp_CI))) &
                             ")");
                  end if;

                  Set_Str_To_Name_Buffer ("");
                  if ATN.Namespace (Corresponding_Declaration
                                                           (Tmp_CI)) /= No_Node
                  then

                     Set_Str_To_Name_Buffer ("");
                     Get_Name_String
                     (ATN.Name
                      (ATN.Identifier
                       (ATN.Namespace
                        (Corresponding_Declaration (Tmp_CI)))));
                     Pkg_Name := Name_Find;
Maxime Perrotin's avatar
Maxime Perrotin committed
1037
                     C_Add_Package
Maxime Perrotin's avatar
Maxime Perrotin committed
1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074
                        (Get_Name_String (Pkg_Name),
                         Get_Name_String (Pkg_Name)'Length);
                     Set_Str_To_Name_Buffer ("");
                     Get_Name_String (Pkg_Name);
                     Add_Str_To_Name_Buffer ("::");
                     Get_Name_String_And_Append (Name (Identifier (Tmp_CI)));
                     Device_Classifier := Name_Find;
                  else
                     Device_Classifier := Name (Identifier (Tmp_CI));
                  end if;

                  if Get_Bound_Processor (Tmp_CI) /= No_Node then
                     Set_Str_To_Name_Buffer ("");
                     Associated_Processor_Name := Name
                        (Identifier
                           (Parent_Subcomponent
                              (Get_Bound_Processor (Tmp_CI))));
                  end if;

                  if Is_Defined_Property
                     (Tmp_CI, "deployment::configuration") and then
                     Get_String_Property
                        (Tmp_CI, "deployment::configuration") /= No_Name
                  then
                        Get_Name_String
                           (Get_String_Property
                              (Tmp_CI, "deployment::configuration"));
                     Device_Configuration := Name_Find;
                  else
                     Device_Configuration := Get_String_Name ("noconf");
                  end if;

                  Device_Configuration_Len := Get_Name_String
                    (Device_Configuration)'Length;

                  Find_Connected_Bus (Tmp_CI, Accessed_Bus, Accessed_Port);
                  if Accessed_Bus /= No_Node and then
1075 1076
                     Accessed_Port /= No_Node and then
                     Associated_Processor_Name /= No_Name
Maxime Perrotin's avatar
Maxime Perrotin committed
1077 1078 1079 1080
                  then
                     Accessed_Bus_Name := Name (Identifier (Accessed_Bus));
                     Accessed_Port_Name := Name (Identifier (Accessed_Port));

Maxime Perrotin's avatar
Maxime Perrotin committed
1081
                     C_New_Device
Maxime Perrotin's avatar
Maxime Perrotin committed
1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100
                        (Get_Name_String (Name (Identifier (Processes))),
                         Get_Name_String
                           (Name (Identifier (Processes)))'Length,
                         Get_Name_String (Device_Classifier),
                         Get_Name_String (Device_Classifier)'Length,
                         Get_Name_String (Associated_Processor_Name),
                         Get_Name_String (Associated_Processor_Name)'Length,
                         Get_Name_String (Device_Configuration),
                         Device_Configuration_Len,
                         Get_Name_String (Accessed_Bus_Name),
                         Get_Name_String (Accessed_Bus_Name)'Length,
                         Get_Name_String (Accessed_Port_Name),
                         Get_Name_String (Accessed_Port_Name)'Length,
                         Get_Name_String (Device_ASN1_Filename),
                         Device_ASN1_Filename_Len,
                         Get_Name_String (Device_ASN1_Typename),
                         Device_ASN1_Typename_Len,
                         Get_Name_String (Device_ASN1_Module),
                         Device_ASN1_Module_Len);
Maxime Perrotin's avatar
Maxime Perrotin committed
1101
                     C_End_Device;
1102 1103 1104 1105 1106 1107 1108
                  else
                     Exit_On_Error (True,
                     "[ERROR] In your deployment view, check the connection of"
                     & " this driver: "
                     & Get_Name_String (Name (Identifier (Processes)))
                     & " - in processor "
                     & Get_Name_String (Associated_Processor_Name));
Maxime Perrotin's avatar
Maxime Perrotin committed
1109 1110 1111 1112 1113
                  end if;
               end;
            end if;

            if Get_Category_Of_Component (Tmp_CI) = CC_Process then
Maxime Perrotin's avatar
Maxime Perrotin committed
1114 1115
               declare
                  Node_Coverage : Boolean := False;
1116 1117 1118
                  Env_Vars     : Name_Id := No_Name;
                  User_CFlags  : Name_Id := No_Name;
                  User_LdFlags : Name_Id := No_Name;
Maxime Perrotin's avatar
Maxime Perrotin committed
1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131
               begin
                  if Is_Defined_Property (Tmp_CI,
                                        "taste_dv_properties::coverageenabled")
                  then
                     Node_Coverage := Get_Boolean_Property
                        (Tmp_CI,
                     Get_String_Name ("taste_dv_properties::coverageenabled"));
                     if Node_Coverage then
                        Put_Line ("Needs Coverage");
                     else
                        Put_Line ("Needs No coverage");
                     end if;
                  end if;
Maxime Perrotin's avatar
Maxime Perrotin committed
1132

Maxime Perrotin's avatar
Maxime Perrotin committed
1133
                  CPU := Get_Bound_Processor (Tmp_CI);
1134 1135 1136
                  Env_Vars     := Get_Env_Vars     (CPU);
                  User_CFlags  := Get_User_CFlags  (CPU);
                  User_LdFlags := Get_User_LdFlags (CPU);
Maxime Perrotin's avatar
Maxime Perrotin committed
1137
                  Set_Str_To_Name_Buffer ("");
Maxime Perrotin's avatar
Maxime Perrotin committed
1138
                  CPU_Name := Name (Identifier (Parent_Subcomponent (CPU)));
Maxime Perrotin's avatar
Maxime Perrotin committed
1139

Maxime Perrotin's avatar
Maxime Perrotin committed
1140
                  CPU_Platform := Get_Execution_Platform (CPU);
Maxime Perrotin's avatar
Maxime Perrotin committed
1141

Maxime Perrotin's avatar
Maxime Perrotin committed
1142
                  if ATN.Namespace (Corresponding_Declaration (CPU)) /= No_Node
Maxime Perrotin's avatar
Maxime Perrotin committed
1143 1144 1145 1146 1147 1148 1149 1150
                  then
                     Set_Str_To_Name_Buffer ("");
                     Get_Name_String
                        (ATN.Name
                           (ATN.Identifier
                              (ATN.Namespace
                                 (Corresponding_Declaration (CPU)))));
                     Pkg_Name := Name_Find;
Maxime Perrotin's avatar
Maxime Perrotin committed
1151
                     C_Add_Package
Maxime Perrotin's avatar
Maxime Perrotin committed
1152 1153 1154 1155 1156 1157 1158 1159 1160 1161
                        (Get_Name_String (Pkg_Name),
                        Get_Name_String (Pkg_Name)'Length);
                     Set_Str_To_Name_Buffer ("");
                     Get_Name_String (Pkg_Name);
                     Add_Str_To_Name_Buffer ("::");
                     Get_Name_String_And_Append (Name (Identifier (CPU)));
                     CPU_Classifier := Name_Find;
                  else
                     CPU_Classifier := Name (Identifier (CPU));
                  end if;
Maxime Perrotin's avatar
Maxime Perrotin committed
1162

Maxime Perrotin's avatar
Maxime Perrotin committed
1163
                  C_New_Processor
Maxime Perrotin's avatar
Maxime Perrotin committed
1164 1165 1166 1167 1168
                     (Get_Name_String (CPU_Name),
                     Get_Name_String (CPU_Name)'Length,
                     Get_Name_String (CPU_Classifier),
                     Get_Name_String (CPU_Classifier)'Length,
                     Supported_Execution_Platform'Image (CPU_Platform),
1169 1170
                     Supported_Execution_Platform'Image (CPU_Platform)'Length,
                     (if Env_Vars /= No_Name then
1171
                          Get_Name_String (Env_Vars)
1172 1173
                      else ""),
                     (if Env_Vars /= No_Name then
1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186
                        Get_Name_String (Env_Vars)'Length
                      else 0),
                     (if User_CFlags /= No_Name then
                         Get_Name_String (User_CFlags)
                      else ""),
                     (if User_CFlags /= No_Name then
                         Get_Name_String (User_CFlags)'Length
                      else 0),
                     (if User_LdFlags /= No_Name then
                          Get_Name_String (User_LdFlags)
                      else ""),
                     (if User_LdFlags /= No_Name then
                        Get_Name_String (User_LdFlags)'Length
1187
                      else 0));
Maxime Perrotin's avatar
Maxime Perrotin committed
1188

Maxime Perrotin's avatar
Maxime Perrotin committed
1189
                  C_New_Process
Maxime Perrotin's avatar
Maxime Perrotin committed
1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214
                     (Get_Name_String
                        (ATN.Name
                           (ATN.Component_Type_Identifier
                              (Corresponding_Declaration (Tmp_CI)))),
                      Get_Name_String
                        (ATN.Name
                           (ATN.Component_Type_Identifier
                              (Corresponding_Declaration (Tmp_CI))))'Length,
                     Get_Name_String (Name (Identifier (Processes))),
                     Get_Name_String (Name (Identifier (Processes)))'Length,
                     NodeName, NodeName'Length,
                     Boolean'Pos (Node_Coverage));

                  Processes2 := First_Node (Subcomponents (My_System));

                  while Present (Processes2) loop
                     Tmp_CI2 := Corresponding_Instance (Processes2);

                     if Get_Category_Of_Component (Tmp_CI2) = CC_System
                        and then
                        Is_Defined_Property
                           (Tmp_CI2, "taste::aplc_binding")
                     then
                        Ref := Get_Reference_Property
                           (Tmp_CI2, Get_String_Name ("taste::aplc_binding"));
Maxime Perrotin's avatar
Maxime Perrotin committed
1215

Maxime Perrotin's avatar
Maxime Perrotin committed
1216 1217 1218
                        if Ref = Tmp_CI then
                           declare
                              Bound_APLC_Name : Unbounded_String;
Maxime Perrotin's avatar
Maxime Perrotin committed
1219
                           begin
Maxime Perrotin's avatar
Maxime Perrotin committed
1220
                              begin
Maxime Perrotin's avatar
Maxime Perrotin committed
1221
                                 Bound_APLC_Name := US
Maxime Perrotin's avatar
Maxime Perrotin committed
1222
                                   (Get_Name_String
Maxime Perrotin's avatar
Maxime Perrotin committed
1223 1224 1225 1226 1227 1228 1229
                                     (ATN.Name
                                       (ATN.Component_Type_Identifier
                                     (Corresponding_Declaration (Tmp_CI2)))));
                              exception
                                 when System.Assertions.Assert_Failure =>
                                    Put_Line
                                       ("Detected DV from TASTE version 1.2");
Maxime Perrotin's avatar
Maxime Perrotin committed
1230
                                    Bound_APLC_Name := US
Maxime Perrotin's avatar
Maxime Perrotin committed
1231 1232 1233
                                      (Get_Name_String
                                         (Name (Identifier (Processes2))));
                              end;
Maxime Perrotin's avatar
Maxime Perrotin committed
1234

Maxime Perrotin's avatar
Maxime Perrotin committed
1235
                              C_Add_Binding
Maxime Perrotin's avatar
Maxime Perrotin committed
1236 1237 1238 1239
                                 (To_String (Bound_APLC_Name),
                                  To_String (Bound_APLC_Name)'Length);
                           end;
                        end if;
Maxime Perrotin's avatar
Maxime Perrotin committed
1240 1241
                     end if;

Maxime Perrotin's avatar
Maxime Perrotin committed
1242 1243
                     Processes2 := Next_Node (Processes2);
                  end loop;
Maxime Perrotin's avatar
Maxime Perrotin committed
1244

Maxime Perrotin's avatar
Maxime Perrotin committed
1245
                  C_End_Process;
Maxime Perrotin's avatar
Maxime Perrotin committed
1246
               end;
Maxime Perrotin's avatar
Maxime Perrotin committed
1247 1248 1249 1250
            end if;

            Processes := Next_Node (Processes);
         end loop;
Maxime Perrotin's avatar
Maxime Perrotin committed
1251
         C_End_Drivers_Section;
Maxime Perrotin's avatar
Maxime Perrotin committed
1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266
      end if;
   end Browse_Deployment_View_System;

   ------------------------
   -- Parse_Command_Line --
   ------------------------

   procedure Parse_Command_Line is
      FN                : Name_Id;
      B                 : Location;
      Previous_OutDir   : Boolean := False;
      Previous_IFview   : Boolean := False;
      Previous_CView    : Boolean := False;
      Previous_DataView : Boolean := False;
      Previous_Stack    : Boolean := False;
1267
      Previous_TimerRes : Boolean := False;
Maxime Perrotin's avatar
Maxime Perrotin committed
1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292
   begin
      for J in 1 .. Ada.Command_Line.Argument_Count loop
         --  Parse the file corresponding to the Jth argument of the
         --  command line and enrich the global AADL tree.

         if Previous_IfView then
            Interface_View := J;
            Previous_Ifview := false;

         elsif Previous_Cview then
            Concurrency_view := J;
            Previous_Cview := false;

         elsif Previous_DataView then
            Data_View := J;
            Previous_DataView := false;

         elsif Previous_Outdir then
            OutDir := J;
            Previous_OutDir := false;

         elsif Previous_Stack then
            Stack_Val := J;
            Previous_Stack := false;

1293 1294 1295 1296
         elsif Previous_TimerRes then
            Timer_Resolution := J;
            Previous_TimerRes := false;

Maxime Perrotin's avatar
Maxime Perrotin committed
1297 1298 1299 1300
         elsif Ada.Command_Line.Argument (J) = "--polyorb-hi-c"
           or else Ada.Command_Line.Argument (J) = "-p"
           or else Ada.Command_Line.Argument (J) = "-polyorb-hi-c"
         then
Maxime Perrotin's avatar
Maxime Perrotin committed
1301
            C_Set_PolyORBHI_C;
Maxime Perrotin's avatar
Maxime Perrotin committed
1302 1303 1304 1305 1306 1307

         elsif Ada.Command_Line.Argument (J) = "--keep-case"
           or else Ada.Command_Line.Argument (J) = "-j"
           or else Ada.Command_Line.Argument (J) = "-keep-case"
         then
            Keep_case := true;
Maxime Perrotin's avatar
Maxime Perrotin committed
1308
            C_Keep_case;
Maxime Perrotin's avatar
Maxime Perrotin committed
1309 1310 1311 1312 1313 1314 1315 1316 1317 1318

         elsif Ada.Command_Line.Argument (J) = "--glue"
           or else Ada.Command_Line.Argument (J) = "-glue"
           or else Ada.Command_Line.Argument (J) = "-l"
         then
            generate_glue := true;

         elsif Ada.Command_Line.Argument (J) = "--smp2"
           or else Ada.Command_Line.Argument (J) = "-m"
         then
Maxime Perrotin's avatar
Maxime Perrotin committed
1319
            C_Set_SMP2;
Maxime Perrotin's avatar
Maxime Perrotin committed
1320 1321 1322 1323 1324

         elsif Ada.Command_Line.Argument (J) = "--gw"
           or else Ada.Command_Line.Argument (J) = "-gw"
           or else Ada.Command_Line.Argument (J) = "-w"
         then
Maxime Perrotin's avatar
Maxime Perrotin committed
1325
            C_Set_Gateway;
Maxime Perrotin's avatar
Maxime Perrotin committed
1326 1327 1328 1329 1330 1331 1332 1333

         --  The "test" flag activates a function in buildsupport,
         --  used for debugging purposes (e.g. dump of the model after
         --  all preprocessings). Users need not use it.
         elsif Ada.Command_Line.Argument (J) = "--test"
           or else Ada.Command_Line.Argument (J) = "-test"
           or else Ada.Command_Line.Argument (J) = "-t"
         then
Maxime Perrotin's avatar
Maxime Perrotin committed
1334
            C_Set_Test;
Maxime Perrotin's avatar
Maxime Perrotin committed
1335 1336 1337 1338 1339 1340 1341 1342

         elsif Ada.Command_Line.Argument (J) = "--aadlv2"
           or else Ada.Command_Line.Argument (J) = "-aadlv2"
           or else Ada.Command_Line.Argument (J) = "-a"
         then
            AADL_Version := Ocarina.AADL_V2;

         elsif Ada.Command_Line.Argument (J) = "--future" then
Maxime Perrotin's avatar
Maxime Perrotin committed
1343
            C_Set_Future;
Maxime Perrotin's avatar
Maxime Perrotin committed
1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360

         elsif Ada.Command_Line.Argument (J) = "--output"
           or else Ada.Command_Line.Argument (J) = "-o"
         then
            Previous_OutDir := True;

         elsif Ada.Command_Line.Argument (J) = "--interfaceview"
           or else Ada.Command_Line.Argument (J) = "-i"
         then
            Previous_Ifview := True;

         elsif Ada.Command_Line.Argument (J) = "--stack"
           or else Ada.Command_Line.Argument (J) = "-stack"
           or else Ada.Command_Line.Argument (J) = "-s"
         then
            Previous_Stack := True;

1361 1362 1363 1364 1365 1366
         elsif Ada.Command_Line.Argument (J) = "--timer"
           or else Ada.Command_Line.Argument (J) = "-timer"
           or else Ada.Command_Line.Argument (J) = "-x"
         then
            Previous_TimerRes := True;

Maxime Perrotin's avatar
Maxime Perrotin committed
1367 1368 1369 1370 1371 1372 1373 1374
         elsif Ada.Command_Line.Argument (J) = "--deploymentview"
           or else Ada.Command_Line.Argument (J) = "-c"
         then
            Previous_Cview := True;

         elsif Ada.Command_Line.Argument (J) = "--version"
           or else Ada.Command_Line.Argument (J) = "-v"
         then
Maxime Perrotin's avatar
Maxime Perrotin committed
1375
            OS_Exit (0);
Maxime Perrotin's avatar
Maxime Perrotin committed
1376 1377 1378 1379 1380 1381 1382 1383 1384

         elsif Ada.Command_Line.Argument (J) = "--dataview"
           or else Ada.Command_Line.Argument (J) = "-d"
         then
            Previous_DataView := True;

         elsif Ada.Command_Line.Argument (J) = "--debug"
           or else Ada.Command_Line.Argument (J) = "-g"
         then
Maxime Perrotin's avatar
Maxime Perrotin committed
1385
            C_Set_Debug_Messages;
Maxime Perrotin's avatar
Maxime Perrotin committed
1386

Maxime Perrotin's avatar
Maxime Perrotin committed
1387 1388 1389 1390
         elsif Ada.Command_Line.Argument (J) = "--help"
           or else Ada.Command_Line.Argument (J) = "-h"
         then
            Usage;
Maxime Perrotin's avatar
Maxime Perrotin committed
1391
            OS_Exit (0);
Maxime Perrotin's avatar
Maxime Perrotin committed
1392

Maxime Perrotin's avatar
Maxime Perrotin committed
1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442
         else
            Set_Str_To_Name_Buffer (Ada.Command_Line.Argument (J));
            FN := Ocarina.Files.Search_File (Name_Find);
            Exit_On_Error (FN = No_Name, "File not found: "
                          & Ada.Command_Line.Argument (J));
            B := Ocarina.Files.Load_File (FN);
            Interface_Root := Ocarina.Parser.Parse
              (AADL_Language, Interface_Root, B);

            --  the "else" makes the parser parse any additional aadl files
            --  (in complement to the interface/deployment/data views)
            --  they must therefore be part of Root AND Deployment_Root trees
            Set_Str_To_Name_Buffer (Ada.Command_Line.Argument (J));
            FN := Ocarina.Files.Search_File (Name_Find);
            B := Ocarina.Files.Load_File (FN);
            Deployment_Root := Ocarina.Parser.Parse
              (AADL_Language, Deployment_Root, B);
         end if;
      end loop;
   end Parse_Command_Line;

   ----------------
   -- Initialize --
   ----------------

   procedure Initialize is
      FN : Name_Id;
      B  : Location;
   begin
      --  Initialization step: we look for ocarina on path to define
      --  OCARINA_PATH env. variable. This will indicate Ocarina librrary
      --  where to find AADL default property sets, and Ocarina specific
      --  packages and property sets.

      declare
         S : constant GNAT.OS_Lib.String_Access
           := GNAT.OS_Lib.Locate_Exec_On_Path ("ocarina");
      begin
         Exit_On_Error (S = null,
            "[ERROR] ocarina is not in your PATH");
         GNAT.OS_Lib.Setenv ("OCARINA_PATH", S.all (S'First .. S'Last - 12));
      end;

      --  Display the command line syntax

      if Ada.Command_Line.Argument_Count = 0 then
         Usage;
         OS_Exit (1);
      end if;

Maxime Perrotin's avatar
Maxime Perrotin committed
1443
      C_Init;
Maxime Perrotin's avatar
Maxime Perrotin committed
1444 1445 1446 1447
      Ocarina.Initialize;
      Ocarina.AADL_Version := AADL_Version;

      Ocarina.Configuration.Init_Modules;
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
1448
--      Ocarina.FE_AADL.Parser.First_Parsing := True;
Maxime Perrotin's avatar
Maxime Perrotin committed
1449 1450 1451 1452 1453
      Ocarina.FE_AADL.Parser.Add_Pre_Prop_Sets := True;
      AADL_Language := Get_String_Name ("aadl");

      Parse_Command_Line;

Maxime Perrotin's avatar
Maxime Perrotin committed
1454
      C_Set_AADLV2;
Maxime Perrotin's avatar
Maxime Perrotin committed
1455 1456 1457 1458 1459 1460

      Exit_On_Error (Interface_View = 0, "Error: Missing Interface view!");
      Set_Str_To_Name_Buffer (Ada.Command_Line.Argument (Interface_View));
      FN := Ocarina.Files.Search_File (Name_Find);
      Exit_On_Error (FN = No_Name, "Error: Missing Interface view!");
      B := Ocarina.Files.Load_File (FN);
Maxime Perrotin's avatar
Maxime Perrotin committed
1461
      C_Set_Interfaceview
Maxime Perrotin's avatar
Maxime Perrotin committed
1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495
       (Ada.Command_Line.Argument (Interface_View),
        Ada.Command_Line.Argument (Interface_View)'Length);
      Interface_Root := Ocarina.Parser.Parse
        (AADL_Language, Interface_Root, B);

      if Concurrency_view = 0 and Generate_Glue then
         Put_Line ("Fatal error: Missing Deployment view!");
         Put_Line ("Use the '-c file.aadl' parameter.");
         Put_Line
            ("Note: the generation of glue code is invoked automatically");
         Put_Line
            ("from the TASTE orchestrator. You should run buildsupport");
         Put_Line
            ("only to generate your application skeletons ('-gw' flag).");
         New_line;

      elsif Concurrency_View > 0 and Generate_Glue then
         Set_Str_To_Name_Buffer (Ada.Command_Line.Argument (Concurrency_View));
         FN := Ocarina.Files.Search_File (Name_Find);
         B := Ocarina.Files.Load_File (FN);
         Deployment_Root := Ocarina.Parser.Parse
           (AADL_Language, Deployment_Root, B);
         Exit_On_Error (Deployment_Root = No_Node,
              "[ERROR] Deployment view is incorrect");
      end if;

      --  Missing data view is actually not an error.
      --  Systems can live with parameterless messages
      --  Exit_On_Error (Data_view = 0, "Error: Missing Data view!");
      if Data_View > 0 then
         Set_Str_To_Name_Buffer (Ada.Command_Line.Argument (Data_View));
         FN := Ocarina.Files.Search_File (Name_Find);

         Exit_On_Error (FN = No_Name, "Cannot find Data View");
Maxime Perrotin's avatar
Maxime Perrotin committed
1496
         C_Set_Dataview
Maxime Perrotin's avatar
Maxime Perrotin committed
1497 1498 1499 1500 1501 1502 1503 1504 1505
            (Ada.Command_Line.Argument (Data_View),
            Ada.Command_Line.Argument (Data_View)'Length);
         B := Ocarina.Files.Load_File (FN);
         Interface_Root := Ocarina.Parser.Parse
           (AADL_Language, Interface_Root, B);
         if Deployment_Root /= No_Node then
            Deployment_Root := Ocarina.Parser.Parse
               (AADL_Language, Deployment_Root, B);
         end if;
1506 1507
         Dataview_root := Ocarina.Parser.Parse
                            (AADL_Language, Dataview_root, B);
Maxime Perrotin's avatar
Maxime Perrotin committed
1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518
      end if;

      Exit_On_Error (No (Interface_Root), "Internal error");

      --  Analyze the tree

      Success := Ocarina.Analyzer.Analyze (AADL_Language, Interface_Root);
      Exit_On_Error (not Success, "Internal Error, cannot analyze model.");

   end Initialize;

Maxime Perrotin's avatar
Maxime Perrotin committed
1519
   IV_Root : Node_Id;
1520
   AST : Complete_Interface_View;
TASTE User's avatar
TASTE User committed
1521
   pragma Unreferenced (AST);
Maxime Perrotin's avatar
Maxime Perrotin committed
1522

Maxime Perrotin's avatar
Maxime Perrotin committed
1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536
begin
   Banner;

   Initialize;

   --  First, we analyze the interface view. For that, we load the
   --  AADL model, analyze it. Under AADLv2 version, the root system
   --  of the interface view is called interfaceview.others.

   --  Instantiate AADL tree

   Ocarina.Options.Root_System_Name :=
          Get_String_Name ("interfaceview.others");

Maxime Perrotin's avatar
Maxime Perrotin committed
1537
   IV_Root := Root_System (Instantiate_Model (Root => Interface_Root));
TASTE User's avatar
TASTE User committed
1538 1539 1540 1541 1542
   --  AST := AADL_to_Ada_IV (IV_Root);
   --  for each of AST.Flat_Functions loop
   --     Put_Line ("AST: " & To_String (Each.Prefix.Value_Or (US ("")))
   --                 & " " & To_String (Each.Name));
   --  end loop;
1543

Maxime Perrotin's avatar
Maxime Perrotin committed
1544 1545
   Process_Interface_View (IV_Root);
--      (Root_System (Instantiate_Model (Root => Interface_Root)));
Maxime Perrotin's avatar
Maxime Perrotin committed
1546 1547 1548 1549 1550 1551 1552 1553 1554 1555

   --  Now, we are done with the interface view. We now analyze the
   --  deployment view.

   --  Additional properties for the Deployment view

   Load_Deployment_View_Properties (Deployment_Root);

   Process_Deployment_View (Deployment_Root);

Maxime Perrotin's avatar
Maxime Perrotin committed
1556
   C_End;
Maxime Perrotin's avatar
Maxime Perrotin committed
1557 1558 1559 1560 1561 1562
   Ocarina.Configuration.Reset_Modules;
   Ocarina.Reset;
exception
   when E : others =>
      Errors.Display_Bug_Box (E);
end BuildSupport;