Natools

Diff
Login

Differences From Artifact [2c6754c683]:

To Artifact [34517169c8]:


361
362
363
364
365
366
367
368

369
370
371
372
373
374
375
361
362
363
364
365
366
367

368
369
370
371
372
373
374
375







-
+







      pragma Assert (not (Atom_Maps.Key (Cursor).Last < Values.First));

      if Atom_Maps.Key (Cursor).First < Values.First then
         declare
            Old_Key : constant Interval := Atom_Maps.Key (Cursor);
            Prefix_Key : constant Interval
              := (Old_Key.First,  T'Pred (Values.First));
            Prefix_Image : constant Atom_Refs.Immutable_Reference
            Prefix_Image : constant Displayed_Atom
              := Atom_Maps.Element (Cursor);
         begin
            Delete_And_Next (Map, Cursor);
            Map.Insert (Prefix_Key, Prefix_Image);

            if Values.Last < Old_Key.Last then
               Map.Insert ((T'Succ (Values.Last), Old_Key.Last), Prefix_Image);
387
388
389
390
391
392
393
394

395
396
397
398
399
400
401
402
403
404
405
406
407


408
409
410
411
412

413
414
415
416
417
418
419
420
421
422
423
424
425
426



427
428
429
430






431
432
433
434
435
436
437
387
388
389
390
391
392
393

394
395
396
397
398
399
400
401
402
403
404
405
406

407
408
409
410
411
412

413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430




431
432
433
434
435
436
437
438
439
440
441
442
443







-
+












-
+
+




-
+














+
+
+
-
-
-
-
+
+
+
+
+
+







      if Atom_Maps.Has_Element (Cursor)
        and then not (Values.Last < Atom_Maps.Key (Cursor).First)
      then
         declare
            Old_Key : constant Interval := Atom_Maps.Key (Cursor);
            Suffix_Key : constant Interval
              := (T'Succ (Values.Last), Old_Key.Last);
            Suffix_Image : constant Atom_Refs.Immutable_Reference
            Suffix_Image : constant Displayed_Atom
              := Atom_Maps.Element (Cursor);
         begin
            Delete_And_Next (Map, Cursor);
            Map.Insert (Suffix_Key, Suffix_Image);
         end;
      end if;
   end Exclude;


   procedure Include
     (Map : in out Atom_Maps.Map;
      Values : in Interval;
      Image : in Atom_Refs.Immutable_Reference) is
      Image : in Atom_Refs.Immutable_Reference;
      Width : in Generic_Integers.Width) is
   begin
      Exclude (Map, Values);

      if not Image.Is_Empty then
         Map.Insert (Values, Image);
         Map.Insert (Values, (Image, Width));
      end if;
   end Include;


   procedure Parse
     (Map : in out Atom_Maps.Map;
      Expression : in out Lockable.Descriptor'Class)
   is
      Event : Events.Event := Expression.Current_Event;
      Lock : Lockable.Lock_State;
   begin
      loop
         case Event is
            when Events.Add_Atom =>
               declare
                  Image : constant Atom := Expression.Current_Atom;
               begin
               Include
                 (Map,
                  (T'First, T'Last),
                  Create (Expression.Current_Atom));
                  Include
                    (Map,
                     (T'First, T'Last),
                     Create (Image),
                     Image'Length);
               end;

            when Events.Open_List =>
               Expression.Lock (Lock);

               begin
                  Expression.Next;
                  Parse_Single_Affix (Map, Expression);
490
491
492
493
494
495
496

497
498
499
500
501
502
503
504

505
506






























507
508
509
510
511
512
513
514
515
516
517
518
519
520
521

522
523
524
525
526
527
528
529

530


531
532
533
534
535
536
537
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
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







+








+


+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+














-
+








+
-
+
+








         return (First, Last);
      end Read_Interval;

      Event : Events.Event := Expression.Current_Event;
      Lock : Lockable.Lock_State;
      Affix : Atom_Refs.Immutable_Reference;
      Affix_Width : Width := 0;
   begin
      case Event is
         when Events.Add_Atom =>
            declare
               Current : constant Atom := Expression.Current_Atom;
            begin
               if Current'Length > 0 then
                  Affix := Create (Current);
                  Affix_Width := Current'Length;
               end if;
            end;

         when Events.Open_List =>
            Expression.Lock (Lock);

            begin
               Expression.Next (Event);
               if Event /= Events.Add_Atom then
                  Expression.Unlock (Lock, False);
                  return;
               end if;

               Affix := Create (Expression.Current_Atom);
               Affix_Width := Affix.Query.Data.all'Length;

               Expression.Next (Event);
               if Event = Events.Add_Atom then
                  begin
                     Affix_Width := Width'Value
                       (To_String (Expression.Current_Atom));
                  exception
                     when Constraint_Error => null;
                  end;
               end if;
            exception
               when others =>
                  Expression.Unlock (Lock, False);
                  raise;
            end;

            Expression.Unlock (Lock);

         when others =>
            return;
      end case;

      loop
         Expression.Next (Event);

         case Event is
            when Events.Add_Atom =>
               declare
                  Value : T;
               begin
                  Value := T'Value (To_String (Expression.Current_Atom));
                  Include (Map, (Value, Value), Affix);
                  Include (Map, (Value, Value), Affix, Affix_Width);
               exception
                  when Constraint_Error => null;
               end;

            when Events.Open_List =>
               Expression.Lock (Lock);

               begin
                  Include
                  Include (Map, Read_Interval (Expression), Affix);
                    (Map, Read_Interval (Expression),
                     Affix, Affix_Width);
               exception
                  when Constraint_Error =>
                     null;
                  when others =>
                     Expression.Unlock (Lock, False);
                     raise;
               end;
592
593
594
595
596
597
598
599

600
601
602
603
604
605
606
632
633
634
635
636
637
638

639
640
641
642
643
644
645
646







-
+







   begin
      Check_Explicit_Image :
      declare
         Cursor : constant Atom_Maps.Cursor
           := Template.Images.Find ((Value, Value));
      begin
         if Atom_Maps.Has_Element (Cursor) then
            return Atom_Maps.Element (Cursor).Query.Data.all;
            return Atom_Maps.Element (Cursor).Image.Query.Data.all;
         end if;
      end Check_Explicit_Image;

      if Value < 0 then
         Reverse_Render (-Value, Symbols.Query.Data.all, Output, Length);
         Output.Append (Safe_Atom (Template.Negative_Sign, "-"));
      else
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
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







+
-
+
+
+
+
+











+
-
+
+
+
+
+








      Add_Prefix :
      declare
         Cursor : constant Atom_Maps.Cursor
           := Template.Prefix.Find ((Value, Value));
      begin
         if Atom_Maps.Has_Element (Cursor) then
            declare
            Output.Append_Reverse (Atom_Maps.Element (Cursor).Query.Data.all);
               Data : constant Displayed_Atom := Atom_Maps.Element (Cursor);
            begin
               Output.Append_Reverse (Data.Image.Query.Data.all);
               Length := Length + Data.Width;
            end;
         end if;
      end Add_Prefix;

      Output.Invert;

      Add_Suffix :
      declare
         Cursor : constant Atom_Maps.Cursor
           := Template.Suffix.Find ((Value, Value));
      begin
         if Atom_Maps.Has_Element (Cursor) then
            declare
            Output.Append (Atom_Maps.Element (Cursor).Query.Data.all);
               Data : constant Displayed_Atom := Atom_Maps.Element (Cursor);
            begin
               Output.Append (Data.Image.Query.Data.all);
               Length := Length + Data.Width;
            end;
         end if;
      end Add_Suffix;

      if Length > Template.Maximum_Width then
         return Safe_Atom (Template.Overflow_Message, "");
      end if;

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
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
820
821
822
823

824
825
826
827
828
829
830
831







-
+















-
+














-
+







   end Remove_Prefix;


   procedure Remove_Prefix
     (Object : in out Format;
      Values : in Interval) is
   begin
      Set_Prefix (Object, Values, Atom_Refs.Null_Immutable_Reference);
      Set_Prefix (Object, Values, Atom_Refs.Null_Immutable_Reference, 0);
   end Remove_Prefix;


   procedure Remove_Suffix
     (Object : in out Format;
      Value : in T) is
   begin
      Remove_Suffix (Object, (Value, Value));
   end Remove_Suffix;


   procedure Remove_Suffix
     (Object : in out Format;
      Values : in Interval) is
   begin
      Set_Suffix (Object, Values, Atom_Refs.Null_Immutable_Reference);
      Set_Suffix (Object, Values, Atom_Refs.Null_Immutable_Reference, 0);
   end Remove_Suffix;


   procedure Set_Align (Object : in out Format; Value : in Alignment) is
   begin
      Object.Align := Value;
   end Set_Align;


   procedure Set_Image
     (Object : in out Format;
      Value : in T;
      Image : in Atom_Refs.Immutable_Reference) is
   begin
      Include (Object.Images, (Value, Value), Image);
      Include (Object.Images, (Value, Value), Image, 0);
   end Set_Image;


   procedure Set_Image
     (Object : in out Format;
      Value : in T;
      Image : in Atom) is
867
868
869
870
871
872
873
874


875
876

877
878
879
880
881
882
883
884










885

886
887
888
889
890
891
892


893
894

895
896
897
898
899
900
901
902










903

904
905
906
907
908
909
910
917
918
919
920
921
922
923

924
925
926

927
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







-
+
+

-
+








+
+
+
+
+
+
+
+
+
+
-
+






-
+
+

-
+








+
+
+
+
+
+
+
+
+
+
-
+







      Set_Positive_Sign (Object, Create (Sign));
   end Set_Positive_Sign;


   procedure Set_Prefix
     (Object : in out Format;
      Value : in T;
      Prefix : in Atom_Refs.Immutable_Reference) is
      Prefix : in Atom_Refs.Immutable_Reference;
      Width : in Generic_Integers.Width) is
   begin
      Set_Prefix (Object, (Value, Value), Prefix);
      Set_Prefix (Object, (Value, Value), Prefix, Width);
   end Set_Prefix;


   procedure Set_Prefix
     (Object : in out Format;
      Value : in T;
      Prefix : in Atom) is
   begin
      Set_Prefix (Object, Value, Prefix, Prefix'Length);
   end Set_Prefix;


   procedure Set_Prefix
     (Object : in out Format;
      Value : in T;
      Prefix : in Atom;
      Width : in Generic_Integers.Width) is
   begin
      Set_Prefix (Object, Value, Create (Prefix));
      Set_Prefix (Object, Value, Create (Prefix), Width);
   end Set_Prefix;


   procedure Set_Prefix
     (Object : in out Format;
      Values : in Interval;
      Prefix : in Atom_Refs.Immutable_Reference) is
      Prefix : in Atom_Refs.Immutable_Reference;
      Width : in Generic_Integers.Width) is
   begin
      Include (Object.Prefix, Values, Prefix);
      Include (Object.Prefix, Values, Prefix, Width);
   end Set_Prefix;


   procedure Set_Prefix
     (Object : in out Format;
      Values : in Interval;
      Prefix : in Atom) is
   begin
      Set_Prefix (Object, Values, Prefix, Prefix'Length);
   end Set_Prefix;


   procedure Set_Prefix
     (Object : in out Format;
      Values : in Interval;
      Prefix : in Atom;
      Width : in Generic_Integers.Width) is
   begin
      Set_Prefix (Object, Values, Create (Prefix));
      Set_Prefix (Object, Values, Create (Prefix), Width);
   end Set_Prefix;


   procedure Set_Right_Padding
     (Object : in out Format;
      Symbol : in Atom_Refs.Immutable_Reference) is
   begin
919
920
921
922
923
924
925
926


927
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
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
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048

1049
1050
1051
1052
1053
1054
1055
1056







-
+
+

-
+








+
+
+
+
+
+
+
+
+
+
-
+






-
+
+

-
+








+
+
+
+
+
+
+
+
+
+
-
+







      Set_Right_Padding (Object, Create (Symbol));
   end Set_Right_Padding;


   procedure Set_Suffix
     (Object : in out Format;
      Value : in T;
      Suffix : in Atom_Refs.Immutable_Reference) is
      Suffix : in Atom_Refs.Immutable_Reference;
      Width : in Generic_Integers.Width) is
   begin
      Set_Suffix (Object, (Value, Value), Suffix);
      Set_Suffix (Object, (Value, Value), Suffix, Width);
   end Set_Suffix;


   procedure Set_Suffix
     (Object : in out Format;
      Value : in T;
      Suffix : in Atom) is
   begin
      Set_Suffix (Object, Value, Suffix, Suffix'Length);
   end Set_Suffix;


   procedure Set_Suffix
     (Object : in out Format;
      Value : in T;
      Suffix : in Atom;
      Width : in Generic_Integers.Width) is
   begin
      Set_Suffix (Object, Value, Create (Suffix));
      Set_Suffix (Object, Value, Create (Suffix), Width);
   end Set_Suffix;


   procedure Set_Suffix
     (Object : in out Format;
      Values : in Interval;
      Suffix : in Atom_Refs.Immutable_Reference) is
      Suffix : in Atom_Refs.Immutable_Reference;
      Width : in Generic_Integers.Width) is
   begin
      Include (Object.Suffix, Values, Suffix);
      Include (Object.Suffix, Values, Suffix, Width);
   end Set_Suffix;


   procedure Set_Suffix
     (Object : in out Format;
      Values : in Interval;
      Suffix : in Atom) is
   begin
      Set_Suffix (Object, Values, Suffix, Suffix'Length);
   end Set_Suffix;


   procedure Set_Suffix
     (Object : in out Format;
      Values : in Interval;
      Suffix : in Atom;
      Width : in Generic_Integers.Width) is
   begin
      Set_Suffix (Object, Values, Create (Suffix));
      Set_Suffix (Object, Values, Create (Suffix), Width);
   end Set_Suffix;


   procedure Set_Symbols
     (Object : in out Format;
      Symbols : in Atom_Arrays.Immutable_Reference) is
   begin