source: trunk/ada-2012/src/semantic/gela-name_list_managers.adb@ 552

Last change on this file since 552 was 426, checked in by Maxim Reznik, 7 years ago

Minor refactoring

Rename Count_Type to List in Gela.Peristent_Lists. Hide Index_Type

  • Property svn:keywords set to Author Date Revision
File size: 3.7 KB
Line 
1package body Gela.Name_List_Managers is
2
3 ------------
4 -- Append --
5 ------------
6
7 procedure Append
8 (Self : in out Name_List_Manager;
9 Symbol : Gela.Lexical_Types.Symbol;
10 Name : Gela.Elements.Defining_Names.Defining_Name_Access;
11 Input : List;
12 Output : out List)
13 is
14 Value : constant Pair := (Symbol, Name);
15 begin
16 Self.Pair_List.Prepend
17 (Value => Value,
18 Input => Input.Index,
19 Output => Output.Index);
20 end Append;
21
22 ------------
23 -- Append --
24 ------------
25
26 procedure Append
27 (Self : in out Name_List_Manager;
28 Key : Gela.Elements.Defining_Names.Defining_Name_Access;
29 Value : List;
30 Input : Map;
31 Output : out Map)
32 is
33 begin
34 null;
35 end Append;
36
37 -------------
38 -- Element --
39 -------------
40
41 overriding function Element
42 (Self : Defining_Name_Cursor)
43 return Gela.Elements.Defining_Names.Defining_Name_Access
44 is
45 begin
46 return Self.Set.Pair_List.Head (Self.Name).Name;
47 end Element;
48
49 ----------------
50 -- Empty_List --
51 ----------------
52
53 function Empty_List (Self : Name_List_Manager) return List is
54 pragma Unreferenced (Self);
55 begin
56 return (Index => Pair_Peristent_Lists.Empty);
57 end Empty_List;
58
59 ----------
60 -- Find --
61 ----------
62
63 function Find
64 (Self : access Name_List_Manager'Class;
65 Input : List;
66 Symbol : Gela.Lexical_Types.Symbol)
67 return Defining_Name_Cursor is
68 begin
69 return Result : Defining_Name_Cursor := (Self, Input.Index) do
70 Result.Internal_Next (Symbol);
71 end return;
72 end Find;
73
74 procedure For_Each
75 (Self : access Name_List_Manager;
76 Input : List;
77 Proc : access procedure
78 (Symbol : Gela.Lexical_Types.Symbol;
79 Name : Gela.Elements.Defining_Names.Defining_Name_Access))
80 is
81 use type Pair_Peristent_Lists.List;
82
83 Name : Pair_Peristent_Lists.List := Input.Index;
84 begin
85 while Name /= Pair_Peristent_Lists.Empty loop
86 Proc
87 (Self.Pair_List.Head (Name).Symbol,
88 Self.Pair_List.Head (Name).Name);
89
90 Name := Self.Pair_List.Tail (Name);
91 end loop;
92 end For_Each;
93
94 ---------------
95 -- Empty_Map --
96 ---------------
97
98 function Empty_Map (Self : Name_List_Manager) return Map is
99 pragma Unreferenced (Self);
100 begin
101 return (null record);
102 end Empty_Map;
103
104 -----------------
105 -- Has_Element --
106 -----------------
107
108 overriding function Has_Element
109 (Self : Defining_Name_Cursor) return Boolean
110 is
111 use type Pair_Peristent_Lists.List;
112 begin
113 return Self.Name /= Pair_Peristent_Lists.Empty;
114 end Has_Element;
115
116 -------------------
117 -- Internal_Next --
118 -------------------
119
120 procedure Internal_Next
121 (Self : in out Defining_Name_Cursor;
122 Symbol : Gela.Lexical_Types.Symbol)
123 is
124 use type Gela.Lexical_Types.Symbol;
125 use type Pair_Peristent_Lists.List;
126 begin
127 while Self.Name /= Pair_Peristent_Lists.Empty
128 and then Self.Set.Pair_List.Head (Self.Name).Symbol /= Symbol
129 loop
130 Self.Name := Self.Set.Pair_List.Tail (Self.Name);
131 end loop;
132 end Internal_Next;
133
134 ----------
135 -- Next --
136 ----------
137
138 overriding procedure Next
139 (Self : in out Defining_Name_Cursor)
140 is
141 Symbol : constant Gela.Lexical_Types.Symbol := Self.Symbol;
142 begin
143 Self.Name := Self.Set.Pair_List.Tail (Self.Name);
144 Self.Internal_Next (Symbol);
145 end Next;
146
147 ------------
148 -- Symbol --
149 ------------
150
151 function Symbol
152 (Self : Defining_Name_Cursor) return Gela.Lexical_Types.Symbol is
153 begin
154 return Self.Set.Pair_List.Head (Self.Name).Symbol;
155 end Symbol;
156
157end Gela.Name_List_Managers;
Note: See TracBrowser for help on using the repository browser.