/[eiffelstudio]/vendor/gobosoft.com/gobo/4.0d/library/tools/src/eiffel/compilation/et_signature_checker.e
ViewVC logotype

Contents of /vendor/gobosoft.com/gobo/4.0d/library/tools/src/eiffel/compilation/et_signature_checker.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: 29577 byte(s)
Update 4.0d version with changes in Gobo from 2016/05/09

1 note
2
3 description:
4
5 "Eiffel feature signature checkers"
6
7 library: "Gobo Eiffel Tools Library"
8 copyright: "Copyright (c) 2004-2016, Eric Bezault and others"
9 license: "MIT License"
10 date: "$Date$"
11 revision: "$Revision$"
12
13 class ET_SIGNATURE_CHECKER
14
15 inherit
16
17 ET_CLASS_SUBPROCESSOR
18 redefine
19 make
20 end
21
22 ET_AST_NULL_PROCESSOR
23 undefine
24 make
25 redefine
26 process_class,
27 process_class_type,
28 process_qualified_like_type,
29 process_qualified_like_braced_type,
30 process_tuple_type
31 end
32
33 create
34
35 make
36
37 feature {NONE} -- Initialization
38
39 make
40 -- Create a new signature checker for features of given classes.
41 do
42 precursor {ET_CLASS_SUBPROCESSOR}
43 create parent_context.make_with_capacity (current_class, 1)
44 end
45
46 feature -- Signature validity
47
48 check_signature_vtct_validity (a_feature: ET_FEATURE; a_class: ET_CLASS)
49 -- Check whether the types in the signature of `a_feature'
50 -- (declared in `a_class') are based on known classes.
51 -- Set `has_fatal_error' if a fatal error occurred.
52 require
53 a_feature_not_void: a_feature /= Void
54 a_class_not_void: a_class /= Void
55 a_class_preparsed: a_class.is_preparsed
56 local
57 old_class: ET_CLASS
58 l_type, l_previous_type: detachable ET_TYPE
59 i, nb: INTEGER
60 do
61 has_fatal_error := False
62 old_class := current_class
63 current_class := a_class
64 l_type := a_feature.type
65 if l_type /= Void then
66 l_type.process (Current)
67 end
68 if attached a_feature.arguments as l_arguments then
69 nb := l_arguments.count
70 from i := 1 until i > nb loop
71 l_type := l_arguments.formal_argument (i).type
72 if l_type /= l_previous_type then
73 l_type.process (Current)
74 l_previous_type := l_type
75 end
76 i := i + 1
77 end
78 end
79 current_class := old_class
80 end
81
82 check_signature_validity (a_feature: ET_FLATTENED_FEATURE; a_class: ET_CLASS; a_report: BOOLEAN)
83 -- Check signature validity of `a_feature' for redeclarations and joinings in `a_class'.
84 -- Set `has_fatal_error' if a fatal error occurred.
85 -- `a_report' indicates whether error messages should be emitted or not.
86 require
87 a_feature_not_void: a_feature /= Void
88 a_class_not_void: a_class /= Void
89 a_class_preparsed: a_class.is_preparsed
90 -- no_cycle: no cycle in anchored types involved.
91 local
92 a_flattened_feature: ET_FEATURE
93 a_redeclared_feature: ET_REDECLARED_FEATURE
94 an_inherited_feature: ET_INHERITED_FEATURE
95 a_parent_feature: detachable ET_PARENT_FEATURE
96 an_adapted_feature: ET_ADAPTED_FEATURE
97 a_cursor: DS_LINKED_LIST_CURSOR [ET_PARENT_FEATURE]
98 old_class: ET_CLASS
99 old_processing_mode: INTEGER
100 do
101 has_fatal_error := False
102 old_class := current_class
103 current_class := a_class
104 old_processing_mode := processing_mode
105 processing_mode := check_vtct_validity_mode
106 if a_feature.is_redeclared then
107 -- Redeclaration.
108 if not has_fatal_error then
109 a_redeclared_feature := a_feature.redeclared_feature
110 from
111 a_parent_feature := a_redeclared_feature.parent_feature
112 until
113 a_parent_feature = Void
114 loop
115 check_redeclared_signature_validity (a_redeclared_feature, a_parent_feature, a_report)
116 a_parent_feature := a_parent_feature.merged_feature
117 end
118 end
119 elseif a_feature.is_inherited then
120 an_inherited_feature := a_feature.inherited_feature
121 if an_inherited_feature.parent_feature.merged_feature /= Void then
122 -- No need to check the signature when there is no
123 -- Joining nor merging.
124 a_flattened_feature := an_inherited_feature.flattened_feature
125 if a_flattened_feature.is_deferred then
126 -- Joining (merging deferred features together).
127 from
128 a_parent_feature := an_inherited_feature.parent_feature
129 until
130 a_parent_feature = Void
131 loop
132 check_joined_signature_validity (an_inherited_feature, a_parent_feature, a_report)
133 a_parent_feature := a_parent_feature.merged_feature
134 end
135 else
136 -- Redeclaration (merging deferred features into an effective one).
137 from
138 a_parent_feature := an_inherited_feature.parent_feature
139 until
140 a_parent_feature = Void
141 loop
142 if a_parent_feature.is_deferred then
143 check_redeclared_signature_validity (an_inherited_feature, a_parent_feature, a_report)
144 end
145 a_parent_feature := a_parent_feature.merged_feature
146 end
147 end
148 end
149 end
150 if a_feature.is_adapted then
151 an_adapted_feature := a_feature.adapted_feature
152 if an_adapted_feature.is_selected then
153 if attached an_adapted_feature.replicated_features as a_replicated_features then
154 a_cursor := a_replicated_features.new_cursor
155 from a_cursor.start until a_cursor.after loop
156 check_selected_signature_validity (an_adapted_feature, a_cursor.item, a_report)
157 a_cursor.forth
158 end
159 end
160 end
161 end
162 processing_mode := old_processing_mode
163 current_class := old_class
164 end
165
166 feature {NONE} -- Signature validity
167
168 check_redeclared_signature_validity (a_feature: ET_ADAPTED_FEATURE; other: ET_PARENT_FEATURE; a_report: BOOLEAN)
169 -- Check whether the signature of `a_feature' conforms
170 -- to the signature of `other'. This check has to be done
171 -- when `a_feature' is a redeclaration in `current_class'
172 -- of the inherited feature `other', or when the inherited
173 -- feature `other' is deferred and is merged to the other
174 -- inherted feature `a_feature'.
175 -- `a_report' indicates whether error messages should be emitted or not.
176 require
177 a_feature_not_void: a_feature /= Void
178 other_not_void: other /= Void
179 -- no_cycle: no cycle in anchored types involved.
180 local
181 a_type: detachable ET_TYPE
182 other_type: detachable ET_TYPE
183 other_precursor: ET_FEATURE
184 a_flattened_feature: ET_FEATURE
185 a_parent_feature: ET_PARENT_FEATURE
186 an_arguments: detachable ET_FORMAL_ARGUMENT_LIST
187 other_arguments: detachable ET_FORMAL_ARGUMENT_LIST
188 i, nb: INTEGER
189 l_conforms: BOOLEAN
190 do
191 a_flattened_feature := a_feature.flattened_feature
192 a_type := a_flattened_feature.type
193 parent_context.set (other.parent.type, current_class)
194 other_precursor := other.precursor_feature
195 other_type := other_precursor.type
196 if a_type = Void then
197 if other_type /= Void then
198 set_fatal_error
199 if a_report then
200 if a_feature.is_inherited then
201 a_parent_feature := a_feature.inherited_feature.flattened_parent
202 error_handler.report_vdrd2b_error (current_class, a_parent_feature, other)
203 else
204 error_handler.report_vdrd2a_error (current_class, a_flattened_feature, other)
205 end
206 end
207 end
208 elseif other_type = Void then
209 set_fatal_error
210 if a_report then
211 if a_feature.is_inherited then
212 a_parent_feature := a_feature.inherited_feature.flattened_parent
213 error_handler.report_vdrd2b_error (current_class, a_parent_feature, other)
214 else
215 error_handler.report_vdrd2a_error (current_class, a_flattened_feature, other)
216 end
217 end
218 else
219 -- The test below is useful in expanded types which contains for
220 -- example 'like Current' in the signature. In that case 'like Current'
221 -- in the context of the current expanded class does not conform to
222 -- 'like Current' in the context of the parent, but the types are
223 -- identical so we want to accept this particular case anyway.
224 --
225 -- Note that we won't need that trick anymore with ECMA Eiffel where
226 -- expanded types conforms to reference parents.
227 -- But the reverse is still true: when 'like Current' appears in
228 -- an expanded parent, and the current class is not expanded.
229 --
230 -- There is also a bug in EiffelStudio 6.8 where it allows a feature
231 -- of type 'attached like Current' to be redefined as 'detachable like Current'.
232 -- That's why we use `same_syntactical_type_with_type_marks' and not just
233 -- `same_syntactical_type' below.
234 l_conforms := attached {ET_LIKE_CURRENT} a_type and then a_type.same_syntactical_type_with_type_marks (other_type, tokens.attached_keyword, parent_context, tokens.attached_keyword, current_class)
235 if not l_conforms then
236 if not a_report then
237 check_tuple_actual_parameters_unfolded (a_type, a_flattened_feature.implementation_class)
238 check_tuple_actual_parameters_unfolded (other_type, other_precursor.implementation_class)
239 end
240 l_conforms := a_type.conforms_to_type (other_type, parent_context, current_class)
241 end
242 if not l_conforms then
243 set_fatal_error
244 if a_report then
245 if a_feature.is_inherited then
246 a_parent_feature := a_feature.inherited_feature.flattened_parent
247 error_handler.report_vdrd2b_error (current_class, a_parent_feature, other)
248 else
249 error_handler.report_vdrd2a_error (current_class, a_flattened_feature, other)
250 end
251 end
252 elseif a_feature.is_redeclared and other_precursor.is_attribute then
253 if not a_flattened_feature.is_attribute then
254 -- We already checked in `check_redeclaration_validity' whether
255 -- `a_flattened_feature' was an attribute and reported
256 -- an error otherwise.
257 elseif a_type.is_type_expanded (current_class) then
258 if not other_type.is_type_expanded (parent_context) then
259 -- VDRD-6 says that the types of the two attributes should
260 -- be both expanded or both non-expanded.
261 set_fatal_error
262 if a_report then
263 error_handler.report_vdrd6b_error (current_class, other, a_flattened_feature)
264 end
265 end
266 elseif a_type.is_type_reference (current_class) then
267 if not other_type.is_type_reference (parent_context) then
268 -- VDRD-6 says that the types of the two attributes should
269 -- be both expanded or both non-expanded.
270 set_fatal_error
271 if a_report then
272 error_handler.report_vdrd6b_error (current_class, other, a_flattened_feature)
273 end
274 end
275 else
276 -- Here we don't know about the expandedness of the type:
277 -- it has to be a formal generic parameter for which we don't
278 -- know yet whether the actual generic parameter will be
279 -- expanded or not.
280 if not a_type.same_named_type (other_type, parent_context, current_class) then
281 -- VDRD-6 says that the types of the two attributes should
282 -- be both expanded or both non-expanded.
283 set_fatal_error
284 if a_report then
285 error_handler.report_vdrd6b_error (current_class, other, a_flattened_feature)
286 end
287 end
288 end
289 end
290 end
291 an_arguments := a_flattened_feature.arguments
292 other_arguments := other_precursor.arguments
293 if an_arguments = Void or else an_arguments.is_empty then
294 if other_arguments /= Void and then not other_arguments.is_empty then
295 set_fatal_error
296 if a_report then
297 if a_feature.is_inherited then
298 a_parent_feature := a_feature.inherited_feature.flattened_parent
299 error_handler.report_vdrd2b_error (current_class, a_parent_feature, other)
300 else
301 error_handler.report_vdrd2a_error (current_class, a_flattened_feature, other)
302 end
303 end
304 end
305 elseif other_arguments = Void or else other_arguments.count /= an_arguments.count then
306 set_fatal_error
307 if a_report then
308 error_handler.report_vdrd2a_error (current_class, a_flattened_feature, other)
309 end
310 else
311 nb := an_arguments.count
312 from i := 1 until i > nb loop
313 a_type := an_arguments.formal_argument (i).type
314 other_type := other_arguments.formal_argument (i).type
315 -- The test below is useful in expanded types which contains for
316 -- example 'like Current' in the signature. In that case 'like Current'
317 -- in the context of the current expanded class does not conform to
318 -- 'like Current' in the context of the parent, but the types are
319 -- identical so we want to accept this particular case anyway.
320 --
321 -- Note that we won't need that trick anymore with ECMA Eiffel where
322 -- expanded types conforms to reference parents.
323 -- But the reverse is still true: when 'like Current' appears in
324 -- an expanded parent, and the current class is not expanded.
325 --
326 -- There is also a bug in EiffelStudio 6.8 where it allows a feature
327 -- of type 'attached like Current' to be redefined as 'detachable like Current'.
328 -- That's why we use `same_syntactical_type_with_type_marks' and not just
329 -- `same_syntactical_type' below.
330 l_conforms := attached {ET_LIKE_CURRENT} a_type and then a_type.same_syntactical_type_with_type_marks (other_type, tokens.attached_keyword, parent_context, tokens.attached_keyword, current_class)
331 if not l_conforms then
332 if not a_report then
333 check_tuple_actual_parameters_unfolded (a_type, a_flattened_feature.implementation_class)
334 check_tuple_actual_parameters_unfolded (other_type, other_precursor.implementation_class)
335 end
336 l_conforms := a_type.conforms_to_type (other_type, parent_context, current_class)
337 end
338 if not l_conforms then
339 set_fatal_error
340 if a_report then
341 if a_feature.is_inherited then
342 a_parent_feature := a_feature.inherited_feature.flattened_parent
343 error_handler.report_vdrd2b_error (current_class, a_parent_feature, other)
344 else
345 error_handler.report_vdrd2a_error (current_class, a_flattened_feature, other)
346 end
347 end
348 end
349 i := i + 1
350 end
351 end
352 end
353
354 check_selected_signature_validity (a_feature: ET_ADAPTED_FEATURE; other: ET_PARENT_FEATURE; a_report: BOOLEAN)
355 -- Check whether the signature of `a_feature' conforms
356 -- to the signature of `other'. This check has to be done
357 -- when `a_feature' is the selected version in `current_class'
358 -- of the inherited replicated feature `other'.
359 -- `a_report' indicates whether error messages should be emitted or not.
360 require
361 a_feature_not_void: a_feature /= Void
362 a_feature_selected: a_feature.is_selected
363 other_not_void: other /= Void
364 -- no_cycle: no cycle in anchored types involved.
365 local
366 a_type: detachable ET_TYPE
367 other_type: detachable ET_TYPE
368 other_precursor: ET_FEATURE
369 a_flattened_feature: ET_FEATURE
370 a_parent_feature: ET_PARENT_FEATURE
371 an_arguments: detachable ET_FORMAL_ARGUMENT_LIST
372 other_arguments: detachable ET_FORMAL_ARGUMENT_LIST
373 i, nb: INTEGER
374 l_conforms: BOOLEAN
375 do
376 a_flattened_feature := a_feature.flattened_feature
377 a_type := a_flattened_feature.type
378 parent_context.set (other.parent.type, current_class)
379 other_precursor := other.precursor_feature
380 other_type := other_precursor.type
381 if a_type = Void then
382 if other_type /= Void then
383 set_fatal_error
384 if a_report then
385 if a_feature.is_inherited then
386 a_parent_feature := a_feature.inherited_feature.flattened_parent
387 error_handler.report_vdrd2d_error (current_class, a_parent_feature, other)
388 else
389 error_handler.report_vdrd2c_error (current_class, a_flattened_feature, other)
390 end
391 end
392 end
393 elseif other_type = Void then
394 set_fatal_error
395 if a_report then
396 if a_feature.is_inherited then
397 a_parent_feature := a_feature.inherited_feature.flattened_parent
398 error_handler.report_vdrd2d_error (current_class, a_parent_feature, other)
399 else
400 error_handler.report_vdrd2c_error (current_class, a_flattened_feature, other)
401 end
402 end
403 else
404 -- The test below is useful in expanded types which contains for
405 -- example 'like Current' in the signature. In that case 'like Current'
406 -- in the context of the current expanded class does not conform to
407 -- 'like Current' in the context of the parent, but the types are
408 -- identical so we want to accept this particular case anyway.
409 --
410 -- Note that we won't need that trick anymore with ECMA Eiffel where
411 -- expanded types conforms to reference parents.
412 -- But the reverse is still true: when 'like Current' appears in
413 -- an expanded parent, and the current class is not expanded.
414 --
415 -- There is also a bug in EiffelStudio 6.8 where it allows a feature
416 -- of type 'attached like Current' to be redefined as 'detachable like Current'.
417 -- That's why we use `same_syntactical_type_with_type_marks' and not just
418 -- `same_syntactical_type' below.
419 l_conforms := attached {ET_LIKE_CURRENT} a_type and then a_type.same_syntactical_type_with_type_marks (other_type, tokens.attached_keyword, parent_context, tokens.attached_keyword, current_class)
420 if not l_conforms then
421 if not a_report then
422 check_tuple_actual_parameters_unfolded (a_type, a_flattened_feature.implementation_class)
423 check_tuple_actual_parameters_unfolded (other_type, other_precursor.implementation_class)
424 end
425 l_conforms := a_type.conforms_to_type (other_type, parent_context, current_class)
426 end
427 if not l_conforms then
428 set_fatal_error
429 if a_report then
430 if a_feature.is_inherited then
431 a_parent_feature := a_feature.inherited_feature.flattened_parent
432 error_handler.report_vdrd2d_error (current_class, a_parent_feature, other)
433 else
434 error_handler.report_vdrd2c_error (current_class, a_flattened_feature, other)
435 end
436 end
437 end
438 end
439 an_arguments := a_flattened_feature.arguments
440 other_arguments := other_precursor.arguments
441 if an_arguments = Void or else an_arguments.is_empty then
442 if other_arguments /= Void and then not other_arguments.is_empty then
443 set_fatal_error
444 if a_report then
445 if a_feature.is_inherited then
446 a_parent_feature := a_feature.inherited_feature.flattened_parent
447 error_handler.report_vdrd2d_error (current_class, a_parent_feature, other)
448 else
449 error_handler.report_vdrd2c_error (current_class, a_flattened_feature, other)
450 end
451 end
452 end
453 elseif other_arguments = Void or else other_arguments.count /= an_arguments.count then
454 set_fatal_error
455 if a_report then
456 if a_feature.is_inherited then
457 a_parent_feature := a_feature.inherited_feature.flattened_parent
458 error_handler.report_vdrd2d_error (current_class, a_parent_feature, other)
459 else
460 error_handler.report_vdrd2c_error (current_class, a_flattened_feature, other)
461 end
462 end
463 else
464 nb := an_arguments.count
465 from i := 1 until i > nb loop
466 a_type := an_arguments.formal_argument (i).type
467 other_type := other_arguments.formal_argument (i).type
468 -- The test below is useful in expanded types which contains for
469 -- example 'like Current' in the signature. In that case 'like Current'
470 -- in the context of the current expanded class does not conform to
471 -- 'like Current' in the context of the parent, but the types are
472 -- identical so we want to accept this particular case anyway.
473 --
474 -- Note that we won't need that trick anymore with ECMA Eiffel where
475 -- expanded types conforms to reference parents.
476 -- But the reverse is still true: when 'like Current' appears in
477 -- an expanded parent, and the current class is not expanded.
478 --
479 -- There is also a bug in EiffelStudio 6.8 where it allows a feature
480 -- of type 'attached like Current' to be redefined as 'detachable like Current'.
481 -- That's why we use `same_syntactical_type_with_type_marks' and not just
482 -- `same_syntactical_type' below.
483 l_conforms := attached {ET_LIKE_CURRENT} a_type and then a_type.same_syntactical_type_with_type_marks (other_type, tokens.attached_keyword, parent_context, tokens.attached_keyword, current_class)
484 if not l_conforms then
485 if not a_report then
486 check_tuple_actual_parameters_unfolded (a_type, a_flattened_feature.implementation_class)
487 check_tuple_actual_parameters_unfolded (other_type, other_precursor.implementation_class)
488 end
489 l_conforms := a_type.conforms_to_type (other_type, parent_context, current_class)
490 end
491 if not l_conforms then
492 set_fatal_error
493 if a_report then
494 if a_feature.is_inherited then
495 a_parent_feature := a_feature.inherited_feature.flattened_parent
496 error_handler.report_vdrd2d_error (current_class, a_parent_feature, other)
497 else
498 error_handler.report_vdrd2c_error (current_class, a_flattened_feature, other)
499 end
500 end
501 end
502 i := i + 1
503 end
504 end
505 end
506
507 check_joined_signature_validity (a_feature: ET_INHERITED_FEATURE; other: ET_PARENT_FEATURE; a_report: BOOLEAN)
508 -- Check that `a_feature' and `other' have the same signature
509 -- when viewed from `current_class'. This check has to be done
510 -- when joining two or more deferred features, the `a_feature'
511 -- being the result of the join in `current_class' and `other'
512 -- being one of the other deferred features inherited from a
513 -- parent of `current_class'. (See ETL2 page 165 about Joining.)
514 -- `a_report' indicates whether error messages should be emitted or not.
515 require
516 a_feature_not_void: a_feature /= Void
517 other_not_void: other /= Void
518 -- no_cycle: no cycle in anchored types involved.
519 local
520 a_joined_feature: ET_FEATURE
521 other_precursor: ET_FEATURE
522 an_arguments, other_arguments: detachable ET_FORMAL_ARGUMENT_LIST
523 a_type, other_type: detachable ET_TYPE
524 i, nb: INTEGER
525 do
526 a_joined_feature := a_feature.flattened_feature
527 a_type := a_joined_feature.type
528 other_precursor := other.precursor_feature
529 other_type := other_precursor.type
530 parent_context.set (other.parent.type, current_class)
531 if a_type = Void then
532 if other_type /= Void then
533 set_fatal_error
534 if a_report then
535 error_handler.report_vdjr0c_error (current_class, a_feature.flattened_parent, other)
536 end
537 end
538 elseif other_type = Void then
539 set_fatal_error
540 if a_report then
541 error_handler.report_vdjr0c_error (current_class, a_feature.flattened_parent, other)
542 end
543 else
544 if not a_report then
545 check_tuple_actual_parameters_unfolded (a_type, a_joined_feature.implementation_class)
546 check_tuple_actual_parameters_unfolded (other_type, other_precursor.implementation_class)
547 end
548 if not a_type.same_syntactical_type (other_type, parent_context, current_class) then
549 set_fatal_error
550 if a_report then
551 error_handler.report_vdjr0c_error (current_class, a_feature.flattened_parent, other)
552 end
553 end
554 end
555 an_arguments := a_joined_feature.arguments
556 other_arguments := other_precursor.arguments
557 if an_arguments = Void or else an_arguments.is_empty then
558 if other_arguments /= Void and then not other_arguments.is_empty then
559 set_fatal_error
560 if a_report then
561 error_handler.report_vdjr0a_error (current_class, a_feature.flattened_parent, other)
562 end
563 end
564 elseif other_arguments = Void or else other_arguments.count /= an_arguments.count then
565 set_fatal_error
566 if a_report then
567 error_handler.report_vdjr0a_error (current_class, a_feature.flattened_parent, other)
568 end
569 else
570 nb := an_arguments.count
571 from i := 1 until i > nb loop
572 a_type := an_arguments.formal_argument (i).type
573 other_type := other_arguments.formal_argument (i).type
574 if not a_report then
575 check_tuple_actual_parameters_unfolded (a_type, a_joined_feature.implementation_class)
576 check_tuple_actual_parameters_unfolded (other_type, other_precursor.implementation_class)
577 end
578 if not a_type.same_syntactical_type (other_type, parent_context, current_class) then
579 set_fatal_error
580 if a_report then
581 error_handler.report_vdjr0b_error (current_class, a_feature.flattened_parent, other, i)
582 end
583 end
584 i := i + 1
585 end
586 end
587 end
588
589 feature {NONE} -- VTCT Validity checking
590
591 check_class_type_vtct_validity (a_type: ET_CLASS_TYPE)
592 -- Check whether `a_type' is based on known classes.
593 require
594 a_type_not_void: a_type /= Void
595 local
596 i, nb: INTEGER
597 an_actual: ET_TYPE
598 a_class: ET_CLASS
599 do
600 a_class := a_type.base_class
601 if not a_class.is_preparsed then
602 set_fatal_error
603 error_handler.report_vtct0a_error (current_class, a_type)
604 end
605 if a_type.is_generic and then attached a_type.actual_parameters as an_actuals then
606 nb := an_actuals.count
607 from i := 1 until i > nb loop
608 an_actual := an_actuals.type (i)
609 an_actual.process (Current)
610 i := i + 1
611 end
612 end
613 end
614
615 check_qualified_like_identifier_vtct_validity (a_type: ET_QUALIFIED_LIKE_IDENTIFIER)
616 -- Check whether `a_type' is based on known classes.
617 require
618 a_type_not_void: a_type /= Void
619 do
620 a_type.target_type.process (Current)
621 end
622
623 check_tuple_type_vtct_validity (a_type: ET_TUPLE_TYPE)
624 -- Check whether `a_type' is based on known classes.
625 require
626 a_type_not_void: a_type /= Void
627 local
628 i, nb: INTEGER
629 do
630 -- TODO: should we check whether class TUPLE is in the universe or not?
631 if attached a_type.actual_parameters as a_parameters then
632 nb := a_parameters.count
633 from i := 1 until i > nb loop
634 a_parameters.type (i).process (Current)
635 i := i + 1
636 end
637 end
638 end
639
640 feature {NONE} -- Tuple-type-unfolding
641
642 check_tuple_actual_parameters_unfolded (a_type: ET_TYPE; a_class: ET_CLASS)
643 -- Check whether both phases of Tuple-type-unfolding have been performed
644 -- on actual parameters of class types in `a_type' written in `a_class'.
645 -- Set `has_fatal_error' if this is not the case.
646 require
647 a_type_not_void: a_type /= Void
648 a_class_not_void: a_class /= Void
649 local
650 l_old_current_class: ET_CLASS
651 l_old_processing_mode: INTEGER
652 do
653 l_old_current_class := current_class
654 current_class := a_class
655 l_old_processing_mode := processing_mode
656 processing_mode := check_tuple_actual_parameters_unfolded_mode
657 a_type.process (Current)
658 processing_mode := l_old_processing_mode
659 current_class := l_old_current_class
660 end
661
662 check_class_type_tuple_actual_parameters_unfolded (a_type: ET_CLASS_TYPE)
663 -- Check whether both phases of Tuple-type-unfolding have been performed
664 -- on actual parameters of class types in `a_type'.
665 -- Set `has_fatal_error' if this is not the case.
666 require
667 a_type_not_void: a_type /= Void
668 local
669 i, nb: INTEGER
670 an_actual: ET_TYPE
671 do
672 if attached a_type.actual_parameters as an_actuals then
673 nb := an_actuals.count
674 from i := 1 until i > nb loop
675 an_actual := an_actuals.type (i)
676 an_actual.process (Current)
677 i := i + 1
678 end
679 if not a_type.tuple_actual_parameters_unfolded_2 then
680 set_fatal_error
681 end
682 end
683 end
684
685 check_qualified_like_identifier_tuple_actual_parameters_unfolded (a_type: ET_QUALIFIED_LIKE_IDENTIFIER)
686 -- Check whether both phases of Tuple-type-unfolding have been performed
687 -- on actual parameters of class types in `a_type'.
688 -- Set `has_fatal_error' if this is not the case.
689 require
690 a_type_not_void: a_type /= Void
691 do
692 a_type.target_type.process (Current)
693 end
694
695 check_tuple_type_tuple_actual_parameters_unfolded (a_type: ET_TUPLE_TYPE)
696 -- Check whether both phases of Tuple-type-unfolding have been performed
697 -- on actual parameters of class types in `a_type'.
698 -- Set `has_fatal_error' if this is not the case.
699 require
700 a_type_not_void: a_type /= Void
701 local
702 i, nb: INTEGER
703 an_actual: ET_TYPE
704 do
705 if attached a_type.actual_parameters as an_actuals then
706 nb := an_actuals.count
707 from i := 1 until i > nb loop
708 an_actual := an_actuals.type (i)
709 an_actual.process (Current)
710 i := i + 1
711 end
712 end
713 end
714
715 feature {ET_AST_NODE} -- Type processing
716
717 process_class (a_type: ET_CLASS)
718 -- Process `a_type'.
719 do
720 if processing_mode = check_vtct_validity_mode then
721 process_class_type (a_type)
722 end
723 end
724
725 process_class_type (a_type: ET_CLASS_TYPE)
726 -- Process `a_type'.
727 do
728 if processing_mode = check_vtct_validity_mode then
729 check_class_type_vtct_validity (a_type)
730 elseif processing_mode = check_tuple_actual_parameters_unfolded_mode then
731 check_class_type_tuple_actual_parameters_unfolded (a_type)
732 end
733 end
734
735 process_qualified_like_braced_type (a_type: ET_QUALIFIED_LIKE_BRACED_TYPE)
736 -- Process `a_type'.
737 do
738 if processing_mode = check_vtct_validity_mode then
739 check_qualified_like_identifier_vtct_validity (a_type)
740 elseif processing_mode = check_tuple_actual_parameters_unfolded_mode then
741 check_qualified_like_identifier_tuple_actual_parameters_unfolded (a_type)
742 end
743 end
744
745 process_qualified_like_type (a_type: ET_QUALIFIED_LIKE_TYPE)
746 -- Process `a_type'.
747 do
748 if processing_mode = check_vtct_validity_mode then
749 check_qualified_like_identifier_vtct_validity (a_type)
750 elseif processing_mode = check_tuple_actual_parameters_unfolded_mode then
751 check_qualified_like_identifier_tuple_actual_parameters_unfolded (a_type)
752 end
753 end
754
755 process_tuple_type (a_type: ET_TUPLE_TYPE)
756 -- Process `a_type'.
757 do
758 if processing_mode = check_vtct_validity_mode then
759 check_tuple_type_vtct_validity (a_type)
760 elseif processing_mode = check_tuple_actual_parameters_unfolded_mode then
761 check_tuple_type_tuple_actual_parameters_unfolded (a_type)
762 end
763 end
764
765 processing_mode: INTEGER
766 -- Mode in which `process_*' routines are called
767
768 check_vtct_validity_mode: INTEGER = 1
769 -- VTCT validity checking mode
770
771 check_tuple_actual_parameters_unfolded_mode: INTEGER = 2
772 -- Tuple-type-unfolded checking mode
773
774 feature {NONE} -- Implementation
775
776 parent_context: ET_NESTED_TYPE_CONTEXT
777 -- Parent context for type conformance checking
778
779 invariant
780
781 parent_context_not_void: parent_context /= Void
782
783 end

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23