source: trunk/ada-2012/src/semantic/gela-plain_environments.ads@ 552

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

Keep package_renaming_declaration in Env

to be able expand selected names in Visible call.

  • Property svn:keywords set to Author Date Revision
File size: 7.1 KB
Line 
1-- This package provides Environment_Set.
2with Gela.Contexts;
3with Gela.Defining_Name_Cursors;
4with Gela.Elements.Defining_Names;
5with Gela.Environments;
6with Gela.Lexical_Types;
7with Gela.Semantic_Types;
8with Gela.Library_Environments;
9
10with Ada.Containers.Hashed_Maps;
11with Ada.Containers.Vectors;
12with Gela.Peristent_Lists;
13with Gela.Name_List_Managers;
14
15package Gela.Plain_Environments is
16 pragma Preelaborate;
17
18 type Environment_Set (Context : access Gela.Contexts.Context'Class) is
19 new Gela.Environments.Environment_Set with private;
20 type Plain_Environment_Set_Access is access all Environment_Set;
21
22private
23
24 package Defining_Name_Lists is new Gela.Peristent_Lists
25 (Element_Type => Gela.Elements.Defining_Names.Defining_Name_Access);
26
27 subtype Defining_Name_List is Defining_Name_Lists.List;
28
29 -- Region_Item --
30
31 type Region_Item is record
32 Name : Gela.Elements.Defining_Names.Defining_Name_Access;
33 -- Defining name corresponding to given region, if any
34 Local : Gela.Name_List_Managers.List;
35 -- List of Direct_Visible_Item.
36 Use_Package : Defining_Name_List;
37 -- List of use_package_clauses in the region
38 Completion : Defining_Name_List;
39 -- List of <Completion, Name> pairs
40 Rename : Gela.Name_List_Managers.List;
41 -- List of package renames.
42 end record;
43
44 package Region_Item_Lists is new Gela.Peristent_Lists
45 (Element_Type => Region_Item);
46
47 subtype Region_Item_List is Region_Item_Lists.List;
48
49 -- Env_Item --
50
51 type Region_Enum is (Nested, Other, Withed);
52 -- Nested - List of nested regions, current - first
53 -- Other - List of all visible regions except Nested_Region_List
54 -- Withed - List of regions available over with clauses
55
56 type Region_List_Array is array (Region_Enum) of Region_Item_List;
57
58 type Env_Item is record
59 Region_List : Region_List_Array;
60 end record;
61
62 use type Gela.Semantic_Types.Env_Index;
63
64 subtype Env_Item_Index is Gela.Semantic_Types.Env_Index
65 range 1 .. Gela.Semantic_Types.Env_Index'Last - 1;
66 -- Reserve last for Library_Level_Environment index
67
68 package Env_Item_Vectors is new Ada.Containers.Vectors
69 (Index_Type => Env_Item_Index,
70 Element_Type => Env_Item);
71
72 function Hash
73 (X : Gela.Lexical_Types.Symbol) return Ada.Containers.Hash_Type;
74
75 function Hash
76 (X : Gela.Semantic_Types.Env_Index) return Ada.Containers.Hash_Type;
77
78 package Symbol_Maps is new Ada.Containers.Hashed_Maps
79 (Key_Type => Gela.Lexical_Types.Symbol,
80 Element_Type => Gela.Semantic_Types.Env_Index,
81 Hash => Hash,
82 Equivalent_Keys => Gela.Lexical_Types."=",
83 "=" => Gela.Semantic_Types."=");
84
85 package Env_Maps is new Ada.Containers.Hashed_Maps
86 (Key_Type => Gela.Semantic_Types.Env_Index,
87 Element_Type => Gela.Lexical_Types.Symbol,
88 Hash => Hash,
89 Equivalent_Keys => Gela.Semantic_Types."=",
90 "=" => Gela.Lexical_Types."=");
91
92 type Environment_Set (Context : access Gela.Contexts.Context'Class) is
93 new Gela.Environments.Environment_Set with
94 record
95 Names : aliased Gela.Name_List_Managers.Name_List_Manager;
96 Lib : aliased Gela.Library_Environments.Environment_Set (Context);
97 Env : Env_Item_Vectors.Vector;
98 Region : Region_Item_Lists.Container;
99 Use_Package : Defining_Name_Lists.Container;
100 Units_Env : Symbol_Maps.Map;
101 -- Map of library level regions
102 Lib_Env : Env_Maps.Map;
103 -- Reverse mapping for Units_Env
104 end record;
105
106 overriding function Empty_Environment
107 (Self : Environment_Set)
108 return Gela.Semantic_Types.Env_Index;
109
110 overriding function Add_With_Clause
111 (Self : in out Environment_Set;
112 Index : Gela.Semantic_Types.Env_Index;
113 Symbol : Gela.Lexical_Types.Symbol)
114 return Gela.Semantic_Types.Env_Index;
115
116 overriding function Add_Defining_Name
117 (Self : in out Environment_Set;
118 Index : Gela.Semantic_Types.Env_Index;
119 Symbol : Gela.Lexical_Types.Symbol;
120 Name : Gela.Elements.Defining_Names.Defining_Name_Access)
121 return Gela.Semantic_Types.Env_Index;
122
123 overriding function Add_Use_Package
124 (Self : in out Environment_Set;
125 Index : Gela.Semantic_Types.Env_Index;
126 Name : Gela.Elements.Defining_Names.Defining_Name_Access)
127 return Gela.Semantic_Types.Env_Index;
128
129 overriding function Add_Rename_Package
130 (Self : in out Environment_Set;
131 Index : Gela.Semantic_Types.Env_Index;
132 Region : Gela.Elements.Defining_Names.Defining_Name_Access;
133 Name : Gela.Elements.Defining_Names.Defining_Name_Access)
134 return Gela.Semantic_Types.Env_Index;
135
136 overriding function Add_Completion
137 (Self : in out Environment_Set;
138 Index : Gela.Semantic_Types.Env_Index;
139 Name : Gela.Elements.Defining_Names.Defining_Name_Access;
140 Completion : Gela.Elements.Defining_Names.Defining_Name_Access)
141 return Gela.Semantic_Types.Env_Index;
142
143 overriding function Completions
144 (Self : in out Environment_Set;
145 Index : Gela.Semantic_Types.Env_Index;
146 Name : Gela.Elements.Defining_Names.Defining_Name_Access)
147 return Gela.Environments.Completion_List;
148
149 overriding function Direct_Visible
150 (Self : access Environment_Set;
151 Index : Gela.Semantic_Types.Env_Index;
152 Symbol : Gela.Lexical_Types.Symbol)
153 return Gela.Defining_Name_Cursors.Defining_Name_Cursor'Class;
154
155 overriding function Enter_Completion_Region
156 (Self : access Environment_Set;
157 Index : Gela.Semantic_Types.Env_Index;
158 Region : Gela.Elements.Defining_Names.Defining_Name_Access)
159 return Gela.Semantic_Types.Env_Index;
160
161 overriding function Enter_Declarative_Region
162 (Self : access Environment_Set;
163 Index : Gela.Semantic_Types.Env_Index;
164 Region : Gela.Elements.Defining_Names.Defining_Name_Access)
165 return Gela.Semantic_Types.Env_Index;
166
167 overriding function Leave_Declarative_Region
168 (Self : access Environment_Set;
169 Index : Gela.Semantic_Types.Env_Index)
170 return Gela.Semantic_Types.Env_Index;
171
172 overriding function Library_Level_Environment
173 (Self : Environment_Set)
174 return Gela.Semantic_Types.Env_Index;
175
176 overriding function Library_Unit_Environment
177 (Self : access Environment_Set;
178 Symbol : Gela.Lexical_Types.Symbol)
179 return Gela.Semantic_Types.Env_Index;
180
181 overriding procedure Set_Library_Unit_Environment
182 (Self : access Environment_Set;
183 Symbol : Gela.Lexical_Types.Symbol;
184 Value : Gela.Semantic_Types.Env_Index);
185
186 overriding function Use_Visible
187 (Self : access Environment_Set;
188 Index : Gela.Semantic_Types.Env_Index;
189 Symbol : Gela.Lexical_Types.Symbol)
190 return Gela.Defining_Name_Cursors.Defining_Name_Cursor'Class;
191
192 overriding function Visible
193 (Self : access Environment_Set;
194 Index : Gela.Semantic_Types.Env_Index;
195 Region : Gela.Elements.Defining_Names.Defining_Name_Access;
196 Symbol : Gela.Lexical_Types.Symbol;
197 Found : access Boolean)
198 return Gela.Defining_Name_Cursors.Defining_Name_Cursor'Class;
199
200end Gela.Plain_Environments;
Note: See TracBrowser for help on using the repository browser.