Natools

Check-in [f06c3f6401]
Login
Overview
Comment:s_expressions-generic_caches: turn a useless check into a precondition
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: f06c3f6401952346dca22fe7fba90a6774d39e5f
User & Date: nat on 2014-02-23 17:55:02
Other Links: manifest | tags
Context
2014-02-24
19:31
s_expressions-cache_tests: add checks using empty reference and cursor check-in: 7d6b6a6e6e user: nat tags: trunk
2014-02-23
17:55
s_expressions-generic_caches: turn a useless check into a precondition check-in: f06c3f6401 user: nat tags: trunk
2014-02-22
13:46
s_expressions-generic_caches: fix level compuation of lists that have just been opened check-in: 7ac5ffc727 user: nat tags: trunk
Changes

Modified src/natools-s_expressions-generic_caches.adb from [9263dcc4c7] to [233b7de8f5].

73
74
75
76
77
78
79

80
81
82
83
84
85
86
87
      return Tree'(Ada.Finalization.Limited_Controlled
        with Root | Last => null, Opening => False);
   end Create_Tree;


   function Duplicate (Source : Tree) return Tree is
      function Dup_List (First, Parent : Node_Access) return Node_Access;

      function Dup_Node (N, Parent : Node_Access) return Node_Access;

      New_Last : Node_Access := null;

      function Dup_List (First, Parent : Node_Access) return Node_Access is
         Source : Node_Access := First;
         Result, Target : Node_Access;
      begin







>
|







73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
      return Tree'(Ada.Finalization.Limited_Controlled
        with Root | Last => null, Opening => False);
   end Create_Tree;


   function Duplicate (Source : Tree) return Tree is
      function Dup_List (First, Parent : Node_Access) return Node_Access;
      function Dup_Node (N : not null Node_Access; Parent : Node_Access)
        return Node_Access;

      New_Last : Node_Access := null;

      function Dup_List (First, Parent : Node_Access) return Node_Access is
         Source : Node_Access := First;
         Result, Target : Node_Access;
      begin
95
96
97
98
99
100
101

102

103
104
105
106
107
108
109
110
111
112
113
114
115
            exit when Source = null;
            Target.Next := Dup_Node (Source, Parent);
            Target := Target.Next;
         end loop;
         return Result;
      end Dup_List;


      function Dup_Node (N, Parent : Node_Access) return Node_Access is

         Result : Node_Access;
      begin
         if N = null then
            return null;
         end if;

         case N.Kind is
            when Atom_Node =>
               Result := new Node'(Kind => Atom_Node,
                 Parent => Parent,
                 Next => null,
                 Data => new Atom'(N.Data.all));
            when List_Node =>







>
|
>


<
<
<
<







96
97
98
99
100
101
102
103
104
105
106
107




108
109
110
111
112
113
114
            exit when Source = null;
            Target.Next := Dup_Node (Source, Parent);
            Target := Target.Next;
         end loop;
         return Result;
      end Dup_List;

      function Dup_Node (N : not null Node_Access; Parent : Node_Access)
        return Node_Access
      is
         Result : Node_Access;
      begin




         case N.Kind is
            when Atom_Node =>
               Result := new Node'(Kind => Atom_Node,
                 Parent => Parent,
                 Next => null,
                 Data => new Atom'(N.Data.all));
            when List_Node =>