Natools

Diff
Login

Differences From Artifact [d09dd75265]:

To Artifact [88f07d9369]:


196
197
198
199
200
201
202


































203
204
205
206
207
208
209


   procedure Write_Map_Body
     (Map : in Map_Description;
      Prefix : in String;
      File : in Ada.Text_IO.File_Type) is
   begin


































      Ada.Text_IO.Put_Line
        (File,
         "   function "
         & To_String (Map.Function_Name)
         & " (Key : String) return "
         & To_String (Map.Element_Type)
         & " is");







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243


   procedure Write_Map_Body
     (Map : in Map_Description;
      Prefix : in String;
      File : in Ada.Text_IO.File_Type) is
   begin
      if Map.Indefinite then
         Ada.Text_IO.Put_Line
           (File,
            "   function " & Prefix & "_Elements (Hash : "
            & Prefix & "_Hash)");
         Ada.Text_IO.Put_Line
           (File,
            "     return " & To_String (Map.Element_Type) & " is");
         Ada.Text_IO.Put_Line (File, "   begin");
         Ada.Text_IO.Put_Line (File, "      case Hash is");

         declare
            Pos : Natural := 0;
            Cursor : Node_Lists.Cursor := Map.Nodes.First;
         begin
            while Node_Lists.Has_Element (Cursor) loop
               Ada.Text_IO.Put_Line
                 (File, "         when " & Image (Pos) & " =>");
               Ada.Text_IO.Put_Line
                 (File,
                  "            return "
                  & To_String (Node_Lists.Element (Cursor).Name)
                  & ';');

               Node_Lists.Next (Cursor);
               Pos := Pos + 1;
            end loop;
         end;

         Ada.Text_IO.Put_Line (File, "      end case;");
         Ada.Text_IO.Put_Line (File, "   end " & Prefix & "_Elements;");
         Ada.Text_IO.New_Line (File);
      end if;

      Ada.Text_IO.Put_Line
        (File,
         "   function "
         & To_String (Map.Function_Name)
         & " (Key : String) return "
         & To_String (Map.Element_Type)
         & " is");
321
322
323
324
325
326
327

328
329












330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352

353
354
355
356
357
358
359
            Ada.Text_IO.Put_Line (File, ",");
         end if;

         Pos := Pos + 1;
         Node_Lists.Next (Cursor);
      end loop;


      Ada.Text_IO.Put_Line
        (File,












         "   " & Prefix & "_Elements : constant array (0 .. " & Image (Last)
         & ") of " & To_String (Map.Element_Type));
      Pos := 0;
      Cursor := Map.Nodes.First;
      while Node_Lists.Has_Element (Cursor) loop
         if Pos = 0 then
            Ada.Text_IO.Put (File, "     := (");
         else
            Ada.Text_IO.Put (File, "         ");
         end if;

         Ada.Text_IO.Put
           (File, To_String (Node_Lists.Element (Cursor).Name));

         if Pos = Last then
            Ada.Text_IO.Put_Line (File, ");");
         else
            Ada.Text_IO.Put_Line (File, ",");
         end if;

         Pos := Pos + 1;
         Node_Lists.Next (Cursor);
      end loop;

   end Write_Map_Private_Spec;


   procedure Write_Map_Public_Spec
     (Map : in Map_Description;
      File : in Ada.Text_IO.File_Type) is
   begin







>
|
|
>
>
>
>
>
>
>
>
>
>
>
>
|
|
|
|
|
|
|
|
|
|

|
|

|
|
|
|
|

|
|
|
>







355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
            Ada.Text_IO.Put_Line (File, ",");
         end if;

         Pos := Pos + 1;
         Node_Lists.Next (Cursor);
      end loop;

      if Map.Indefinite then
         Ada.Text_IO.Put_Line
           (File,
            "   subtype " & Prefix & "_Hash is Natural range 0 .. "
            & Image (Last) & ';');
         Ada.Text_IO.Put_Line
           (File,
            "   function " & Prefix & "_Elements (Hash : "
            & Prefix & "_Hash)");
         Ada.Text_IO.Put_Line
           (File,
            "     return " & To_String (Map.Element_Type) & ';');
      else
         Ada.Text_IO.Put_Line
           (File,
            "   " & Prefix & "_Elements : constant array (0 .. " & Image (Last)
            & ") of " & To_String (Map.Element_Type));
         Pos := 0;
         Cursor := Map.Nodes.First;
         while Node_Lists.Has_Element (Cursor) loop
            if Pos = 0 then
               Ada.Text_IO.Put (File, "     := (");
            else
               Ada.Text_IO.Put (File, "         ");
            end if;

            Ada.Text_IO.Put
              (File, To_String (Node_Lists.Element (Cursor).Name));

            if Pos = Last then
               Ada.Text_IO.Put_Line (File, ");");
            else
               Ada.Text_IO.Put_Line (File, ",");
            end if;

            Pos := Pos + 1;
            Node_Lists.Next (Cursor);
         end loop;
      end if;
   end Write_Map_Private_Spec;


   procedure Write_Map_Public_Spec
     (Map : in Map_Description;
      File : in Ada.Text_IO.File_Type) is
   begin
568
569
570
571
572
573
574
575

576
577
578
579
580
581
582
583
584
585
586






587
588
589
590
591
592
593

   procedure Reset (Self : out Map_Description) is
   begin
      Self := (Element_Type => Hold (""),
               Hash_Package_Name => Hold (""),
               Function_Name => Hold (""),
               Not_Found => Hold (""),
               Nodes => Node_Lists.Empty_List);

   end Reset;


   procedure Insert
     (Self : in out Map_Description;
      Key : in String;
      Element_Name : in String) is
   begin
      Self.Nodes.Append  (Node (Key, Element_Name));
   end Insert;








   procedure Set_Element_Type
     (Self : in out Map_Description;
      Name : in String) is
   begin
      Self.Element_Type := Hold (Name);
   end Set_Element_Type;







|
>











>
>
>
>
>
>







616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648

   procedure Reset (Self : out Map_Description) is
   begin
      Self := (Element_Type => Hold (""),
               Hash_Package_Name => Hold (""),
               Function_Name => Hold (""),
               Not_Found => Hold (""),
               Nodes => Node_Lists.Empty_List,
               Indefinite => False);
   end Reset;


   procedure Insert
     (Self : in out Map_Description;
      Key : in String;
      Element_Name : in String) is
   begin
      Self.Nodes.Append  (Node (Key, Element_Name));
   end Insert;


   procedure Set_Definite (Self : in out Map_Description) is
   begin
      Self.Indefinite := False;
   end Set_Definite;


   procedure Set_Element_Type
     (Self : in out Map_Description;
      Name : in String) is
   begin
      Self.Element_Type := Hold (Name);
   end Set_Element_Type;
604
605
606
607
608
609
610








611
612
613
614
615
616
617
618
619
620
621
622
623
624
625

626
627
628
629
630
631
632
633

634
635
636
637
638
639
640
   procedure Set_Hash_Package_Name
     (Self : in out Map_Description;
      Name : in String) is
   begin
      Self.Hash_Package_Name := Hold (Name);
   end Set_Hash_Package_Name;










   procedure Set_Not_Found
     (Self : in out Map_Description;
      Name : in String) is
   begin
      Self.Not_Found := Hold (Name);
   end Set_Not_Found;


   function Map
     (Element_Type : String;
      Nodes : Node_Array;
      Hash_Package_Name : String := "";
      Function_Name : String := "Element";
      Not_Found : String := "")

     return Map_Description
   is
      Result : Map_Description
        := (Element_Type => Hold (Element_Type),
            Hash_Package_Name => Hold (Hash_Package_Name),
            Function_Name => Hold (Function_Name),
            Not_Found => Hold (Not_Found),
            Nodes => Node_Lists.Empty_List);

   begin
      for I in Nodes'Range loop
         Result.Nodes.Append (Nodes (I));
      end loop;

      return Result;
   end Map;







>
>
>
>
>
>
>
>














|
>







|
>







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
701
702
703
704
705
   procedure Set_Hash_Package_Name
     (Self : in out Map_Description;
      Name : in String) is
   begin
      Self.Hash_Package_Name := Hold (Name);
   end Set_Hash_Package_Name;


   procedure Set_Indefinite
     (Self : in out Map_Description;
      Indefinite : in Boolean := True) is
   begin
      Self.Indefinite := Indefinite;
   end Set_Indefinite;


   procedure Set_Not_Found
     (Self : in out Map_Description;
      Name : in String) is
   begin
      Self.Not_Found := Hold (Name);
   end Set_Not_Found;


   function Map
     (Element_Type : String;
      Nodes : Node_Array;
      Hash_Package_Name : String := "";
      Function_Name : String := "Element";
      Not_Found : String := "";
      Indefinite : Boolean := False)
     return Map_Description
   is
      Result : Map_Description
        := (Element_Type => Hold (Element_Type),
            Hash_Package_Name => Hold (Hash_Package_Name),
            Function_Name => Hold (Function_Name),
            Not_Found => Hold (Not_Found),
            Nodes => Node_Lists.Empty_List,
            Indefinite => Indefinite);
   begin
      for I in Nodes'Range loop
         Result.Nodes.Append (Nodes (I));
      end loop;

      return Result;
   end Map;