/[eiffelstudio]/branches/eth/eve/Src/Eiffel/API/evaluated_type/like_type_a.e
ViewVC logotype

Contents of /branches/eth/eve/Src/Eiffel/API/evaluated_type/like_type_a.e

Parent Directory Parent Directory | Revision Log Revision Log


Revision 94983 - (show annotations)
Fri May 2 11:05:28 2014 UTC (5 years, 7 months ago) by jasonw
File size: 16334 byte(s)
<<Merged from trunk#94978.>>
1 note
2 description: "Representation of an anchored type"
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
9 LIKE_TYPE_A
10
11 inherit
12 TYPE_A
13 undefine
14 same_as
15 redefine
16 actual_type, annotation_flags,
17 deep_actual_type, context_free_type,
18 conformance_type,
19 convert_to,
20 has_associated_class,
21 has_like_current,
22 associated_class_type,
23 has_associated_class_type,
24 has_like,
25 formal_instantiation_in,
26 good_generics,
27 error_generics,
28 formal_instantiated_in,
29 instantiated_in,
30 is_class_valid,
31 is_explicit,
32 is_attached,
33 is_basic,
34 is_expanded,
35 is_ephemeral,
36 is_external,
37 is_implicitly_attached,
38 is_initialization_required,
39 is_like,
40 is_loose,
41 is_none,
42 is_reference,
43 is_separate,
44 internal_is_valid_for_class,
45 meta_type,
46 set_attached_mark,
47 set_detachable_mark,
48 set_is_implicitly_attached,
49 set_separate_mark,
50 unset_is_implicitly_attached,
51 description, description_with_detachable_type,
52 c_type,
53 generics,
54 generated_id,
55 generate_cid, generate_cid_array, generate_cid_init,
56 make_type_byte_code, generate_gen_type_il,
57 maximum_interval_value, minimum_interval_value, is_optimized_as_frozen,
58 is_generated_as_single_type, heaviest, instantiation_in, adapted_in,
59 internal_generic_derivation, internal_same_generic_derivation_as,
60 skeleton_adapted_in, set_frozen_mark, is_frozen, is_variant
61 end
62
63 feature -- Properties
64
65 actual_type: TYPE_A
66 -- Actual type of the anchored type in a given class
67
68 deep_actual_type: TYPE_A
69 -- <Precursor>
70 do
71 Result := actual_type.deep_actual_type
72 end
73
74 context_free_type: TYPE_A
75 -- <Precursor>
76 do
77 Result := actual_type.context_free_type
78 end
79
80 conformance_type: TYPE_A
81 -- Type which is used to check conformance
82 do
83 -- `conformance_type' has to be called because
84 -- `actual_type' may yield yet another anchored type.
85 Result := actual_type.conformance_type.to_other_attachment (Current).to_other_variant (Current)
86 end
87
88 feature -- Status report
89
90 has_associated_class: BOOLEAN
91 -- Does Current have an associated class?
92 do
93 Result := actual_type /= Void and then
94 actual_type.has_associated_class
95 end
96
97 has_associated_class_type (a_context_type: TYPE_A): BOOLEAN
98 -- Does Current have an associated class?
99 do
100 Result := actual_type /= Void and then actual_type.has_associated_class_type (a_context_type)
101 end
102
103 has_like: BOOLEAN
104 -- Does the type have anchored type in its definition?
105 do
106 Result := True
107 end
108
109 has_like_current: BOOLEAN
110 -- <Precursor>
111 do
112 Result := actual_type.has_like_current
113 end
114
115 is_class_valid: BOOLEAN
116 do
117 Result := actual_type /= Void and then actual_type.is_class_valid
118 end
119
120 is_like: BOOLEAN = True
121 -- Is the type anchored one ?
122
123 is_loose: BOOLEAN
124 -- Does type depend on formal generic parameters and/or anchors?
125 do
126 -- True for anchored types by default.
127 Result := True
128 end
129
130 is_explicit: BOOLEAN
131 do
132 -- By definition an anchor is never explicit.
133 end
134
135 is_basic: BOOLEAN
136 -- Is the current actual type a basic one ?
137 do
138 Result := actual_type.is_basic
139 end
140
141 is_external: BOOLEAN
142 -- Is current type based on an external class?
143 do
144 Result := actual_type.is_external
145 end
146
147 is_reference: BOOLEAN
148 -- Is current actual type a reference one?
149 do
150 Result := attached actual_type as a and then a.is_reference
151 end
152
153 is_expanded: BOOLEAN
154 -- Is current actual type an expanded one?
155 do
156 Result := attached actual_type as a and then a.is_expanded
157 end
158
159 is_ephemeral: BOOLEAN
160 -- <Precursor>
161 do
162 Result := attached actual_type as a and then a.is_ephemeral
163 end
164
165 is_none: BOOLEAN
166 -- Is current actual type NONE?
167 do
168 Result := actual_type.is_none
169 end
170
171 same_as (other: TYPE_A): BOOLEAN
172 -- Is the current type the same as `other' ?
173 deferred
174 end
175
176 is_separate: BOOLEAN
177 -- Is type separate?
178 do
179 if Precursor then
180 Result := True
181 elseif attached conformance_type as t then
182 Result := t.is_separate
183 end
184 end
185
186 is_attached: BOOLEAN
187 -- <Precursor>
188 do
189 if is_directly_attached then
190 Result := True
191 elseif not has_detachable_mark and then attached actual_type as t then
192 Result := t.is_attached
193 end
194 end
195
196 is_implicitly_attached: BOOLEAN
197 -- <Precursor>
198 do
199 if is_directly_implicitly_attached then
200 Result := True
201 elseif not has_detachable_mark and then attached actual_type as t then
202 Result := t.is_implicitly_attached
203 end
204 end
205
206 is_initialization_required: BOOLEAN
207 -- Is initialization required for this type in void-safe mode?
208 do
209 if Precursor then
210 Result := True
211 elseif not has_detachable_mark then
212 Result := conformance_type.is_initialization_required
213 end
214 end
215
216 is_frozen: BOOLEAN
217 -- <Precursor>
218 do
219 if Precursor then
220 Result := True
221 elseif not has_variant_mark and then attached conformance_type as t then
222 Result := t.is_frozen
223 end
224 end
225
226 is_variant: BOOLEAN
227 -- <Precursor>
228 do
229 if Precursor then
230 Result := True
231 elseif not has_frozen_mark and then attached conformance_type as t then
232 Result := t.is_variant
233 end
234 end
235
236 good_generics: BOOLEAN
237 -- <Original>
238 do
239 Result := actual_type.good_generics
240 end
241
242 error_generics: VTUG
243 -- <Original>
244 --| No need to redefine it in LIKE_CURRENT since `good_generics' is always True.
245 do
246 Result := actual_type.error_generics
247 -- We override the `type' set above since it is `actual_type'
248 -- and we want to see the anchor instead.
249 Result.set_type (Current)
250 end
251
252 feature -- Access
253
254 hash_code: INTEGER
255 do
256 Result := actual_type.hash_code
257 end
258
259 base_class: CLASS_C
260 -- Associated class
261 do
262 Result := actual_type.base_class
263 end
264
265 associated_class_type (a_context_type: TYPE_A): CLASS_TYPE
266 do
267 Result := actual_type.associated_class_type (a_context_type)
268 end
269
270 generics: ARRAYED_LIST [TYPE_A]
271 -- <Precursor>
272 do
273 if attached actual_type as a then
274 Result := a.generics
275 end
276 end
277
278 description: ATTR_DESC
279 do
280 Result := actual_type.description
281 end
282
283 description_with_detachable_type: ATTR_DESC
284 do
285 Result := actual_type.description_with_detachable_type
286 end
287
288 c_type: TYPE_C
289 do
290 Result := actual_type.c_type
291 end
292
293 feature -- Primitives
294
295 set_actual_type (a: TYPE_A)
296 -- Assign `a' to `actual_type'.
297 do
298 -- Remove any previously recorded actual type first
299 -- since it can be used to compute attachment properties
300 -- and give wrong results.
301 actual_type := Void
302 -- Promote separateness status if present.
303 if has_separate_mark then
304 actual_type := a.to_other_immediate_attachment (Current).to_other_separateness (Current)
305 else
306 actual_type := a.to_other_immediate_attachment (Current)
307 end
308 end
309
310 formal_instantiation_in (type: TYPE_A; constraint: TYPE_A; written_id: INTEGER): TYPE_A
311 -- <Precursor>
312 local
313 t: like Current
314 do
315 t := twin
316 t.set_actual_type (actual_type.formal_instantiation_in (type, constraint, written_id))
317 Result := t
318 end
319
320 instantiation_in (type: TYPE_A written_id: INTEGER): TYPE_A
321 -- Instantiation of Current in the context of `class_type',
322 -- assuming that Current is written in class of id `written_id'.
323 local
324 t: like Current
325 do
326 t := twin
327 t.set_actual_type (actual_type.instantiation_in (type, written_id))
328 Result := t
329 end
330
331 adapted_in (a_class_type: CLASS_TYPE): TYPE_A
332 do
333 Result := actual_type.adapted_in (a_class_type)
334 end
335
336 skeleton_adapted_in (a_class_type: CLASS_TYPE): TYPE_A
337 do
338 Result := actual_type.skeleton_adapted_in (a_class_type)
339 end
340
341 formal_instantiated_in (class_type: TYPE_A): TYPE_A
342 -- Instantiation of Current in the context of `class_type'
343 -- assuming that Current is written in the associated class
344 -- of `class_type'.
345 local
346 t: like Current
347 do
348 t := twin
349 t.set_actual_type (actual_type.formal_instantiated_in (class_type).actual_type)
350 Result := t
351 end
352
353 instantiated_in (class_type: TYPE_A): TYPE_A
354 -- Instantiation of Current in the context of `class_type'
355 -- assuming that Current is written in the associated class
356 -- of `class_type'.
357 local
358 t: like Current
359 do
360 t := twin
361 t.set_actual_type (actual_type.instantiated_in (class_type).actual_type)
362 Result := t
363 end
364
365 convert_to (a_context_class: CLASS_C; a_target_type: TYPE_A): BOOLEAN
366 -- Does current convert to `a_target_type' in `a_context_class'?
367 -- Update `last_conversion_info' of AST_CONTEXT.
368 do
369 Result := actual_type.convert_to (a_context_class, a_target_type)
370 end
371
372 meta_type: TYPE_A
373 -- C type for `actual_type'
374 do
375 Result := actual_type.meta_type
376 end
377
378 feature -- Modification
379
380 set_frozen_mark
381 -- <Precursor>
382 do
383 Precursor
384 if attached actual_type as l_type then
385 actual_type := l_type.to_other_variant (Current)
386 end
387 end
388
389 set_attached_mark
390 -- Mark type declaration as having an explicit attached mark.
391 local
392 a: like actual_type
393 do
394 Precursor
395 a := actual_type
396 if a /= Void then
397 actual_type := a.to_other_immediate_attachment (Current)
398 end
399 end
400
401 set_detachable_mark
402 -- Set class type declaration as having an explicit detachable mark.
403 local
404 a: like actual_type
405 do
406 Precursor
407 a := actual_type
408 if a /= Void then
409 actual_type := a.to_other_immediate_attachment (Current)
410 end
411 end
412
413 set_is_implicitly_attached
414 local
415 t: TYPE_A
416 do
417 -- Make sure `actual_type' does not affect attachment status.
418 t := actual_type
419 actual_type := Void
420 Precursor
421 if attached t then
422 actual_type := t.to_other_immediate_attachment (Current)
423 end
424 end
425
426 unset_is_implicitly_attached
427 local
428 t: TYPE_A
429 do
430 -- Make sure `actual_type' does not affect attachment status.
431 t := actual_type
432 actual_type := Void
433 Precursor
434 if attached t then
435 actual_type := t.to_other_immediate_attachment (Current)
436 end
437 end
438
439 set_separate_mark
440 -- <Precursor>
441 do
442 Precursor
443 if attached actual_type as a then
444 actual_type := a.to_other_separateness (Current)
445 end
446 end
447
448 feature -- IL code generation
449
450 minimum_interval_value: INTERVAL_VAL_B
451 require else
452 valid_type: actual_type.is_integer or actual_type.is_natural or actual_type.is_character
453 do
454 Result := actual_type.minimum_interval_value
455 end
456
457 maximum_interval_value: INTERVAL_VAL_B
458 require else
459 valid_type: actual_type.is_integer or actual_type.is_natural or actual_type.is_character
460 do
461 Result := actual_type.maximum_interval_value
462 end
463
464 heaviest (other: TYPE_A): TYPE_A
465 do
466 Result := actual_type.heaviest (other)
467 end
468
469 is_optimized_as_frozen: BOOLEAN
470 do
471 Result := actual_type.is_optimized_as_frozen
472 end
473
474 is_generated_as_single_type: BOOLEAN
475 -- Is associated type generated as a single type or as an interface type and
476 -- an implementation type.
477 do
478 Result := actual_type.is_generated_as_single_type
479 end
480
481 feature -- Generic conformance
482
483 annotation_flags: NATURAL_16
484 -- Flags for annotations of Current.
485 -- Currently only `!' and `frozen' are supported
486 do
487 -- Unlike {TYPE_A}, we actually need to know if the formal is declared with
488 -- an attachment mark and if it is which one. When there are no attachment mark
489 -- at runtime, we will use the attachment mark of the actual generic parameter.
490 if not is_expanded then
491 if is_attached then
492 Result := {SHARED_GEN_CONF_LEVEL}.attached_type
493 elseif has_detachable_mark then
494 Result := {SHARED_GEN_CONF_LEVEL}.detachable_type
495 end
496 end
497 -- To uncomment when variant/frozen proposal for generics is supported.
498 -- if is_frozen then
499 -- Result := Result | {SHARED_GEN_CONF_LEVEL}.frozen_type
500 -- end
501 end
502
503 generated_id (final_mode: BOOLEAN; a_context_type: TYPE_A): NATURAL_16
504 -- Id of a `like xxx'.
505 do
506 Result := actual_type.generated_id (final_mode, a_context_type)
507 end
508
509 generate_cid (buffer: GENERATION_BUFFER; final_mode, use_info: BOOLEAN; a_context_type: TYPE_A)
510 do
511 generate_cid_prefix (buffer, Void)
512 if use_info then
513 initialize_info (shared_create_info)
514 shared_create_info.generate_cid (buffer, final_mode)
515 else
516 actual_type.generate_cid (buffer, final_mode, use_info, a_context_type)
517 end
518 end
519
520 generate_cid_array (buffer: GENERATION_BUFFER; final_mode, use_info: BOOLEAN; idx_cnt: COUNTER; a_context_type: TYPE_A)
521 do
522 generate_cid_prefix (buffer, idx_cnt)
523 if use_info then
524 initialize_info (shared_create_info)
525 shared_create_info.generate_cid_array (buffer, final_mode, idx_cnt)
526 else
527 actual_type.generate_cid_array (buffer, final_mode, use_info, idx_cnt, a_context_type)
528 end
529 end
530
531 generate_cid_init (buffer: GENERATION_BUFFER; final_mode, use_info: BOOLEAN; idx_cnt: COUNTER; a_context_type: TYPE_A; a_level: NATURAL)
532 do
533 generate_cid_prefix (Void, idx_cnt)
534 if use_info then
535 initialize_info (shared_create_info)
536 shared_create_info.generate_cid_init (buffer, final_mode, idx_cnt, a_level)
537 else
538 actual_type.generate_cid_init (buffer, final_mode, use_info, idx_cnt, a_context_type, a_level)
539 end
540 end
541
542 make_type_byte_code (ba: BYTE_ARRAY; use_info: BOOLEAN; a_context_type: TYPE_A)
543 do
544 make_type_prefix_byte_code (ba)
545 if use_info then
546 initialize_info (shared_create_info)
547 shared_create_info.make_type_byte_code (ba)
548 else
549 actual_type.make_type_byte_code (ba, use_info, a_context_type)
550 end
551 end
552
553 generate_gen_type_il (il_generator: IL_CODE_GENERATOR; use_info: BOOLEAN)
554 -- `use_info' is true iff we generate code for a
555 -- creation instruction.
556 do
557 if use_info then
558 initialize_info (shared_create_info)
559 shared_create_info.generate_il_type
560 else
561 actual_type.generate_gen_type_il (il_generator, use_info)
562 end
563 end
564
565 initialize_info (an_info: like shared_create_info)
566 -- Initialize `an_info' using current data.
567 do
568 end
569
570 shared_create_info: CREATE_INFO
571 -- Same as `create_info' except that it is a shared instance.
572 deferred
573 end
574
575 feature {TYPE_A} -- Helpers
576
577 internal_conform_to (a_context_class: CLASS_C; other: TYPE_A; a_in_generic: BOOLEAN): BOOLEAN
578 -- <Precursor>
579 do
580 Result := actual_type.internal_conform_to (a_context_class, other.conformance_type, a_in_generic)
581 end
582
583 internal_is_valid_for_class (a_class: CLASS_C): BOOLEAN
584 -- Is current type valid?
585 do
586 Result := attached actual_type as l_actual_type and then l_actual_type.internal_is_valid_for_class (a_class)
587 end
588
589 internal_generic_derivation (a_level: INTEGER_32): TYPE_A
590 do
591 -- We keep the same level since we are merely forwarding the call.
592 Result := actual_type.internal_generic_derivation (a_level)
593 end
594
595 internal_same_generic_derivation_as (current_type, other: TYPE_A; a_level: INTEGER_32): BOOLEAN
596 do
597 -- We keep the same level since we are merely forwarding the call.
598 Result := actual_type.internal_same_generic_derivation_as (current_type, other, a_level)
599 end
600
601 note
602 copyright: "Copyright (c) 1984-2014, Eiffel Software"
603 license: "GPL version 2 (see http://www.eiffel.com/licensing/gpl.txt)"
604 licensing_options: "http://www.eiffel.com/licensing"
605 copying: "[
606 This file is part of Eiffel Software's Eiffel Development Environment.
607
608 Eiffel Software's Eiffel Development Environment is free
609 software; you can redistribute it and/or modify it under
610 the terms of the GNU General Public License as published
611 by the Free Software Foundation, version 2 of the License
612 (available at the URL listed under "license" above).
613
614 Eiffel Software's Eiffel Development Environment is
615 distributed in the hope that it will be useful, but
616 WITHOUT ANY WARRANTY; without even the implied warranty
617 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
618 See the GNU General Public License for more details.
619
620 You should have received a copy of the GNU General Public
621 License along with Eiffel Software's Eiffel Development
622 Environment; if not, write to the Free Software Foundation,
623 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
624 ]"
625 source: "[
626 Eiffel Software
627 5949 Hollister Ave., Goleta, CA 93117 USA
628 Telephone 805-685-1006, Fax 805-685-6869
629 Website http://www.eiffel.com
630 Customer support http://support.eiffel.com
631 ]"
632
633 end -- class LIKE_TYPE_A

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23