/[eiffelstudio]/branches/CAT_mono/Src/Eiffel/eiffel/genericity/type_i.e
ViewVC logotype

Contents of /branches/CAT_mono/Src/Eiffel/eiffel/genericity/type_i.e

Parent Directory Parent Directory | Revision Log Revision Log


Revision 69868 - (show annotations)
Fri Aug 3 22:28:26 2007 UTC (12 years, 4 months ago) by martins
File size: 14855 byte(s)
enabled more types to store monomorph information
1 indexing
2 description: "Representation of a type during code generation."
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_I
9
10 inherit
11 HASHABLE
12 SHARED_HASH_CODE
13 SHARED_WORKBENCH
14 SHARED_TYPE_I
15 export
16 {NONE} all
17 end
18
19 SK_CONST
20 COMPILER_EXPORTER
21 SHARED_GEN_CONF_LEVEL
22
23 DEBUG_OUTPUT
24 export
25 {NONE} all
26 end
27
28 feature -- Access
29
30 static_type_id: INTEGER is
31 -- Static Type id of `Current'.
32 require
33 il_generation: System.il_generation
34 do
35 check
36 is_reference_at_least: is_reference
37 end
38 Result := System.system_object_class.compiled_class.types.first.static_type_id
39 ensure
40 valid_result: Result > 0
41 end
42
43 implementation_id: INTEGER is
44 -- Return implementation id of `Current'.
45 require
46 il_generation: System.il_generation
47 local
48 cl_type: CL_TYPE_I
49 do
50 cl_type ?= Current
51 if cl_type /= Void then
52 Result := cl_type.associated_class_type.implementation_id
53 else
54 check
55 is_reference_at_least: is_reference
56 end
57 Result := System.system_object_class.compiled_class.types.first.implementation_id
58 end
59 ensure
60 valid_result: Result > 0
61 end
62
63 external_id: INTEGER is
64 -- External type id of `Current' (or `static_type_id' for pure Eiffel type).
65 require
66 il_generation: System.il_generation
67 do
68 Result := System.system_object_class.compiled_class.types.first.external_id
69 ensure
70 valid_result: Result > 0
71 end
72
73 instantiation_in (other: CLASS_TYPE): TYPE_I is
74 -- Instantiation of Current in context of `other' class type.
75 require
76 other_not_void: other /= Void
77 other_is_generic: has_formal implies other.is_generic
78 do
79 Result := Current
80 ensure
81 Result_not_void: Result /= Void
82 end
83
84 complete_instantiation_in (other: CLASS_TYPE): TYPE_I is
85 -- Instantiation of Current in context of `other'. Used
86 -- by `GEN_TYPE_I' to properly instantiate formal generic
87 -- parameters of Current in `other'.
88 require
89 other_not_void: other /= Void
90 other_is_generic: has_formal implies other.is_generic
91 do
92 Result := instantiation_in (other)
93 end
94
95 anchor_instantiation_in (other: CLASS_TYPE): TYPE_I is
96 -- Instantation of `like Current' parts of Current in `other'
97 require
98 other_not_void: other /= Void
99 other_is_expanded: other.is_expanded
100 do
101 Result := Current
102 ensure
103 result_not_void: Result /= Void
104 result_not_anchored: not Result.is_anchored
105 end
106
107 created_in (other: CLASS_TYPE): TYPE_I is
108 -- Resulting type of Current as if it was used to create object in `other'.
109 require
110 other_not_void: other /= Void
111 other_is_generic: has_formal implies other.is_generic
112 do
113 Result := Current
114 ensure
115 Result_not_void: Result /= Void
116 end
117
118 frozen generic_derivation: CL_TYPE_I is
119 -- Precise generic derivation of current type.
120 -- That is to say given a type, it gives the associated TYPE_I
121 -- which can be used to search its associated CLASS_TYPE.
122 do
123 Result ?= internal_generic_derivation (0)
124 ensure
125 cleaned_not_void: Result /= Void
126 end
127
128 c_type: TYPE_C is
129 -- Corresponding C type
130 deferred
131 ensure
132 result_not_void: Result /= Void
133 end
134
135 type_a: TYPE_A is
136 deferred
137 ensure
138 result_not_void: Result /= Void
139 end
140
141 element_type: INTEGER_8 is
142 -- Type of current element. See MD_SIGNATURE_CONSTANTS for
143 -- all possible values.
144 deferred
145 end
146
147 description: ATTR_DESC is
148 -- Descritpion of type for skeletons
149 deferred
150 end
151
152 instantiated_description: ATTR_DESC is
153 -- Descritpion of type for skeletons without any formal generics
154 do
155 Result := description
156 ensure
157 result_not_void: Result /= Void
158 result_without_formal: not Result.has_formal
159 end
160
161 il_type_name (a_prefix: STRING): STRING is
162 -- Name of current class type in IL generation.
163 require
164 in_il_generation: System.il_generation
165 deferred
166 ensure
167 il_type_name_not_void: Result /= Void
168 il_type_name_not_empty: not Result.is_empty
169 end
170
171 generic_il_type_name: STRING is
172 -- Associated name to for naming in generic derivation.
173 require
174 in_il_generation: system.il_generation
175 do
176 Result := name
177 ensure
178 il_type_name_not_void: Result /= Void
179 il_type_name_not_empty: not Result.is_empty
180 end
181
182 name: STRING is
183 -- Name of current class type
184 deferred
185 ensure
186 name_not_void: Result /= Void
187 end
188
189 feature -- Status report
190
191 is_consistent: BOOLEAN is
192 -- Is the associated class still in the system ?
193 do
194 Result := True
195 end
196
197 is_valid (a_class: CLASS_C): BOOLEAN is
198 -- Is Current consistent and valid for `a_class'?
199 require
200 a_class_not_void: a_class /= Void
201 a_class_valid: a_class.is_valid
202 do
203 Result := is_consistent
204 end
205
206 is_void: BOOLEAN is
207 -- Is the type a void one (i.e expression has NO type) ?
208 do
209 -- Do nothing
210 end
211
212 is_natural: BOOLEAN is
213 -- Is the type a NATURAL type ?
214 do
215 -- Do nothing
216 end
217
218 is_integer: BOOLEAN is
219 -- Is the type a INTEGER type ?
220 do
221 -- Do nothing
222 end
223
224 is_external: BOOLEAN is
225 -- Is current type based on an external class?
226 do
227 -- Do nothing
228 end
229
230 is_frozen: BOOLEAN is
231 -- Is current type based on a frozen class?
232 do
233 -- Do nothing
234 end
235
236 is_generated_as_single_type: BOOLEAN is
237 -- Is associated type generated as a single type or as an interface type and
238 -- an implementation type.
239 require
240 il_generation: System.il_generation
241 do
242 end
243
244 is_boolean: BOOLEAN is
245 -- Is the type a boolean type
246 do
247 -- Do nothing
248 end
249
250 is_char: BOOLEAN is
251 -- Is the type a char type?
252 do
253 -- Do nothing
254 end
255
256 is_character_8: BOOLEAN is
257 -- Is the type a CHARACTER_8 type?
258 do
259
260 end
261
262 is_character_32: BOOLEAN is
263 -- Is the type a CHARACTER_32 type?
264 do
265
266 end
267
268 is_real_32: BOOLEAN is
269 -- Is the type a REAL_32 type ?
270 do
271 -- Do nothing
272 end
273
274 is_real_64: BOOLEAN is
275 -- is the type a REAL_64 type ?
276 do
277 -- Do nothing
278 end
279
280 is_reference: BOOLEAN is
281 -- Is the type a reference type ?
282 do
283 -- Do nothing
284 end
285
286 is_formal: BOOLEAN is
287 -- Is the type a formal type ?
288 do
289 -- Do nothing
290 end
291
292 is_multi_constrained: BOOLEAN is
293 -- Is the type a formal type ?
294 do
295 -- Do nothing
296 end
297
298 is_bit: BOOLEAN is
299 -- Is the type a bit type ?
300 do
301 -- Do nothing
302 end
303
304 is_none: BOOLEAN is
305 -- Is the type a none type ?
306 do
307 -- Do nothing
308 end
309
310 is_expanded: BOOLEAN is
311 -- Is the type an expanded/basic one ?
312 do
313 end
314
315 is_basic: BOOLEAN is
316 -- Is the type a basic type ?
317 do
318 -- Do nothing
319 end
320
321 is_true_expanded: BOOLEAN is
322 -- Is type an true expanded one, ie not a basic one?
323 do
324 Result := is_expanded and not is_basic
325 end
326
327 is_separate: BOOLEAN is
328 -- Is the type a separate one ?
329 do
330 -- Do nothing
331 end
332
333 is_feature_pointer: BOOLEAN is
334 -- Is the type a feature pointer one ?
335 do
336 -- Do nothing
337 end
338
339 is_numeric: BOOLEAN is
340 -- is the type a simple numeric one ?
341 do
342 -- Do nothing
343 end
344
345 is_anchored: BOOLEAN is
346 -- Does type contain anchored type?
347 do
348 Result := False
349 end
350
351 is_explicit: BOOLEAN is
352 -- Is type fixed at compile time without anchors or formals?
353 do
354 Result := True
355 end
356
357 is_standalone: BOOLEAN is
358 -- Is type standalone, i.e. does not depend on formal generic or acnhored type?
359 do
360 Result := True
361 end
362
363 has_formal: BOOLEAN is
364 -- Has the type some formal in the first level of structure ?
365 do
366 -- Do nothing
367 end
368
369 has_true_formal: BOOLEAN is
370 -- Has the type some formal in its structure ?
371 do
372 -- Do nothing
373 end
374
375 is_monomorph: BOOLEAN
376 -- Is the current type monomorph?
377 --| This enables static binding.
378 do
379 -- Result := False
380 end
381
382 feature -- Formatting
383
384 dump (buffer: GENERATION_BUFFER) is
385 -- Debug purpose
386 require
387 buffer_exists: buffer /= Void
388 do
389 buffer.put_string (name)
390 end
391
392 feature -- Comparison
393
394 is_identical (other: TYPE_I): BOOLEAN is
395 -- Is `other' identical with Current ?
396 -- Takes true generics into account.
397 require
398 good_argument: other /= Void
399 do
400 Result := same_as (other)
401 end
402
403 same_as (other: TYPE_I): BOOLEAN is
404 -- Is `other' equal to Current ?
405 -- Takes meta generics into account.
406 require
407 good_argument: other /= Void
408 do
409 end
410
411 feature -- Debugging
412
413 trace is
414 -- Debug purpose
415 do
416 io.error.put_string (name)
417 end
418
419 feature -- Code generation
420
421 generate_cecil_value (buffer: GENERATION_BUFFER) is
422 -- Generate type value for cecil.
423 deferred
424 end
425
426 generate_expanded_creation (buffer: GENERATION_BUFFER; target_name: STRING) is
427 -- Generate object associated to current and initializes it.
428 require
429 buffer_not_void: buffer /= Void
430 target_name_not_void: target_name /= Void
431 do
432 end
433
434 generate_expanded_initialization (buffer: GENERATION_BUFFER; target_name: STRING) is
435 -- Initializes object associated to current.
436 require
437 buffer_not_void: buffer /= Void
438 target_name_not_void: target_name /= Void
439 target_name_not_empty: not target_name.is_empty
440 do
441 end
442
443 sk_value: INTEGER is
444 -- Generate SK value associated to the current type.
445 deferred
446 end
447
448 cecil_value: INTEGER is
449 -- Generate type value for cecil (byte_code)
450 do
451 Result := sk_value
452 end
453
454 tuple_code: INTEGER_8 is
455 -- Code for TUPLE type.
456 deferred
457 end
458
459 minimum_interval_value: INTERVAL_VAL_B is
460 -- Minimum value in inspect interval for current type
461 require
462 valid_type: is_integer or else is_natural or else is_char
463 do
464 -- Implementation is provided by descendants that meet precondition
465 ensure
466 result_not_void: Result /= Void
467 end
468
469 maximum_interval_value: INTERVAL_VAL_B is
470 -- Maximum value in inspect interval for current type
471 require
472 valid_type: is_integer or else is_natural or else is_char
473 do
474 -- Implementation is provided by descendants that meet precondition
475 ensure
476 result_not_void: Result /= Void
477 end
478
479 feature -- Array optimization
480
481 conforms_to_array: BOOLEAN is
482 do
483 end
484
485 feature -- Numeric types
486
487 heaviest (other : TYPE_I) : TYPE_I is
488 -- Heaviest of two numeric types
489 do
490 Result := Current
491 end
492
493 feature {NONE} -- Generic conformance
494
495 full_type_byte_code_type_id: INTEGER is
496 -- Associated type ID used in type information byte code.
497 do
498 -- 0 by default
499 end
500
501 make_full_type_byte_code_parameters (ba: BYTE_ARRAY) is
502 -- Generate type information for generic parameters (if any).
503 require
504 ba_attached: ba /= Void
505 do
506 ba.append_short_integer (system.byte_context.current_type.generated_id (False))
507 make_gen_type_byte_code (ba, True)
508 end
509
510 feature -- Generic conformance
511
512 make_full_type_byte_code (ba: BYTE_ARRAY) is
513 -- Append full type info for the current type to `ba'
514 -- following the format for locals, creation expressions, etc.
515 require
516 ba_attached: ba /= Void
517 do
518 ba.append_short_integer (full_type_byte_code_type_id)
519 make_full_type_byte_code_parameters (ba)
520 ba.append_short_integer (-1)
521 end
522
523 make_gen_type_byte_code (ba : BYTE_ARRAY; use_info : BOOLEAN) is
524 -- Put type id's in byte array.
525 -- `use_info' is true iff we generate code for a
526 -- creation instruction.
527 do
528 ba.append_short_integer (generated_id (False))
529 end
530
531 generated_id (final_mode : BOOLEAN) : INTEGER is
532 -- Mode dependent type id - just for convenience
533 do
534 Result := terminator_type -- Invalid type id.
535 check
536 not_called: False
537 end
538 end
539
540 generate_cid (buffer : GENERATION_BUFFER; final_mode, use_info : BOOLEAN) is
541 -- Generate mode dependent sequence of type id's
542 -- separated by commas. `use_info' is true iff
543 -- we generate code for a creation instruction.
544 require
545 valid_file : buffer /= Void
546 do
547 buffer.put_integer (generated_id (final_mode))
548 buffer.put_character (',')
549 end
550
551 generate_cid_array (buffer : GENERATION_BUFFER;
552 final_mode, use_info : BOOLEAN; idx_cnt : COUNTER) is
553 -- Generate mode dependent sequence of type id's
554 -- separated by commas. `use_info' is true iff
555 -- we generate code for a creation instruction.
556 -- 'idx_cnt' holds the index in the array for
557 -- this entry.
558 require
559 valid_file : buffer /= Void
560 valid_counter : idx_cnt /= Void
561 local
562 dummy : INTEGER
563 do
564 generate_cid (buffer, final_mode, use_info)
565
566 -- Increment counter
567 dummy := idx_cnt.next
568 end
569
570 generate_cid_init (buffer : GENERATION_BUFFER;
571 final_mode, use_info : BOOLEAN; idx_cnt : COUNTER) is
572 -- Generate mode dependent initialization of
573 -- cid array. `use_info' is true iff
574 -- we generate code for a creation instruction.
575 -- 'idx_cnt' holds the index in the array for
576 -- this entry.
577 require
578 valid_file : buffer /= Void
579 valid_counter : idx_cnt /= Void
580 local
581 dummy : INTEGER
582 do
583 -- Only increment counter.
584 dummy := idx_cnt.next
585 end
586
587 feature -- Generic conformance for IL
588
589 generate_gen_type_il (il_generator: IL_CODE_GENERATOR; use_info : BOOLEAN) is
590 -- `use_info' is true iff we generate code for a
591 -- creation instruction.
592 require
593 il_generator_not_void: il_generator /= Void
594 do
595 end
596
597 feature {NONE} -- Debug output
598
599 debug_output: STRING is
600 -- Output displayed in debugger.
601 do
602 Result := name
603 end
604
605 feature {TYPE_I} -- Implementation
606
607 internal_generic_derivation (a_level: INTEGER): TYPE_I is
608 -- Precise generic derivation of current type.
609 -- That is to say given a type, it gives the associated TYPE_I
610 -- which can be used to search its associated CLASS_TYPE.
611 do
612 Result := Current
613 ensure
614 cleaned_not_void: Result /= Void
615 end
616
617 indexing
618 copyright: "Copyright (c) 1984-2006, Eiffel Software"
619 license: "GPL version 2 (see http://www.eiffel.com/licensing/gpl.txt)"
620 licensing_options: "http://www.eiffel.com/licensing"
621 copying: "[
622 This file is part of Eiffel Software's Eiffel Development Environment.
623
624 Eiffel Software's Eiffel Development Environment is free
625 software; you can redistribute it and/or modify it under
626 the terms of the GNU General Public License as published
627 by the Free Software Foundation, version 2 of the License
628 (available at the URL listed under "license" above).
629
630 Eiffel Software's Eiffel Development Environment is
631 distributed in the hope that it will be useful, but
632 WITHOUT ANY WARRANTY; without even the implied warranty
633 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
634 See the GNU General Public License for more details.
635
636 You should have received a copy of the GNU General Public
637 License along with Eiffel Software's Eiffel Development
638 Environment; if not, write to the Free Software Foundation,
639 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
640 ]"
641 source: "[
642 Eiffel Software
643 356 Storke Road, Goleta, CA 93117 USA
644 Telephone 805-685-1006, Fax 805-685-6869
645 Website http://www.eiffel.com
646 Customer support http://support.eiffel.com
647 ]"
648
649 end -- class TYPE_I

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23