ocarina-instances-processor-properties.adb 30.7 KB
Newer Older
1
2
3
4
5
6
7
8
------------------------------------------------------------------------------
--                                                                          --
--                           OCARINA COMPONENTS                             --
--                                                                          --
--                 OCARINA.INSTANCES.PROCESSOR.PROPERTIES                   --
--                                                                          --
--                                 B o d y                                  --
--                                                                          --
9
--    Copyright (C) 2005-2009 Telecom ParisTech, 2010-2016 ESA & ISAE.      --
10
--                                                                          --
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
-- 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
44
45
46
47
48
49
50
51
52
53
54
55
56
--                                                                          --
------------------------------------------------------------------------------

with Ocarina.AADL_Values;
with Ocarina.Instances.Finder;

with Ocarina.ME_AADL.AADL_Tree.Nodes;
with Ocarina.ME_AADL.AADL_Tree.Nutils;
with Ocarina.ME_AADL.AADL_Tree.Entities;
with Ocarina.ME_AADL.AADL_Instances.Nodes;

package body Ocarina.Instances.Processor.Properties is

   use Ocarina.AADL_Values;
   use Ocarina.Instances.Finder;

   use Ocarina.ME_AADL.AADL_Tree.Nodes;
   use Ocarina.ME_AADL.AADL_Instances.Nodes;
   use Ocarina.ME_AADL.AADL_Tree.Entities;

   package ATN renames Ocarina.ME_AADL.AADL_Tree.Nodes;
   package AIN renames Ocarina.ME_AADL.AADL_Instances.Nodes;
   package ATNU renames Ocarina.ME_AADL.AADL_Tree.Nutils;
   package ATE renames Ocarina.ME_AADL.AADL_Tree.Entities;

   function Evaluate_Property_Value
     (Instance_Root  : Node_Id;
      Container      : Node_Id;
57
      Property_Value : Node_Id) return Node_Id;
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
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
   --  Compute the value by fetching the property terms and applying
   --  the operations described in the property value. Return the
   --  first evaluated value (the following ones are chainded using
   --  Next_Node), or No_Node if nothing could be evaluated.

   procedure Expand_Property_Value
     (Instance_Root :     Node_Id;
      Container     :     Node_Id;
      Property      :     Node_Id;
      Result_Node   : out Node_Id;
      Result_List   : out List_Id);
   --  Expand the property terms of the property, and return all the
   --  property values. If the property is a list property then the
   --  result will be returned in Result_List and Result_Node will be
   --  set to No_Node. Otherwise, the result will be returned in
   --  Result_Node and Result_List will be set to No_List.

   procedure Resolve_Values
     (Root      : Node_Id;
      Container : Node_Id;
      Property  : Node_Id);
   --  Set a direct value (i.e. without value ()) for each value of
   --  the property association.

   procedure Resolve_Property_Associations
     (Properties : List_Id;
      Root       : Node_Id;
      Container  : Node_Id);

   procedure Resolve_Properties_Of_Component_Instance
     (Root      : Node_Id;
      Component : Node_Id);

   procedure Resolve_Properties_Of_Namespace_Instance
     (Root          : Node_Id;
      The_Namespace : Node_Id);

   --------------------------------------
   -- Compute_Property_Instance_Values --
   --------------------------------------

   procedure Compute_Property_Instance_Values (Root : Node_Id) is
      pragma Assert (Kind (Root) = K_Architecture_Instance);

      List_Node : Node_Id;
   begin
      Resolve_Properties_Of_Component_Instance
        (Root      => Root,
         Component => Root_System (Root));

      if Namespaces (Root) /= No_List then
         List_Node := AIN.First_Node (AIN.Namespaces (Root));

         while Present (List_Node) loop
            Resolve_Properties_Of_Namespace_Instance
              (Root          => Root,
               The_Namespace => List_Node);
            List_Node := AIN.Next_Node (List_Node);
         end loop;
      end if;
   end Compute_Property_Instance_Values;

   --------------------
   -- Resolve_Values --
   --------------------

   procedure Resolve_Values
     (Root      : Node_Id;
      Container : Node_Id;
      Property  : Node_Id)
   is
      pragma Assert (Kind (Root) = K_Architecture_Instance);
      pragma Assert (AIN.Kind (Property) = K_Property_Association_Instance);
      pragma Assert (Present (Container));

133
134
      Prop_Value : constant Node_Id :=
        AIN.Property_Association_Value (Property);
135
136
137
138
139
140
141
142
143
144
145
      Expanded_Node : Node_Id;
      Expanded_List : List_Id;
   begin
      Expand_Property_Value
        (Root,
         Container,
         Property,
         Expanded_Node,
         Expanded_List);

      Set_Expanded_Single_Value (Prop_Value, Expanded_Node);
146
      Set_Expanded_Multi_Value (Prop_Value, Expanded_List);
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
   end Resolve_Values;

   ---------------------------
   -- Expand_Property_Value --
   ---------------------------

   procedure Expand_Property_Value
     (Instance_Root :     Node_Id;
      Container     :     Node_Id;
      Property      :     Node_Id;
      Result_Node   : out Node_Id;
      Result_List   : out List_Id)
   is
      pragma Assert (Kind (Instance_Root) = K_Architecture_Instance);
      pragma Assert (Present (Container));
      pragma Assert
        (No (Property)
         or else AIN.Kind (Property) = K_Property_Association_Instance
         or else ATN.Kind (Property) = K_Constant_Property_Declaration
         or else ATN.Kind (Property) = K_Property_Definition_Declaration);

      Value                : Node_Id;
      List_Node            : Node_Id;
      Computed_Value       : Node_Id;
      Evaluation_Container : Node_Id;
   begin
      Result_Node := No_Node;
      Result_List := No_List;

      if No (Property) then
         return;
      end if;

      --  First get the value of the property. For property
      --  associations, the evaluation context is the entity in which
      --  it has been declared.

      case AIN.Kind (Property) is
         when K_Property_Association_Instance =>
186
187
188
            Value                := AIN.Property_Association_Value (Property);
            Evaluation_Container :=
              Value_Container (AIN.Property_Association_Value (Property));
189
190
191
192
193
194
195
196
197
198
199
200
         --  when K_Constant_Property_Declaration =>
         --   Value := Constant_Value (Property);
         --   Evaluation_Container := Container;
         --  when K_Property_Definition_Declaration =>
         --   Value := Default_Value (Property);
         --   Evaluation_Container := Container;
         when others =>
            raise Program_Error;
      end case;

      if Present (Value) then
         if Present (Single_Value (Value)) then
201
202
203
204
205
            Result_Node :=
              Evaluate_Property_Value
                (Instance_Root  => Instance_Root,
                 Container      => Evaluation_Container,
                 Property_Value => Single_Value (Value));
206
207
208
209
         end if;

         if not ATNU.Is_Empty (Multi_Value (Value)) then
            Result_List := ATNU.New_List (K_List_Id, ATN.Loc (Value));
210
            List_Node   := ATN.First_Node (Multi_Value (Value));
211
212

            while Present (List_Node) loop
213
214
215
216
217
               Computed_Value :=
                 Evaluate_Property_Value
                   (Instance_Root  => Instance_Root,
                    Container      => Evaluation_Container,
                    Property_Value => List_Node);
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239

               if Present (Computed_Value) then
                  --  The computed value may be No_Node if nothing is
                  --  pointed to. Then we simply ignore it. Else we
                  --  append the computed values.

                  ATNU.Append_Node_To_List (Computed_Value, Result_List);
               end if;

               List_Node := ATN.Next_Node (List_Node);
            end loop;
         end if;
      end if;
   end Expand_Property_Value;

   -----------------------------
   -- Evaluate_Property_Value --
   -----------------------------

   function Evaluate_Property_Value
     (Instance_Root  : Node_Id;
      Container      : Node_Id;
240
      Property_Value : Node_Id) return Node_Id
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
   is
      use Ocarina.ME_AADL.AADL_Tree.Nutils;

      package ATNU renames Ocarina.ME_AADL.AADL_Tree.Nutils;

      pragma Assert
        (No (Property_Value)
         or else Kind (Property_Value) = K_Literal
         or else Kind (Property_Value) = K_Property_Term
         or else Kind (Property_Value) = K_Enumeration_Term
         or else Kind (Property_Value) = K_Number_Range_Term
         or else Kind (Property_Value) = K_Reference_Term
         or else Kind (Property_Value) = K_Property_Term
         or else Kind (Property_Value) = K_Minus_Numeric_Term
         or else Kind (Property_Value) = K_Signed_AADLNumber
         or else Kind (Property_Value) = K_Not_Boolean_Term
         or else Kind (Property_Value) = K_And_Boolean_Term
         or else Kind (Property_Value) = K_Or_Boolean_Term
         or else Kind (Property_Value) = K_Parenthesis_Boolean_Term
260
261
         or else Kind (Property_Value) = K_Component_Classifier_Term
         or else Kind (Property_Value) = K_Record_Term);
262
263
264
265
266
267
268
269
270
271
272
273
274

      Evaluated_Value : Node_Id;
      Node            : Node_Id;
      Dummy           : List_Id;
      pragma Warnings (Off, Dummy); --  Not read in realease mode
   begin
      if No (Property_Value) then
         Evaluated_Value := No_Node;
      else
         case ATN.Kind (Property_Value) is
            when K_Literal =>
               --  We clone the literal value

275
276
277
278
279
280
281
               Evaluated_Value :=
                 ATNU.New_Node
                   (Kind (Property_Value),
                    ATN.Loc (Property_Value));
               Set_Value
                 (Evaluated_Value,
                  New_Value (Value (Value (Property_Value))));
282

283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
            when K_Enumeration_Term =>
               --  We clone the enumeration literal

               Evaluated_Value := ATNU.New_Node
                 (Kind (Property_Value),
                  ATN.Loc (Property_Value));

               ATN.Set_Identifier
                 (Evaluated_Value,
                  ATN.Identifier (Property_Value));
               ATN.Set_Entity
                 (Evaluated_Value,
                  ATN.Entity (Property_Value));
               ATN.Set_Property_Set_Identifier
                 (Evaluated_Value,
                  ATN.Property_Set_Identifier (Property_Value));

300
301
302
303
304
305
306
307
            when K_Number_Range_Term =>
               declare
                  Evaluated_Lower_Bound : Node_Id;
                  Evaluated_Upper_Bound : Node_Id;
                  Evaluated_Delta_Term  : Node_Id;
               begin
                  Evaluated_Lower_Bound :=
                    Evaluate_Property_Value
308
309
310
                      (Instance_Root  => Instance_Root,
                       Container      => Container,
                       Property_Value => Lower_Bound (Property_Value));
311
312
                  Evaluated_Upper_Bound :=
                    Evaluate_Property_Value
313
314
315
                      (Instance_Root  => Instance_Root,
                       Container      => Container,
                       Property_Value => Upper_Bound (Property_Value));
316
317
                  Evaluated_Delta_Term :=
                    Evaluate_Property_Value
318
319
320
                      (Instance_Root  => Instance_Root,
                       Container      => Container,
                       Property_Value => Delta_Term (Property_Value));
321
322
323
324
325
326
327
328

                  if Present (Evaluated_Lower_Bound)
                    and then Kind (Evaluated_Lower_Bound) = K_Literal
                    and then Present (Evaluated_Upper_Bound)
                    and then Kind (Evaluated_Upper_Bound) = K_Literal
                    and then Present (Evaluated_Delta_Term)
                    and then Kind (Evaluated_Delta_Term) = K_Literal
                  then
329
330
331
332
333
334
335
336
                     Evaluated_Value :=
                       ATNU.New_Node
                         (Kind (Property_Value),
                          ATN.Loc (Property_Value));

                     Set_Lower_Bound (Evaluated_Value, Evaluated_Lower_Bound);
                     Set_Upper_Bound (Evaluated_Value, Evaluated_Upper_Bound);
                     Set_Delta_Term (Evaluated_Value, Evaluated_Delta_Term);
337
338
339
340
341
342
                  else
                     Evaluated_Value := No_Node;
                  end if;
               end;

            when K_Reference_Term =>
343
344
345
346
347
348
349
350
               Evaluated_Value :=
                 ATNU.New_Node
                   (Kind (Property_Value),
                    ATN.Loc (Property_Value));
               Node :=
                 ATNU.New_Node
                   (Kind (Reference_Term (Property_Value)),
                    ATN.Loc (Reference_Term (Property_Value)));
351
352
353
354
355

               case AADL_Version is
                  when AADL_V1 =>
                     ATN.Set_Identifier
                       (Node,
356
357
358
359
360
361
362
363
364
                     --  XXX TODO here duplicate Identifier
                        ATN.Identifier (Reference_Term (Property_Value)));

                     ATN.Set_Path
                       (Node,
                        ATN.Path (Reference_Term (Property_Value)));
                     Set_Namespace_Path
                       (Node,
                        Namespace_Path (Reference_Term (Property_Value)));
365
366
367
368
369
370
371
372
373
374
                     Set_Namespace_Identifier
                       (Node,
                        ATE.Duplicate_Identifier
                          (Namespace_Identifier
                             (Reference_Term (Property_Value))));
                     Set_Referenced_Entity
                       (Node,
                        Find_Instance
                          (Instance_Root      => Instance_Root,
                           Reference_Instance => Container,
375
376
                           Path               =>
                             ATN.Path (Reference_Term (Property_Value))));
377
378

                  when AADL_V2 =>
379
380
381
382
383
384
                     Set_List_Items
                       (Node,
                        List_Items (Reference_Term (Property_Value)));
                     Set_Annex_Path
                       (Node,
                        Annex_Path (Reference_Term (Property_Value)));
385
386
387
388
389
                     Set_Referenced_Entity
                       (Node,
                        Find_Instance
                          (Instance_Root      => Instance_Root,
                           Reference_Instance => Container,
390
391
                           Path               =>
                             List_Items (Reference_Term (Property_Value))));
392
393
394
395
               end case;

               Set_Reference_Term (Evaluated_Value, Node);

396
            --  XXX Todo here evaluate Contained_Element_Path
397

398
            when K_Property_Term =>
399
400
401
402
403
404
405
406
407
408
409
410
411
412
               Expand_Property_Value
                 (Instance_Root => Instance_Root,
                  Container     => Container,
                  Property      => ATE.Get_Referenced_Entity (Property_Value),
                  Result_Node   => Evaluated_Value,
                  Result_List   => Dummy);

               pragma Assert (Dummy = No_List);

            when K_Minus_Numeric_Term =>
               declare
                  Val     : Value_Type;
                  Literal : Node_Id;
               begin
413
414
415
416
417
                  Evaluated_Value :=
                    Evaluate_Property_Value
                      (Instance_Root  => Instance_Root,
                       Container      => Container,
                       Property_Value => Numeric_Term (Property_Value));
418
419
420
421
422
423
424
425
426

                  pragma Assert (Dummy = No_List);

                  if Present (Evaluated_Value) then
                     if Kind (Evaluated_Value) = K_Literal then
                        Literal := Evaluated_Value;

                     elsif Kind (Evaluated_Value) = K_Signed_AADLNumber then
                        Literal := Number_Value (Evaluated_Value);
427
428
                     --  Since the number has been evaluated, the
                     --  number_value can only be a literal
429
430
431
432
433
434

                     else
                        Literal := No_Node;
                     end if;

                     if Present (Literal) then
435
436
437
438
                        if Get_Value_Type (Value (Literal)).T = LT_Integer then
                           Val       := Get_Value_Type (Value (Literal));
                           Val.ISign :=
                             not Get_Value_Type (Value (Literal)).ISign;
439
440
                           Set_Value (Value (Literal), Val);

441
442
                        elsif Get_Value_Type (Value (Literal)).T = LT_Real then
                           Val       := Get_Value_Type (Value (Literal));
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
                           Val.RSign := not Val.RSign;
                           Set_Value (Value (Literal), Val);

                        else
                           Evaluated_Value := No_Node;
                        end if;

                        if Present (Evaluated_Value) then
                           if Kind (Evaluated_Value) = K_Literal then
                              Evaluated_Value := Literal;

                           elsif Kind (Evaluated_Value) =
                             K_Signed_AADLNumber
                           then
                              Set_Number_Value (Evaluated_Value, Literal);
                           end if;
                        end if;

                     else
                        Evaluated_Value := No_Node;
                     end if;
                  end if;
               end;

            when K_Signed_AADLNumber =>
               declare
                  Evaluated_Number_Value : Node_Id;
               begin
471
472
473
474
475
476
477
                  Evaluated_Value :=
                    ATNU.New_Node
                      (Kind (Property_Value),
                       ATN.Loc (Property_Value));
                  Set_Unit_Identifier
                    (Evaluated_Value,
                     Unit_Identifier (Property_Value));
478
479
                  Evaluated_Number_Value :=
                    Evaluate_Property_Value
480
481
482
                      (Instance_Root  => Instance_Root,
                       Container      => Container,
                       Property_Value => Number_Value (Property_Value));
483
484
485

                  if Present (Evaluated_Number_Value) then
                     --  XXX we should check the type
486
487
488
                     Set_Number_Value
                       (Evaluated_Value,
                        Evaluated_Number_Value);
489
490
491
492
493
494
495
496
497
                  else
                     Evaluated_Value := No_Node;
                  end if;
               end;

            when K_Not_Boolean_Term =>
               declare
                  Val : Value_Type;
               begin
498
499
500
501
502
                  Evaluated_Value :=
                    Evaluate_Property_Value
                      (Instance_Root  => Instance_Root,
                       Container      => Container,
                       Property_Value => Boolean_Term (Property_Value));
503
504
505

                  if Present (Evaluated_Value)
                    and then Kind (Evaluated_Value) = K_Literal
506
507
508
                    and then
                      Get_Value_Type (Value (Evaluated_Value)).T =
                      LT_Boolean
509
                  then
510
                     Val      := Get_Value_Type (Value (Evaluated_Value));
511
512
513
514
515
516
517
518
519
520
                     Val.BVal := not Val.BVal;
                     Set_Value (Value (Evaluated_Value), Val);
                  else
                     Evaluated_Value := No_Node;
                  end if;
               end;

            when K_And_Boolean_Term =>
               declare
                  Auxiliary_Value : Node_Id;
521
                  Val             : Value_Type;
522
               begin
523
524
525
526
527
528
529
530
531
532
                  Evaluated_Value :=
                    Evaluate_Property_Value
                      (Instance_Root  => Instance_Root,
                       Container      => Container,
                       Property_Value => First_Term (Property_Value));
                  Auxiliary_Value :=
                    Evaluate_Property_Value
                      (Instance_Root  => Instance_Root,
                       Container      => Container,
                       Property_Value => Second_Term (Property_Value));
533
534
535

                  if Present (Evaluated_Value)
                    and then Kind (Evaluated_Value) = K_Literal
536
537
538
                    and then
                      Get_Value_Type (Value (Evaluated_Value)).T =
                      LT_Boolean
539
540
                    and then Present (Auxiliary_Value)
                    and then Kind (Auxiliary_Value) = K_Literal
541
542
543
                    and then
                      Get_Value_Type (Value (Auxiliary_Value)).T =
                      LT_Boolean
544
                  then
545
546
547
                     Val      := Get_Value_Type (Value (Evaluated_Value));
                     Val.BVal :=
                       Val.BVal
548
549
550
551
552
553
554
555
556
557
                       and then Get_Value_Type (Value (Auxiliary_Value)).BVal;
                     Set_Value (Value (Evaluated_Value), Val);
                  else
                     Evaluated_Value := No_Node;
                  end if;
               end;

            when K_Or_Boolean_Term =>
               declare
                  Auxiliary_Value : Node_Id;
558
                  Val             : Value_Type;
559
               begin
560
561
562
563
564
565
566
567
568
569
                  Evaluated_Value :=
                    Evaluate_Property_Value
                      (Instance_Root  => Instance_Root,
                       Container      => Container,
                       Property_Value => First_Term (Property_Value));
                  Auxiliary_Value :=
                    Evaluate_Property_Value
                      (Instance_Root  => Instance_Root,
                       Container      => Container,
                       Property_Value => Second_Term (Property_Value));
570
571
572

                  if Present (Evaluated_Value)
                    and then Kind (Evaluated_Value) = K_Literal
573
574
575
                    and then
                      Get_Value_Type (Value (Evaluated_Value)).T =
                      LT_Boolean
576
577
                    and then Present (Auxiliary_Value)
                    and then Kind (Auxiliary_Value) = K_Literal
578
579
580
                    and then
                      Get_Value_Type (Value (Auxiliary_Value)).T =
                      LT_Boolean
581
                  then
582
583
584
                     Val      := Get_Value_Type (Value (Evaluated_Value));
                     Val.BVal :=
                       Val.BVal
585
586
587
588
589
590
591
592
                       or else Get_Value_Type (Value (Auxiliary_Value)).BVal;
                     Set_Value (Value (Evaluated_Value), Val);
                  else
                     Evaluated_Value := No_Node;
                  end if;
               end;

            when K_Parenthesis_Boolean_Term =>
593
594
595
596
597
               Evaluated_Value :=
                 Evaluate_Property_Value
                   (Instance_Root  => Instance_Root,
                    Container      => Container,
                    Property_Value => Boolean_Term (Property_Value));
598
599
600

               if Present (Evaluated_Value)
                 and then Kind (Evaluated_Value) = K_Literal
601
602
603
                 and then
                   Get_Value_Type (Value (Evaluated_Value)).T =
                   LT_Boolean
604
605
606
607
608
609
610
               then
                  null;
               else
                  Evaluated_Value := No_Node;
               end if;

            when K_Component_Classifier_Term =>
611
612
613
614
615
616
617
618
619
620
               Evaluated_Value :=
                 ATNU.New_Node
                   (Kind (Property_Value),
                    ATN.Loc (Property_Value));
               Set_Referenced_Entity
                 (Evaluated_Value,
                  ATE.Get_Referenced_Entity (Property_Value));
               Set_Component_Cat
                 (Evaluated_Value,
                  Component_Cat (Property_Value));
621

622
623
624
625
626
627
628
629
630
            when K_Record_Term =>
            --  Simply propagate the list to the instance

               Evaluated_Value :=
                 New_Node (Kind (Property_Value), ATN.Loc (Property_Value));
               Set_List_Items
                 (Evaluated_Value,
                  ATN.List_Items (Property_Value));

631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
            when others =>
               raise Program_Error;
         end case;
      end if;

      return Evaluated_Value;
   end Evaluate_Property_Value;

   -----------------------------------
   -- Resolve_Property_Associations --
   -----------------------------------

   procedure Resolve_Property_Associations
     (Properties : List_Id;
      Root       : Node_Id;
      Container  : Node_Id)
   is
      pragma Assert (Present (Container));

      List_Node : Node_Id;
   begin
      if Properties /= No_List then
         List_Node := AIN.First_Node (Properties);

         while Present (List_Node) loop
656
657
            pragma Assert
              (AIN.Kind (List_Node) = K_Property_Association_Instance);
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
            Resolve_Values
              (Root      => Root,
               Container => Container,
               Property  => List_Node);
            List_Node := AIN.Next_Node (List_Node);
         end loop;
      end if;
   end Resolve_Property_Associations;

   ----------------------------------------------
   -- Resolve_Properties_Of_Component_Instance --
   ----------------------------------------------

   procedure Resolve_Properties_Of_Component_Instance
     (Root      : Node_Id;
      Component : Node_Id)
   is
      pragma Assert (Kind (Component) = K_Component_Instance);

      List_Node      : Node_Id;
      Call_List_Node : Node_Id;
   begin
      --  Features

      if AIN.Features (Component) /= No_List then
         List_Node := AIN.First_Node (AIN.Features (Component));

         while Present (List_Node) loop
            Resolve_Property_Associations
              (Root       => Root,
               Properties => AIN.Properties (List_Node),
               Container  => List_Node);

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

      --  Subcomponents

      if AIN.Subcomponents (Component) /= No_List then
         List_Node := AIN.First_Node (AIN.Subcomponents (Component));

         while Present (List_Node) loop
701
702
703
704
705
            if Present (Corresponding_Instance (List_Node)) then
               Resolve_Properties_Of_Component_Instance
                 (Root      => Root,
                  Component => Corresponding_Instance (List_Node));
            end if;
706
707
708
709
710
711
712
713
714
715
716
717
            List_Node := AIN.Next_Node (List_Node);
         end loop;
      end if;

      --  Call sequences
      --  Some call sequences are anonymous

      if AIN.Calls (Component) /= No_List then
         List_Node := AIN.First_Node (AIN.Calls (Component));

         while Present (List_Node) loop
            if AIN.Subprogram_Calls (List_Node) /= No_List then
718
719
               Call_List_Node :=
                 AIN.First_Node (AIN.Subprogram_Calls (List_Node));
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819

               while Present (Call_List_Node) loop
                  Resolve_Properties_Of_Component_Instance
                    (Root      => Root,
                     Component => Corresponding_Instance (Call_List_Node));
                  Call_List_Node := AIN.Next_Node (Call_List_Node);
               end loop;
            end if;

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

      --  Connections
      --  Some connections are anonymous

      if AIN.Connections (Component) /= No_List then
         List_Node := AIN.First_Node (AIN.Connections (Component));

         while Present (List_Node) loop
            Resolve_Property_Associations
              (Root       => Root,
               Properties => AIN.Properties (List_Node),
               Container  => List_Node);
            List_Node := AIN.Next_Node (List_Node);
         end loop;
      end if;

      --  Flows

      if AIN.Flows (Component) /= No_List then
         List_Node := AIN.First_Node (AIN.Flows (Component));

         while Present (List_Node) loop
            Resolve_Property_Associations
              (Root       => Root,
               Properties => AIN.Properties (List_Node),
               Container  => List_Node);
            List_Node := AIN.Next_Node (List_Node);
         end loop;
      end if;

      --  Modes

      if AIN.Modes (Component) /= No_List then
         List_Node := AIN.First_Node (AIN.Modes (Component));

         while Present (List_Node) loop
            if AIN.Kind (List_Node) = K_Mode_Instance then
               Resolve_Property_Associations
                 (Root       => Root,
                  Properties => AIN.Properties (List_Node),
                  Container  => List_Node);
            end if;
            List_Node := AIN.Next_Node (List_Node);
         end loop;
      end if;

      --  Properties

      Resolve_Property_Associations
        (Root       => Root,
         Properties => AIN.Properties (Component),
         Container  => Component);
   end Resolve_Properties_Of_Component_Instance;

   ----------------------------------------------
   -- Resolve_Properties_Of_Namespace_Instance --
   ----------------------------------------------

   procedure Resolve_Properties_Of_Namespace_Instance
     (Root          : Node_Id;
      The_Namespace : Node_Id)
   is
      pragma Assert (Kind (The_Namespace) = K_Namespace_Instance);

      List_Node     : Node_Id;
      The_Component : Node_Id;
   begin

      --  Declarations

      if AIN.Declarations (The_Namespace) /= No_List then
         List_Node := AIN.First_Node (AIN.Declarations (The_Namespace));

         while Present (List_Node) loop
            The_Component := AIN.Item (List_Node);

            pragma Assert (Kind (The_Component) = K_Component_Instance);

            Resolve_Properties_Of_Component_Instance
              (Root      => Root,
               Component => The_Component);

            List_Node := AIN.Next_Node (List_Node);
         end loop;
      end if;
   end Resolve_Properties_Of_Namespace_Instance;

end Ocarina.Instances.Processor.Properties;