/[eiffelstudio]/vendor/gobosoft.com/gobo/4.0d/library/tools/src/eiffel/ast/type/et_like_current.e
ViewVC logotype

Contents of /vendor/gobosoft.com/gobo/4.0d/library/tools/src/eiffel/ast/type/et_like_current.e

Parent Directory Parent Directory | Revision Log Revision Log


Revision 98698 - (show annotations)
Mon May 9 13:53:54 2016 UTC (3 years, 5 months ago) by manus
File size: 18313 byte(s)
Update 4.0d version with changes in Gobo from 2016/05/09

1 note
2
3 description:
4
5 "Eiffel 'like Current' types"
6
7 library: "Gobo Eiffel Tools Library"
8 copyright: "Copyright (c) 2001-2016, Eric Bezault and others"
9 license: "MIT License"
10 date: "$Date$"
11 revision: "$Revision$"
12
13 class ET_LIKE_CURRENT
14
15 inherit
16
17 ET_LIKE_TYPE
18 redefine
19 named_type_with_type_mark,
20 shallow_named_type_with_type_mark,
21 named_type_has_class,
22 is_like_current,
23 same_syntactical_like_current_with_type_marks,
24 same_named_class_type_with_type_marks,
25 same_named_formal_parameter_type_with_type_marks,
26 same_named_tuple_type_with_type_marks,
27 same_base_class_type_with_type_marks,
28 same_base_formal_parameter_type_with_type_marks,
29 same_base_tuple_type_with_type_marks,
30 conforms_from_class_type_with_type_marks,
31 conforms_from_formal_parameter_type_with_type_marks,
32 conforms_from_tuple_type_with_type_marks,
33 type_with_type_mark,
34 is_type_reference_with_type_mark,
35 is_type_detachable_with_type_mark
36 end
37
38 create
39
40 make
41
42 feature {NONE} -- Initialization
43
44 make (a_type_mark: like type_mark)
45 -- Create a new 'like Current' type.
46 do
47 type_mark := a_type_mark
48 like_keyword := tokens.like_keyword
49 current_keyword := tokens.current_keyword
50 ensure
51 type_mark_set: type_mark = a_type_mark
52 end
53
54 feature -- Access
55
56 like_keyword: ET_KEYWORD
57 -- 'like' keyword
58
59 current_keyword: ET_CURRENT
60 -- 'current' keyword
61
62 named_base_class (a_context: ET_TYPE_CONTEXT): ET_NAMED_CLASS
63 -- Same as `base_class' except that it returns information about this
64 -- class (e.g. its name) as known from the universe it is used from
65 -- (instead of from the universe it is written in).
66 -- Return "*UNKNOWN*" class if unresolved identifier type,
67 -- or unmatched formal generic parameter.
68 do
69 Result := a_context.named_base_class
70 end
71
72 base_type_with_type_mark (a_type_mark: detachable ET_TYPE_MARK; a_context: ET_TYPE_CONTEXT): ET_BASE_TYPE
73 -- Same as `base_type' except that its type mark status is
74 -- overridden by `a_type_mark', if not Void
75 do
76 Result := a_context.base_type_with_type_mark (overridden_type_mark (a_type_mark))
77 end
78
79 shallow_base_type_with_type_mark (a_type_mark: detachable ET_TYPE_MARK; a_context: ET_TYPE_CONTEXT): ET_BASE_TYPE
80 -- Same as `shallow_base_type' except that its type mark status is
81 -- overridden by `a_type_mark', if not Void
82 do
83 Result := a_context.root_context.shallow_base_type_with_type_mark (overridden_type_mark (a_type_mark), a_context)
84 end
85
86 base_type_actual (i: INTEGER; a_context: ET_TYPE_CONTEXT): ET_NAMED_TYPE
87 -- `i'-th actual generic parameter's type of the base type of current
88 -- type when it appears in `a_context'
89 do
90 Result := a_context.base_type_actual (i)
91 end
92
93 base_type_actual_parameter (i: INTEGER; a_context: ET_TYPE_CONTEXT): ET_ACTUAL_PARAMETER
94 -- `i'-th actual generic parameter of the base type of current
95 -- type when it appears in `a_context'
96 do
97 Result := a_context.base_type_actual_parameter (i)
98 end
99
100 base_type_index_of_label (a_label: ET_IDENTIFIER; a_context: ET_TYPE_CONTEXT): INTEGER
101 -- Index of actual generic parameter with label `a_label' in
102 -- the base type of current type when it appears in `a_context';
103 -- 0 if it does not exist
104 do
105 Result := a_context.base_type_index_of_label (a_label)
106 end
107
108 named_type_with_type_mark (a_type_mark: detachable ET_TYPE_MARK; a_context: ET_TYPE_CONTEXT): ET_NAMED_TYPE
109 -- Same as `named_type' except that its type mark status is
110 -- overridden by `a_type_mark', if not Void
111 do
112 Result := a_context.named_type_with_type_mark (overridden_type_mark (a_type_mark))
113 end
114
115 shallow_named_type_with_type_mark (a_type_mark: detachable ET_TYPE_MARK; a_context: ET_TYPE_CONTEXT): ET_NAMED_TYPE
116 -- Same as `shallow_named_type' except that its type mark status is
117 -- overridden by `a_type_mark', if not Void
118 do
119 Result := a_context.root_context.shallow_named_type_with_type_mark (overridden_type_mark (a_type_mark), a_context)
120 end
121
122 type_with_type_mark (a_type_mark: detachable ET_TYPE_MARK): ET_LIKE_CURRENT
123 -- Current type whose type mark status is
124 -- overridden by `a_type_mark', if not Void
125 local
126 l_type_mark: detachable ET_TYPE_MARK
127 do
128 l_type_mark := overridden_type_mark (a_type_mark)
129 if l_type_mark = type_mark then
130 Result := Current
131 else
132 create Result.make (a_type_mark)
133 Result.set_like_keyword (like_keyword)
134 Result.set_current_keyword (current_keyword)
135 end
136 end
137
138 hash_code: INTEGER
139 -- Hash code
140 do
141 Result := 1
142 end
143
144 position: ET_POSITION
145 -- Position of first character of
146 -- current node in source code
147 do
148 if attached type_mark as l_type_mark and then not l_type_mark.is_implicit_mark and then not l_type_mark.position.is_null then
149 Result := l_type_mark.position
150 else
151 Result := like_keyword.position
152 end
153 if Result.is_null then
154 Result := current_keyword.position
155 end
156 end
157
158 last_leaf: ET_AST_LEAF
159 -- Last leaf node in current node
160 do
161 Result := current_keyword
162 end
163
164 feature -- Measurement
165
166 base_type_actual_count (a_context: ET_TYPE_CONTEXT): INTEGER
167 -- Number of actual generic parameters of the base type of current type
168 do
169 Result := a_context.base_type_actual_count
170 end
171
172 feature -- Setting
173
174 set_like_keyword (a_like: like like_keyword)
175 -- Set `like_keyword' to `a_like'.
176 require
177 a_like_not_void: a_like /= Void
178 do
179 like_keyword := a_like
180 ensure
181 like_keyword_set: like_keyword = a_like
182 end
183
184 set_current_keyword (a_current: like current_keyword)
185 -- Set `current_keyword' to `a_current'.
186 require
187 a_current_not_void: a_current /= Void
188 do
189 current_keyword := a_current
190 ensure
191 current_keyword_set: current_keyword = a_current
192 end
193
194 feature -- Status report
195
196 is_like_current: BOOLEAN = True
197 -- Is current type of the form 'like Current'?
198
199 is_type_expanded_with_type_mark (a_type_mark: detachable ET_TYPE_MARK; a_context: ET_TYPE_CONTEXT): BOOLEAN
200 -- Same as `is_type_expanded' except that the type mark status is
201 -- overridden by `a_type_mark', if not Void
202 do
203 Result := a_context.is_type_expanded_with_type_mark (overridden_type_mark (a_type_mark))
204 end
205
206 is_type_reference_with_type_mark (a_type_mark: detachable ET_TYPE_MARK; a_context: ET_TYPE_CONTEXT): BOOLEAN
207 -- Same as `is_type_reference' except that the type mark status is
208 -- overridden by `a_type_mark', if not Void
209 do
210 Result := a_context.is_type_reference_with_type_mark (overridden_type_mark (a_type_mark))
211 end
212
213 is_type_attached_with_type_mark (a_type_mark: detachable ET_TYPE_MARK; a_context: ET_TYPE_CONTEXT): BOOLEAN
214 -- Same as `is_type_attached' except that the type mark status is
215 -- overridden by `a_type_mark', if not Void
216 do
217 Result := a_context.is_type_attached_with_type_mark (overridden_type_mark (a_type_mark))
218 end
219
220 is_type_detachable_with_type_mark (a_type_mark: detachable ET_TYPE_MARK; a_context: ET_TYPE_CONTEXT): BOOLEAN
221 -- Same as `is_type_detachable' except that the type mark status is
222 -- overridden by `a_type_mark', if not Void
223 do
224 Result := a_context.is_type_detachable_with_type_mark (overridden_type_mark (a_type_mark))
225 end
226
227 base_type_has_class (a_class: ET_CLASS; a_context: ET_TYPE_CONTEXT): BOOLEAN
228 -- Does the base type of current type contain `a_class'
229 -- when it appears in `a_context'?
230 do
231 Result := a_context.base_type_has_class (a_class)
232 end
233
234 named_type_has_class (a_class: ET_CLASS; a_context: ET_TYPE_CONTEXT): BOOLEAN
235 -- Does the named type of current type contain `a_class'
236 -- when it appears in `a_context'?
237 do
238 Result := a_context.named_type_has_class (a_class)
239 end
240
241 feature -- Comparison
242
243 same_syntactical_type_with_type_marks (other: ET_TYPE; other_type_mark: detachable ET_TYPE_MARK; other_context: ET_TYPE_CONTEXT; a_type_mark: detachable ET_TYPE_MARK; a_context: ET_TYPE_CONTEXT): BOOLEAN
244 -- Same as `same_syntactical_type' except that the type mark status of `Current'
245 -- and `other' is overridden by `a_type_mark' and `other_type_mark', if not Void
246 do
247 if other = Current and then other_type_mark = a_type_mark then
248 Result := True
249 else
250 Result := other.same_syntactical_like_current_with_type_marks (Current, a_type_mark, a_context, other_type_mark, other_context)
251 end
252 end
253
254 same_named_type_with_type_marks (other: ET_TYPE; other_type_mark: detachable ET_TYPE_MARK; other_context: ET_TYPE_CONTEXT; a_type_mark: detachable ET_TYPE_MARK; a_context: ET_TYPE_CONTEXT): BOOLEAN
255 -- Same as `same_named_type' except that the type mark status of `Current'
256 -- and `other' is overridden by `a_type_mark' and `other_type_mark', if not Void
257 do
258 if other = Current and then other_type_mark = a_type_mark and then other_context = a_context then
259 Result := True
260 else
261 Result := a_context.same_named_type_with_type_marks (other, other_type_mark, other_context, overridden_type_mark (a_type_mark))
262 end
263 end
264
265 same_base_type_with_type_marks (other: ET_TYPE; other_type_mark: detachable ET_TYPE_MARK; other_context: ET_TYPE_CONTEXT; a_type_mark: detachable ET_TYPE_MARK; a_context: ET_TYPE_CONTEXT): BOOLEAN
266 -- Same as `same_base_type' except that the type mark status of `Current'
267 -- and `other' is overridden by `a_type_mark' and `other_type_mark', if not Void
268 do
269 if other = Current and then other_type_mark = a_type_mark and then other_context = a_context then
270 Result := True
271 else
272 Result := a_context.same_base_type_with_type_marks (other, other_type_mark, other_context, overridden_type_mark (a_type_mark))
273 end
274 end
275
276 feature {ET_TYPE, ET_TYPE_CONTEXT} -- Comparison
277
278 same_syntactical_like_current_with_type_marks (other: ET_LIKE_CURRENT; other_type_mark: detachable ET_TYPE_MARK; other_context: ET_TYPE_CONTEXT; a_type_mark: detachable ET_TYPE_MARK; a_context: ET_TYPE_CONTEXT): BOOLEAN
279 -- Are current type appearing in `a_context' and `other'
280 -- type appearing in `other_context' the same type?
281 -- (Note: We are NOT comparing the base types here!
282 -- Therefore anchored types are considered the same
283 -- only if they have the same anchor. An anchor type
284 -- is not considered the same as any other type even
285 -- if they have the same base type.)
286 -- Note that the type mark status of `Current' and `other' is
287 -- overridden by `a_type_mark' and `other_type_mark', if not Void
288 do
289 if other = Current and then other_type_mark = a_type_mark and then other_context = a_context then
290 Result := True
291 elseif a_context.attachment_type_conformance_mode then
292 Result := same_attachment_marks_with_default (overridden_type_mark (a_type_mark), other.overridden_type_mark (other_type_mark), Void)
293 else
294 Result := True
295 end
296 end
297
298 same_named_class_type_with_type_marks (other: ET_CLASS_TYPE; other_type_mark: detachable ET_TYPE_MARK; other_context: ET_TYPE_CONTEXT; a_type_mark: detachable ET_TYPE_MARK; a_context: ET_TYPE_CONTEXT): BOOLEAN
299 -- Do current type appearing in `a_context' and `other' type
300 -- appearing in `other_context' have the same named type?
301 -- Note that the type mark status of `Current' and `other' is
302 -- overridden by `a_type_mark' and `other_type_mark', if not Void
303 do
304 Result := a_context.same_named_class_type_with_type_marks (other, other_type_mark, other_context, overridden_type_mark (a_type_mark))
305 end
306
307 same_named_formal_parameter_type_with_type_marks (other: ET_FORMAL_PARAMETER_TYPE; other_type_mark: detachable ET_TYPE_MARK; other_context: ET_TYPE_CONTEXT; a_type_mark: detachable ET_TYPE_MARK; a_context: ET_TYPE_CONTEXT): BOOLEAN
308 -- Do current type appearing in `a_context' and `other' type
309 -- appearing in `other_context' have the same named type?
310 -- Note that the type mark status of `Current' and `other' is
311 -- overridden by `a_type_mark' and `other_type_mark', if not Void
312 do
313 Result := a_context.same_named_formal_parameter_type_with_type_marks (other, other_type_mark, other_context, overridden_type_mark (a_type_mark))
314 end
315
316 same_named_tuple_type_with_type_marks (other: ET_TUPLE_TYPE; other_type_mark: detachable ET_TYPE_MARK; other_context: ET_TYPE_CONTEXT; a_type_mark: detachable ET_TYPE_MARK; a_context: ET_TYPE_CONTEXT): BOOLEAN
317 -- Do current type appearing in `a_context' and `other' type
318 -- appearing in `other_context' have the same named type?
319 -- Note that the type mark status of `Current' and `other' is
320 -- overridden by `a_type_mark' and `other_type_mark', if not Void
321 do
322 Result := a_context.same_named_tuple_type_with_type_marks (other, other_type_mark, other_context, overridden_type_mark (a_type_mark))
323 end
324
325 same_base_class_type_with_type_marks (other: ET_CLASS_TYPE; other_type_mark: detachable ET_TYPE_MARK; other_context: ET_TYPE_CONTEXT; a_type_mark: detachable ET_TYPE_MARK; a_context: ET_TYPE_CONTEXT): BOOLEAN
326 -- Do current type appearing in `a_context' and `other' type
327 -- appearing in `other_context' have the same base type?
328 -- Note that the type mark status of `Current' and `other' is
329 -- overridden by `a_type_mark' and `other_type_mark', if not Void
330 do
331 Result := a_context.same_base_class_type_with_type_marks (other, other_type_mark, other_context, overridden_type_mark (a_type_mark))
332 end
333
334 same_base_formal_parameter_type_with_type_marks (other: ET_FORMAL_PARAMETER_TYPE; other_type_mark: detachable ET_TYPE_MARK; other_context: ET_TYPE_CONTEXT; a_type_mark: detachable ET_TYPE_MARK; a_context: ET_TYPE_CONTEXT): BOOLEAN
335 -- Do current type appearing in `a_context' and `other' type
336 -- appearing in `other_context' have the same base type?
337 -- Note that the type mark status of `Current' and `other' is
338 -- overridden by `a_type_mark' and `other_type_mark', if not Void
339 do
340 Result := a_context.same_base_formal_parameter_type_with_type_marks (other, other_type_mark, other_context, overridden_type_mark (a_type_mark))
341 end
342
343 same_base_tuple_type_with_type_marks (other: ET_TUPLE_TYPE; other_type_mark: detachable ET_TYPE_MARK; other_context: ET_TYPE_CONTEXT; a_type_mark: detachable ET_TYPE_MARK; a_context: ET_TYPE_CONTEXT): BOOLEAN
344 -- Do current type appearing in `a_context' and `other' type
345 -- appearing in `other_context' have the same base type?
346 -- Note that the type mark status of `Current' and `other' is
347 -- overridden by `a_type_mark' and `other_type_mark', if not Void
348 do
349 Result := a_context.same_base_tuple_type_with_type_marks (other, other_type_mark, other_context, overridden_type_mark (a_type_mark))
350 end
351
352 feature -- Conformance
353
354 conforms_to_type_with_type_marks (other: ET_TYPE; other_type_mark: detachable ET_TYPE_MARK; other_context: ET_TYPE_CONTEXT; a_type_mark: detachable ET_TYPE_MARK; a_context: ET_TYPE_CONTEXT): BOOLEAN
355 -- Same as `conforms_to_type' except that the type mark status of `Current'
356 -- and `other' is overridden by `a_type_mark' and `other_type_mark', if not Void
357 do
358 if other = Current and then other_type_mark = a_type_mark and then other_context = a_context then
359 Result := True
360 else
361 Result := a_context.conforms_to_type_with_type_marks (other, other_type_mark, other_context, overridden_type_mark (a_type_mark))
362 end
363 end
364
365 feature {ET_TYPE, ET_TYPE_CONTEXT} -- Conformance
366
367 conforms_from_class_type_with_type_marks (other: ET_CLASS_TYPE; other_type_mark: detachable ET_TYPE_MARK; other_context: ET_TYPE_CONTEXT; a_type_mark: detachable ET_TYPE_MARK; a_context: ET_TYPE_CONTEXT): BOOLEAN
368 -- Does `other' type appearing in `other_context' conform
369 -- to current type appearing in `a_context'?
370 -- Note that the type mark status of `Current' and `other' is
371 -- overridden by `a_type_mark' and `other_type_mark', if not Void
372 -- (Note: 'current_system.ancestor_builder' is used on the classes
373 -- whose ancestors need to be built in order to check for conformance.)
374 do
375 Result := a_context.conforms_from_class_type_with_type_marks (other, other_type_mark, other_context, overridden_type_mark (a_type_mark))
376 end
377
378 conforms_from_formal_parameter_type_with_type_marks (other: ET_FORMAL_PARAMETER_TYPE; other_type_mark: detachable ET_TYPE_MARK; other_context: ET_TYPE_CONTEXT; a_type_mark: detachable ET_TYPE_MARK; a_context: ET_TYPE_CONTEXT): BOOLEAN
379 -- Does `other' type appearing in `other_context' conform
380 -- to current type appearing in `a_context'?
381 -- Note that the type mark status of `Current' and `other' is
382 -- overridden by `a_type_mark' and `other_type_mark', if not Void
383 -- (Note: 'current_system.ancestor_builder' is used on the classes
384 -- whose ancestors need to be built in order to check for conformance.)
385 do
386 Result := a_context.conforms_from_formal_parameter_type_with_type_marks (other, other_type_mark, other_context, overridden_type_mark (a_type_mark))
387 end
388
389 conforms_from_tuple_type_with_type_marks (other: ET_TUPLE_TYPE; other_type_mark: detachable ET_TYPE_MARK; other_context: ET_TYPE_CONTEXT; a_type_mark: detachable ET_TYPE_MARK; a_context: ET_TYPE_CONTEXT): BOOLEAN
390 -- Does `other' type appearing in `other_context' conform
391 -- to current type appearing in `a_context'?
392 -- Note that the type mark status of `Current' and `other' is
393 -- overridden by `a_type_mark' and `other_type_mark', if not Void
394 -- (Note: 'current_system.ancestor_builder' is used on the classes
395 -- whose ancestors need to be built in order to check for conformance.)
396 do
397 Result := a_context.conforms_from_tuple_type_with_type_marks (other, other_type_mark, other_context, overridden_type_mark (a_type_mark))
398 end
399
400 feature -- Output
401
402 append_to_string (a_string: STRING)
403 -- Append textual representation of
404 -- current type to `a_string'.
405 do
406 if attached type_mark as l_type_mark then
407 if l_type_mark.is_implicit_mark then
408 a_string.append_character ('[')
409 end
410 a_string.append_string (l_type_mark.text)
411 if l_type_mark.is_implicit_mark then
412 a_string.append_character (']')
413 end
414 a_string.append_character (' ')
415 end
416 a_string.append_string (like_space_current)
417 end
418
419 feature -- Processing
420
421 process (a_processor: ET_AST_PROCESSOR)
422 -- Process current node.
423 do
424 a_processor.process_like_current (Current)
425 end
426
427 feature {NONE} -- Constants
428
429 like_space_current: STRING = "like Current"
430 -- Eiffel keywords
431
432 invariant
433
434 current_keyword_not_void: current_keyword /= Void
435
436 end

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.23