/[eiffelstudio]/branches/CAT_mono/Src/Eiffel/eiffel/AST/parser_override/type_a.e
ViewVC logotype

Contents of /branches/CAT_mono/Src/Eiffel/eiffel/AST/parser_override/type_a.e

Parent Directory Parent Directory | Revision Log Revision Log


Revision 69700 - (show annotations)
Thu Jul 26 20:01:12 2007 UTC (12 years, 4 months ago) by martins
File size: 26187 byte(s)
added warning: error PCAT (potential CAT issue)
protected conform to from a Void system.current_class for now
(crash occured during the checking of root type properties)
1 indexing
2 description: "Actual type description."
3 legal: "See notice at end of class."
4 status: "See notice at end of class."
5 date: "$Date$"
6 revision: "$Revision$"
7
8 deferred class TYPE_A
9
10 inherit
11 SHARED_TEXT_ITEMS
12 export
13 {NONE} all
14 end
15
16 SHARED_EIFFEL_PROJECT
17 export
18 {NONE} all
19 end
20
21 SHARED_WORKBENCH
22
23 SHARED_TYPE_I
24 export
25 {NONE} all
26 end
27
28 COMPILER_EXPORTER
29 export
30 {NONE} all
31 end
32
33 SHARED_GENERIC_CONSTRAINT
34
35 SHARED_ERROR_HANDLER
36 export
37 {NONE} all
38 end
39
40 SHARED_AST_CONTEXT
41 export
42 {NONE} all
43 end
44
45 CONF_CONSTANTS
46 export
47 {NONE} all
48 end
49
50 feature -- Visitor
51
52 process (v: TYPE_A_VISITOR) is
53 -- Process current element.
54 require
55 v_not_void: v /= Void
56 v_is_valid: v.is_valid
57 deferred
58 end
59
60 feature -- Roundtrip/Token
61
62 first_token (a_list: LEAF_AS_LIST): LEAF_AS is
63 do
64 end
65
66 last_token (a_list: LEAF_AS_LIST): LEAF_AS is
67 do
68 end
69
70 feature -- Properties
71
72 has_renaming: BOOLEAN is
73 -- Does current type have renamed features?
74 -- This can occur in code like: "G -> A rename a as b end"
75 do
76 Result := false
77 end
78
79 has_associated_class: BOOLEAN is
80 -- Does Current have an associated class?
81 do
82 Result := not (is_void or else is_formal or else is_none or else is_type_set)
83 ensure
84 Yes_if_is: Result implies not (is_void or else
85 is_formal or else is_none or else is_type_set)
86 end
87
88 generics: ARRAY [TYPE_A] is
89 -- Actual generic types
90 do
91 -- Void
92 end
93
94 is_type_set: BOOLEAN is
95 -- Is curren type a type_set?
96 -- | example: {A, B}
97 do
98 -- False
99 end
100
101 is_valid: BOOLEAN is
102 -- The associated class is still in the system
103 do
104 Result := True
105 end
106
107 is_integer: BOOLEAN is
108 -- Is the current actual type an integer type ?
109 do
110 -- Do nothing
111 end
112
113 is_natural: BOOLEAN is
114 -- Is current actual type a natural type?
115 do
116 -- Do nothing
117 end
118
119 is_real_32: BOOLEAN is
120 -- Is the current actual type a real 32 bits type ?
121 do
122 -- Do nothing
123 end
124
125 is_real_64: BOOLEAN is
126 -- Is the current actual type a real 64 bits type ?
127 do
128 -- Do nothing
129 end
130
131 is_character: BOOLEAN is
132 -- Is the current actual type a character type ?
133 do
134 -- Do nothing
135 end
136
137 is_character_32: BOOLEAN is
138 -- Is the current actual type a character 32 bits type ?
139 do
140 -- Do nothing
141 end
142
143 is_boolean: BOOLEAN is
144 -- Is the current actual type a boolean type ?
145 do
146 -- Do nothing
147 end
148
149 is_bits: BOOLEAN is
150 -- Is the current actual type a bits type ?
151 do
152 -- Do nothing
153 end
154
155 is_formal: BOOLEAN is
156 -- Is the current actual type a formal generic ?
157 do
158 -- Do nothing
159 end
160
161 is_expanded: BOOLEAN is
162 -- Is the current actual type an expanded one ?
163 do
164 -- Do nothing
165 end
166
167 is_enum: BOOLEAN is
168 -- Is the current actual type an external enum one?
169 do
170 -- Do nothing
171 end
172
173 is_renamed_type: BOOLEAN is
174 -- Is current type an instance of `RENAMED_TYPE_A [TYPE_A]'?
175 -- If so there is the possibility that some features of this type are renamed.
176 do
177 end
178
179 is_reference: BOOLEAN is
180 -- Is current actual type a reference one?
181 do
182 Result := not is_expanded
183 end
184
185 is_true_expanded: BOOLEAN is
186 -- Is current actual type an expanded one which is not basic?
187 do
188 Result := is_expanded and not is_basic
189 end
190
191 is_basic: BOOLEAN is
192 -- Is the current actual type a basic type ?
193 do
194 -- Do nothing
195 end
196
197 is_external: BOOLEAN is
198 -- Is current type based on an external one?
199 do
200 end
201
202 is_separate: BOOLEAN is
203 -- Is the current actual type a separate one ?
204 do
205 -- Do nothing
206 end
207
208 is_none: BOOLEAN is
209 -- Is the current actual type a none type ?
210 do
211 -- Do nothing
212 end
213
214 is_like: BOOLEAN is
215 -- Is the current type an anchored one ?
216 do
217 -- Do nothing
218 end
219
220 is_like_argument: BOOLEAN is
221 -- Is the current type a like argument?
222 do
223 -- Do nothing
224 end
225 is_named_tuple: BOOLEAN is
226 -- Is the current type a tuple with labels?
227 do
228 -- Do nothing
229 end
230
231 is_pointer: BOOLEAN is
232 -- Is the current type a pointer type ?
233 do
234 -- Do nothing
235 end
236
237 is_typed_pointer: BOOLEAN is
238 -- Is current type a typed pointer type ?
239 do
240 -- Do nothing
241 end
242
243 is_tuple: BOOLEAN is
244 -- Is it a TUPLE type
245 do
246 -- Do nothing
247 end
248
249 is_named_type: BOOLEAN is
250 -- Is it a named type?
251 do
252 end
253
254 is_full_named_type: BOOLEAN is
255 -- Is it a full named type?
256 do
257 ensure
258 is_full_named_type_consistent: Result implies is_named_type
259 end
260
261 is_solved: BOOLEAN is
262 do
263 Result := True
264 end
265
266 has_like: BOOLEAN is
267 -- Has the type anchored type in its definition ?
268 do
269 -- Do nothing
270 end
271
272 has_like_argument: BOOLEAN is
273 -- Has the type like argument in its definition?
274 do
275 -- Do nothing
276 end
277
278 has_formal_generic: BOOLEAN is
279 -- Has type a formal generic parameter?
280 do
281 -- False for non-generic type.
282 end
283
284 is_loose: BOOLEAN is
285 -- Does type depend on formal generic parameters and/or anchors?
286 do
287 -- Do nothing
288 ensure
289 definition: Result = (has_like or has_formal_generic)
290 end
291
292 is_void: BOOLEAN is
293 -- Is the type void (procedure type) ?
294 do
295 end
296
297 is_like_current: BOOLEAN is
298 -- Is the current type a anchored type an Current ?
299 do
300 -- Do nothing
301 end
302
303 is_monomorph: BOOLEAN is
304 -- Is the current type monomorph?
305 do
306 -- Do nothing
307 end
308
309 feature -- Comparison
310
311 frozen is_safe_equivalent (other: TYPE_A): BOOLEAN is
312 -- Is the current type the same as `other' ?
313 --| `deep_equal' cannot be used as for STRINGS, the area
314 --| can have a different size but the STRING is still
315 --| the same (problem detected for LIKE_FEATURE). Xavier
316 local
317 l_other: like Current
318 do
319 Result := other /= Void and then other.same_type (Current)
320 if Result then
321 l_other ?= other
322 check l_other_not_void: l_other /= Void end
323 Result := is_equivalent (l_other)
324 end
325 end;
326
327 frozen equivalent (o1, o2: TYPE_A): BOOLEAN is
328 -- Are `o1' and `o2' equivalent ?
329 -- this feature is similar to `deep_equal'
330 -- but ARRAYs and STRINGs are processed correctly
331 -- (`deep_equal' will compare the size of the `area')
332 do
333 if o1 = Void then
334 Result := o2 = Void
335 else
336 Result := o2 /= Void and then o2.same_type (o1) and then
337 o1.is_equivalent (o2)
338 end
339 end
340
341 is_equivalent (other: like Current): BOOLEAN is
342 -- Is `other' equivalent to the current object ?
343 require
344 arg_non_void: other /= Void
345 same_type: same_type (other)
346 deferred
347 end
348
349 same_as (other: TYPE_A): BOOLEAN is
350 -- Is the current type the same as `other' ?
351 require
352 other_attached: other /= Void
353 do
354 -- Do nothing
355 end
356
357 feature -- Access
358
359 associated_class: CLASS_C is
360 -- Class associated to the current type.
361 require
362 has_associated_class: has_associated_class
363 deferred
364 end
365
366 actual_type: TYPE_A is
367 -- Actual type of the interpreted type
368 --| *** FIXME this will become obsolete
369 do
370 Result := Current
371 ensure
372 Result_not_void: Result /= Void
373 end
374
375 conformance_type: TYPE_A is
376 -- Type which is used to check conformance
377 do
378 Result := actual_type
379 ensure
380 Result_not_void: Result /= Void
381 end
382
383 deep_actual_type: TYPE_A is
384 -- Actual type; recursive on generic types
385 -- NOTE by M.S: Needed for ROUTINEs - perhaps
386 -- this is the intended meaning
387 -- of 'actual_type' - but 'actual_type'
388 -- does not recurs on generics(?)!
389 do
390 Result := actual_type
391 end
392
393 has_generics: BOOLEAN is
394 -- Has the current type generics types ?
395 do
396 Result := generics /= Void
397 end
398
399 intrinsic_type: TYPE_A is
400 -- Default type of a manifest constant.
401 do
402 Result := Current
403 ensure
404 result_not_void: Result /= Void
405 end
406
407 renaming: RENAMING_A is
408 -- Renaming of current type.
409 do
410 -- Result := Void
411 end
412
413 feature -- Output
414
415 frozen append_to (a_text_formatter: TEXT_FORMATTER) is
416 -- Append `Current' to `text'.
417 do
418 ext_append_to (a_text_formatter, Void)
419 end
420
421 dump: STRING is
422 -- Dumped trace
423 deferred
424 end
425
426 ext_append_to (a_text_formatter: TEXT_FORMATTER; c: CLASS_C) is
427 -- Append `Current' to `text'.
428 -- `f' is used to retreive the generic type or argument name as string.
429 -- This replaces the old "G#2" or "arg#1" texts in feature signature views.
430 -- Actually used in FORMAL_A and LIKE_ARGUMENT.
431 require
432 a_text_formatter_not_void: a_text_formatter /= Void
433 deferred
434 end
435
436 feature -- Conversion
437
438 to_type_set: TYPE_SET_A is
439 -- Create a type set containing one element which is `Current'.
440 do
441 create Result.make (1)
442 Result.extend (create {RENAMED_TYPE_A [TYPE_A]}.make (Current, Void))
443 ensure
444 to_type_set_not_void: Result /= Void
445 end
446
447 feature {COMPILER_EXPORTER} -- Access
448
449 has_expanded: BOOLEAN is
450 -- Has the current type some expanded types in itself ?
451 do
452 -- Do nothing
453 end
454
455 type_i: TYPE_I is
456 -- C type
457 require
458 is_valid: is_valid
459 deferred
460 end
461
462 meta_type: TYPE_I is
463 -- Meta type
464 require
465 is_valid: is_valid
466 do
467 Result := type_i
468 end
469
470 is_numeric: BOOLEAN is
471 -- Is the current actual type a numeric type ?
472 do
473 -- Do nothing
474 end
475
476 check_const_gen_conformance (a_gen_type: GEN_TYPE_A; a_target_type: TYPE_A; a_class: CLASS_C; i: INTEGER) is
477 -- Is `Current' a valid generic parameter at position `i' of `gen_type'?
478 require
479 a_gen_type_not_void: a_gen_type /= Void
480 a_target_type_not_void: a_target_type /= Void
481 a_class_not_void: a_class /= Void
482 i_non_negative: i > 0
483 local
484 l_vtcg7: VTCG7
485 l_formal_a: FORMAL_A
486 l_target_type: TYPE_A
487 do
488 if a_target_type.is_formal then
489 -- If we find a formal, then we get the actual generic at its position
490 -- and check wheter Current conforms to it.
491 -- Example: class A [G -> H, H] end
492 -- B[G -> A[STRING, COMPARABLE]]
493 -- `Current' is STRING
494 -- `a_target_type' is H
495 -- Note: We loop over all constraints of `G' an call `check_const_gen_conformance'.
496 -- We replace `H' with `COMPARABLE' and check whether `STRING' conforms to `COMPARABLE'.
497 l_formal_a ?= a_target_type
498 check indeed_a_formal_a: l_formal_a /= Void end
499 l_target_type := a_gen_type.generics.item (l_formal_a.position)
500 else
501 l_target_type := a_target_type
502 end
503
504 if not conform_to (l_target_type) then
505 -- FIXME: Manu 02/04/2004 We should be checking convertibility here,
506 -- but for the moment it is not yet possible because this check is done
507 -- before we do degree 4. What we need to implement is the ability
508 -- to check converitibility without having to go through a full
509 -- degree 4
510 reset_constraint_error_list
511 generate_constraint_error (a_gen_type, Current.to_type_set, l_target_type.to_type_set, i, Void)
512 create l_vtcg7
513 l_vtcg7.set_in_constraint (True)
514 l_vtcg7.set_class (a_class)
515 l_vtcg7.set_error_list (constraint_error_list)
516 l_vtcg7.set_parent_type (a_gen_type)
517 Error_handler.insert_error (l_vtcg7)
518 end
519 end
520
521 conform_to (other: TYPE_A): BOOLEAN is
522 -- Does Current conform to `other' ?
523 -- If catcall checking is activated, this prints warnings if the conformance
524 -- check would fail with monomorphic types.
525 require
526 is_valid: is_valid
527 other_not_void: other /= Void
528 other_is_valid: other.is_valid
529 local
530 l_cat_result: BOOLEAN
531 -- l_warning: SOME_TYPE
532 l_pcat: PCAT
533 do
534 if system.current_class /= Void and then system.current_class.is_cat_call_detection then
535
536 -- Increase check level. This tells us when we are on the lowest
537 -- level of checking a generic class so we emit the warning only once
538 conformance_check.level := conformance_check.level + 1
539 if conformance_check.level = 1 then
540 conformance_check.cat_result := True
541 end
542
543 -- Conformance check ignoring monomorphic types, but checking for variant generics
544 Result := is_conforming_descendant (other)
545 l_cat_result := Result
546
547 -- Conformance check for monomorphic types
548 if l_cat_result and then other.is_monomorph then
549 if other.is_formal then
550 check is_formal end
551 -- monomorphic generics only conform to itself
552 l_cat_result := is_equivalent (other)
553 else
554 -- monomorphic types need to be of the same class
555 l_cat_result := has_associated_class and then other.has_associated_class and then associated_class.class_id = other.associated_class.class_id
556 end
557 end
558 if not l_cat_result then
559 conformance_check.cat_result := False
560 end
561
562 -- If result is not the same (in any of the checks, even recursively for generics)
563 -- and it's the first level (i.e. the base class for a generic)
564 -- then we emit a warning
565 if conformance_check.level = 1 and then (conformance_check.cat_result xor Result) then
566 create l_pcat
567 context.init_error (l_pcat)
568 l_pcat.set_source_type (Current)
569 l_pcat.set_target_type (other)
570 if context.current_feature /= Void then
571 l_pcat.set_location (context.current_feature.e_feature.ast.start_location)
572 end
573 error_handler.insert_warning (l_pcat)
574 end
575 conformance_check.level := conformance_check.level - 1
576 else
577 -- Conformance check ignoring monomorphic types. This will also check variant generics,
578 -- but if a generic check fails it only sets `conformance_check.cat_result' to False which
579 -- is ignored here
580 Result := is_conforming_descendant (other)
581 end
582 end
583
584 silent_conform_to (other: TYPE_A): BOOLEAN is
585 -- Does Current conform to `other' ?
586 -- This does not print warnings if conformance check would
587 -- fail using monomorphic types
588 require
589 is_valid: is_valid
590 other_not_void: other /= Void
591 other_is_valid: other.is_valid
592 do
593 if system.current_class.is_cat_call_detection then
594
595 -- Increase check level. This prevents subsequent "conform_to" features
596 -- to not print warnings
597 conformance_check.level := conformance_check.level + 1
598 if conformance_check.level = 1 then
599 conformance_check.cat_result := True
600 end
601
602 -- Conformance check ignoring monomorphic types, but checking for variant generics
603 Result := is_conforming_descendant (other)
604
605 conformance_check.level := conformance_check.level - 1
606 else
607 -- Conformance check ignoring monomorphic types. This will also check variant generics,
608 -- but if a generic check fails it only sets `conformance_check.cat_result' to False which
609 -- is ignored here
610 Result := is_conforming_descendant (other)
611 end
612 end
613
614 is_conforming_descendant (other: TYPE_A): BOOLEAN is
615 -- Does Current conform to `other' ?
616 -- Do not care about monomorphic types.
617 require
618 is_valid: is_valid
619 other_not_void: other /= Void
620 other_is_valid: other.is_valid
621 deferred
622 end
623
624 conformance_check: TUPLE [level: INTEGER; cat_result: BOOLEAN]
625 -- Tuple used to hold information about current conformance check.
626 -- If `level' is 0, the conformance check starts, otherwise we are
627 -- checking generic parameters.
628 once
629 Result := [0, True]
630 end
631
632 is_conformant_to (other: TYPE_A): BOOLEAN is
633 -- Does Current inherit from other?
634 -- Most of the time, it is equivalent to `conform_to' except
635 -- when current is an expanded type.
636 require
637 is_valid: is_valid
638 other_not_void: other /= Void
639 other_is_valid: other.is_valid
640 do
641 Result := conform_to (other)
642 end
643
644 convert_to (a_context_class: CLASS_C; a_target_type: TYPE_A): BOOLEAN is
645 -- Does current convert to `a_target_type' in `a_context_class'?
646 -- Update `last_conversion_info' of AST_CONTEXT.
647 require
648 a_context_class_not_void: a_context_class /= Void
649 a_target_type_not_void: a_target_type /= Void
650 do
651 Result := False
652 context.set_last_conversion_info (Void)
653 ensure
654 context_set: Result implies context.last_conversion_info /= Void
655 end
656
657 valid_generic (type: TYPE_A): BOOLEAN is
658 -- Do the generic parameter of `type' conform to those of
659 -- Current ?
660 require
661 type_not_void: type /= Void
662 conforming_type: type.associated_class.conform_to (associated_class)
663 do
664 end
665
666 actual_argument_type (a_arg_types: ARRAY [TYPE_A]): TYPE_A is
667 -- Type including like argument process based on `a_arg_types'.
668 require
669 a_arg_types_not_void: a_arg_types /= Void
670 do
671 Result := Current
672 end
673
674 instantiation_in (type: TYPE_A; written_id: INTEGER): TYPE_A is
675 -- Instantiation of Current in the context of `type'
676 -- assuming that Current is written in the class of id `written_id'.
677 require
678 good_argument: type /= Void
679 positive_id: written_id > 0
680 do
681 Result := Current
682 end
683
684 instantiated_in (class_type: TYPE_A): TYPE_A is
685 -- Instantiation of Current in the context of `class_type'
686 -- assuming that Current is written in the associated class
687 -- of `class_type'.
688 require
689 good_argument: class_type /= Void
690 do
691 Result := Current
692 end
693
694 evaluated_type_in_descendant (a_ancestor, a_descendant: CLASS_C; a_feature: FEATURE_I): TYPE_A is
695 -- Evaluate `Current' written in `a_ancestor' in the context of `a_descendant' class.
696 -- If `a_feature' is not Void, then it is the feature seen from `a_descendant' from where
697 -- `Current' appears (i.e. not in an inheritance clause).
698 -- FIXME: it would be nice to have an assertion that checks the validity of a type
699 -- in a class (for example that FORMAL_A #3 would not make sense in a class with only
700 -- one formal generic parameter).
701 require
702 type_is_valid: is_valid
703 a_ancestor_not_void: a_ancestor /= Void
704 a_ancestor_valid: a_ancestor.is_valid
705 a_ancestor_compiled: a_ancestor.has_feature_table
706 a_descendant_not_void: a_descendant /= Void
707 a_descendant_valid: a_descendant.is_valid
708 a_descendant_compiled: a_descendant.has_feature_table
709 real_descendant: a_descendant.conform_to (a_ancestor)
710 a_feature_valid: a_feature /= Void implies
711 (a_feature.written_class.conform_to (a_ancestor) and
712 a_descendant.conform_to (a_feature.written_class))
713 is_feature_needed: has_like implies a_feature /= Void
714 do
715 Result := Current
716 ensure
717 same_object: (a_ancestor = a_descendant) implies Result = Current
718 end
719
720 duplicate: like Current is
721 -- Duplication
722 do
723 Result := twin
724 end
725
726 good_generics: BOOLEAN is
727 -- Has the base class exactly the same number of generic
728 -- parameters in its formal generic declarations ?
729 do
730 Result := True
731 end
732
733 error_generics: VTUG is
734 -- Build the error if `good_generics' returns False
735 do
736 end
737
738 check_constraints (a_type_context: CLASS_C; a_context_feature: FEATURE_I; a_check_creation_readiness: BOOLEAN) is
739 -- Check the constained genericity validity rule and leave
740 -- error info in `constraint_error_list'
741 require
742 good_argument: a_type_context /= Void
743 good_generic_count: good_generics
744 do
745 end
746
747 check_labels (a_context_class: CLASS_C; a_node: TYPE_AS) is
748 -- Check validity of `labels' of current in `a_context_class'.
749 require
750 a_context_class_not_void: a_context_class /= Void
751 do
752 end
753
754 expanded_deferred: BOOLEAN is
755 -- Is the expanded type deferred ?
756 require
757 has_expanded
758 local
759 act_type: TYPE_A
760 do
761 act_type := actual_type
762 Result := act_type.is_expanded and then
763 act_type.associated_class.is_deferred
764 end
765
766 valid_expanded_creation (class_c: CLASS_C): BOOLEAN is
767 -- Is the expanded type has an associated class with one
768 -- creation routine with no arguments only, exported to
769 -- `a_class'
770 require
771 has_expanded
772 local
773 a_class: CLASS_C
774 creators: HASH_TABLE [EXPORT_I, STRING]
775 l_export: EXPORT_I
776 do
777 if is_expanded then
778 a_class := associated_class
779 if a_class.is_external then
780 Result := True
781 else
782 creators := a_class.creators
783 if creators = Void then
784 Result := True
785 else
786 creators.search (a_class.default_create_feature.feature_name)
787 if creators.found then
788 l_export := creators.found_item
789 Result := l_export.valid_for (class_c)
790 end
791 end
792 end
793 else
794 Result := True
795 end
796 end
797
798 is_ancestor_valid: BOOLEAN is
799 -- Is type ancestor valid?
800 -- (This is currently checked only for expanded types that have
801 -- an external ancestor, that is not supported by CIL code generation.)
802 require
803 il_generation: system.il_generation
804 do
805 Result := True
806 if is_expanded and then not is_external and then associated_class.has_external_ancestor_class then
807 Result := False
808 end
809 end
810
811 create_info: CREATE_INFO is
812 -- Byte code information for entity type creation
813 require
814 is_valid: is_valid
815 deferred
816 end
817
818 check_for_obsolete_class (current_class: CLASS_C) is
819 -- Check for obsolete class from Current. If
820 -- obsolete then display warning message.
821 require
822 good_arg: current_class /= Void
823 local
824 ass_class: CLASS_C
825 warn: OBS_CLASS_WARN
826 do
827 if not current_class.is_obsolete then
828 if actual_type.has_associated_class then
829 ass_class := actual_type.associated_class
830 if ass_class.is_obsolete and then ass_class.lace_class.options.is_warning_enabled (w_obsolete_class) then
831 create warn
832 warn.set_class (current_class)
833 warn.set_obsolete_class (ass_class)
834 Error_handler.insert_warning (warn)
835 end
836 end
837 end
838 end
839
840 update_dependance (feat_depend: FEATURE_DEPENDANCE) is
841 -- Update dependency for Dead Code Removal
842 do
843 end
844
845 feature {COMPILER_EXPORTER}
846
847 format (ctxt: TEXT_FORMATTER_DECORATOR) is
848 -- Reconstitute text
849 do
850 ctxt.process_string_text (dump, Void)
851 end
852
853 feature {NONE} -- Implementation
854
855 delayed_convert_constraint_check (
856 context_class: CLASS_C;
857 gen_type: GEN_TYPE_A
858 a_set_to_check, a_constraint_types: TYPE_SET_A;
859 i: INTEGER;
860 in_constraint: BOOLEAN)
861 is
862 -- Check that if we have class A [G -> ANY] and we found A [X] where
863 -- X is expanded, then it exists a conversion routine from X to reference X
864 -- and that `reference X' conforms to the constraint ANY.
865 -- Delayed because could not be done during degree 4 since information
866 -- about conversion routine is usually not yet computed.
867 require
868 context_class_not_void: context_class /= Void
869 gen_type_not_void: gen_type /= Void
870 a_set_to_check_not_void: a_set_to_check /= Void
871 a_constraint_types_not_void: a_constraint_types /= Void
872 a_set_to_check_is_expanded: a_set_to_check.has_expanded
873 not_a_constraint_type_is_reference: not a_constraint_types.has_expanded
874 local
875 l_vtcg7: VTCG7
876 l_to_check, l_constraint_type: TYPE_A
877 do
878 reset_constraint_error_list
879
880 -- Only used in case of a single constraint!!
881 l_constraint_type := a_constraint_types.first.type
882
883 if context_class.is_valid and a_set_to_check.is_valid then
884 l_to_check := a_set_to_check.first.type
885 if a_set_to_check.count /= 1 or else a_constraint_types.count /= 1 then
886 generate_constraint_error (gen_type, l_to_check, a_constraint_types, i, Void)
887 -- The feature listed in the creation constraint has
888 -- not been declared in the constraint class.
889 create l_vtcg7
890 l_vtcg7.set_in_constraint (in_constraint)
891 l_vtcg7.set_class (context_class)
892 l_vtcg7.set_error_list (constraint_error_list)
893 l_vtcg7.set_parent_type (gen_type)
894 Error_handler.insert_error (l_vtcg7)
895 elseif
896 not (l_to_check.convert_to (context_class, l_constraint_type) and
897 l_to_check.is_conformant_to (l_constraint_type))
898 then
899 generate_constraint_error (gen_type, l_to_check, a_constraint_types, i, Void)
900 -- The feature listed in the creation constraint has
901 -- not been declared in the constraint class.
902 create l_vtcg7
903 l_vtcg7.set_in_constraint (in_constraint)
904 l_vtcg7.set_class (context_class)
905 l_vtcg7.set_error_list (constraint_error_list)
906 l_vtcg7.set_parent_type (gen_type)
907 Error_handler.insert_error (l_vtcg7)
908 end
909 end
910 end
911
912 generate_constraint_error (gen_type: GEN_TYPE_A; current_type: TYPE_A; constraint_type: TYPE_A; position: INTEGER; a_unmatched_creation_constraints: LIST[FEATURE_I]) is
913 -- Build the error corresponding to the VTCG error
914 local
915 constraint_info: CONSTRAINT_INFO
916 l_current_type_set, l_constraint_type_set: TYPE_SET_A
917 do
918 l_current_type_set := current_type.to_type_set
919 l_constraint_type_set := constraint_type.to_type_set
920 create constraint_info
921 constraint_info.set_type (gen_type)
922 constraint_info.set_actual_type_set (l_current_type_set)
923 constraint_info.set_formal_number (position)
924 constraint_info.set_constraint_types (l_constraint_type_set)
925 constraint_info.set_unmatched_creation_constraints (a_unmatched_creation_constraints)
926 constraint_error_list.extend (constraint_info)
927 end
928
929 invariant
930 -- A generic type should at least have one generic parameter.
931 -- A tuple however is an eception and can have no generic parameter.
932 generics_not_void_implies_generics_not_empty_or_tuple: (generics /= Void implies (not generics.is_empty or is_tuple))
933
934 indexing
935 copyright: "Copyright (c) 1984-2006, Eiffel Software"
936 license: "GPL version 2 (see http://www.eiffel.com/licensing/gpl.txt)"
937 licensing_options: "http://www.eiffel.com/licensing"
938 copying: "[
939 This file is part of Eiffel Software's Eiffel Development Environment.
940
941 Eiffel Software's Eiffel Development Environment is free
942 software; you can redistribute it and/or modify it under
943 the terms of the GNU General Public License as published
944 by the Free Software Foundation, version 2 of the License
945 (available at the URL listed under "license" above).
946
947 Eiffel Software's Eiffel Development Environment is
948 distributed in the hope that it will be useful, but
949 WITHOUT ANY WARRANTY; without even the implied warranty
950 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
951 See the GNU General Public License for more details.
952
953 You should have received a copy of the GNU General Public
954 License along with Eiffel Software's Eiffel Development
955 Environment; if not, write to the Free Software Foundation,
956 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
957 ]"
958 source: "[
959 Eiffel Software
960 356 Storke Road, Goleta, CA 93117 USA
961 Telephone 805-685-1006, Fax 805-685-6869
962 Website http://www.eiffel.com
963 Customer support http://support.eiffel.com
964 ]"
965
966 end -- class TYPE_A

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23