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

Contents of /branches/CAT_mono/Src/Eiffel/eiffel/genericity/formal_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: 7126 byte(s)
enabled more types to store monomorph information
1 indexing
2 description: "Representation of a compiled formal parameter."
3 legal: "See notice at end of class."
4 status: "See notice at end of class."
5 date: "$Date$"
6 revision: "$Revision$"
7
8 class FORMAL_I
9
10 inherit
11 TYPE_I
12 redefine
13 is_formal, is_valid, same_as, has_true_formal, has_formal, instantiation_in,
14 complete_instantiation_in,
15 generated_id, is_explicit, generate_gen_type_il,
16 generate_cid, generate_cid_array, generate_cid_init,
17 make_gen_type_byte_code, is_reference, is_expanded, is_standalone
18 end
19
20 SHARED_BYTE_CONTEXT
21 export
22 {NONE} all
23 end
24
25 create
26 make
27
28 feature {NONE} -- Initialization
29
30 make (is_ref: like is_reference; is_exp: like is_expanded; i: like position) is
31 -- Assign `i' to `position'.
32 require
33 valid_position: i > 0
34 do
35 is_reference := is_ref
36 is_expanded := is_exp
37 position := i
38 ensure
39 is_reference_set: is_reference = is_ref
40 is_expanded_set: is_expanded = is_exp
41 position_set: position = i
42 end
43
44 feature -- Status report
45
46 element_type: INTEGER_8 is
47 -- Formal element type.
48 do
49 -- Before we said that we should not be called, but now there is one case
50 -- where we are called, it is when we try to create a NATIVE_ARRAY [G] where
51 -- G is a formal generic parameter. In this case we actually considered that
52 -- we have for the type system a NATIVE_ARRAY [SYSTEM_OBJECT].
53 Result := {MD_SIGNATURE_CONSTANTS}.element_type_object
54 end
55
56 tuple_code: INTEGER_8 is
57 -- Formal tuple code. Should not be called.
58 do
59 check
60 False
61 end
62 end
63
64 feature -- Access
65
66 position: INTEGER
67 -- Position of the formal in declarations
68
69 is_reference: BOOLEAN
70 -- Is current constrained to be always a reference?
71
72 is_expanded: BOOLEAN
73 -- Is current constrained to be always an expanded?
74
75 is_valid (a_class: CLASS_C): BOOLEAN is
76 -- Is Current consistent and valid for `a_class'?
77 do
78 Result := a_class.is_generic and then position <= a_class.generics.count
79 end
80
81 hash_code: INTEGER is
82 -- Hash code for current type
83 do
84 Result := Other_code + position
85 end
86
87 description: GENERIC_DESC is
88 -- Descritpion of type for skeletons.
89 do
90 create Result
91 Result.set_type_i (Current)
92 end
93
94 feature -- Status report
95
96 is_formal: BOOLEAN is True
97 -- Is the type a formal type ?
98
99 is_explicit: BOOLEAN is False
100
101 is_standalone: BOOLEAN is False
102 -- Is type standalone, i.e. does not depend on formal generic or acnhored type?
103
104 has_true_formal, has_formal: BOOLEAN is True
105 -- Has the type formal in its structure ?
106
107 instantiation_in (other: CLASS_TYPE): TYPE_I is
108 -- Instantiation of Current in context of `other'
109 do
110 Result := other.type.meta_generic.item (position)
111 end
112
113 complete_instantiation_in (other: CLASS_TYPE): TYPE_I is
114 -- Instantiation of Current in context of `other'.
115 do
116 Result := other.type.true_generics.item (position)
117 end
118
119 name: STRING is
120 -- Name of current type.
121 do
122 create Result.make (3)
123 Result.append ("G#")
124 Result.append_integer (position)
125 end
126
127 il_type_name (a_prefix: STRING): STRING is
128 -- Name of current class type.
129 do
130 Result := name
131 end
132
133 type_a: FORMAL_A is
134 -- Associated FORMAL_A object.
135 do
136 create Result.make (is_reference, is_expanded, is_monomorph, position)
137 end
138
139 feature -- Comparison
140
141 same_as (other: TYPE_I): BOOLEAN is
142 -- Is `other' equal to Current ?
143 local
144 other_formal: FORMAL_I
145 do
146 other_formal ?= other
147 Result := other_formal /= Void and then other_formal.position = position and then
148 is_reference = other.is_reference and then is_expanded = other.is_expanded
149 end
150
151 feature -- Generic conformance
152
153 generated_id (final_mode: BOOLEAN): INTEGER is
154 -- Id of a generic formal parameter.
155 do
156 Result := Formal_type
157 end
158
159 generate_cid (buffer: GENERATION_BUFFER; final_mode, use_info: BOOLEAN) is
160 do
161 buffer.put_integer (Formal_type)
162 buffer.put_character (',')
163 buffer.put_integer (position)
164 buffer.put_character (',')
165 end
166
167 make_gen_type_byte_code (ba: BYTE_ARRAY; use_info: BOOLEAN) is
168 do
169 ba.append_short_integer (formal_type)
170 ba.append_short_integer (position)
171 end
172
173 generate_cid_array (buffer: GENERATION_BUFFER; final_mode, use_info: BOOLEAN; idx_cnt: COUNTER) is
174 local
175 dummy: INTEGER
176 do
177 buffer.put_integer (Formal_type)
178 buffer.put_character (',')
179 buffer.put_integer (position)
180 buffer.put_character (',')
181 dummy := idx_cnt.next
182 dummy := idx_cnt.next
183 end
184
185 generate_cid_init (buffer: GENERATION_BUFFER; final_mode, use_info: BOOLEAN; idx_cnt: COUNTER) is
186 local
187 dummy : INTEGER
188 do
189 -- Increment counter
190 dummy := idx_cnt.next
191 dummy := idx_cnt.next
192 end
193
194 feature -- Generic conformance for IL
195
196 generate_gen_type_il (il_generator: IL_CODE_GENERATOR; use_info: BOOLEAN) is
197 -- `use_info' is true iff we generate code for a
198 -- creation instruction.
199 do
200 -- We must be in a generic class otherwise having a formal creation
201 -- does not make sense.
202 check
203 generic_class: context.current_type.base_class.is_generic
204 end
205
206 -- Generate call to feature, defined in every descendant of
207 -- the current generic class, that will
208 -- create the corresponding runtime type associated with formal
209 -- in descendant class.
210 il_generator.generate_type_feature_call (context.current_type.base_class.formal_at_position (position))
211 end
212
213 feature {NONE} -- Code generation
214
215 generate_cecil_value (buffer: GENERATION_BUFFER) is
216 do
217 ensure then
218 False
219 end
220
221 feature {NONE} -- Not applicable
222
223 c_type: TYPE_C is
224 -- Associated C type.
225 do
226 -- FIXME: we should not call it, but in case we have decided that it
227 -- will always return a reference type
228 Result := Reference_c_type
229 end
230
231 sk_value: INTEGER is
232 do
233 ensure then
234 False
235 end
236
237 indexing
238 copyright: "Copyright (c) 1984-2006, Eiffel Software"
239 license: "GPL version 2 (see http://www.eiffel.com/licensing/gpl.txt)"
240 licensing_options: "http://www.eiffel.com/licensing"
241 copying: "[
242 This file is part of Eiffel Software's Eiffel Development Environment.
243
244 Eiffel Software's Eiffel Development Environment is free
245 software; you can redistribute it and/or modify it under
246 the terms of the GNU General Public License as published
247 by the Free Software Foundation, version 2 of the License
248 (available at the URL listed under "license" above).
249
250 Eiffel Software's Eiffel Development Environment is
251 distributed in the hope that it will be useful, but
252 WITHOUT ANY WARRANTY; without even the implied warranty
253 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
254 See the GNU General Public License for more details.
255
256 You should have received a copy of the GNU General Public
257 License along with Eiffel Software's Eiffel Development
258 Environment; if not, write to the Free Software Foundation,
259 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
260 ]"
261 source: "[
262 Eiffel Software
263 356 Storke Road, Goleta, CA 93117 USA
264 Telephone 805-685-1006, Fax 805-685-6869
265 Website http://www.eiffel.com
266 Customer support http://support.eiffel.com
267 ]"
268
269 end -- class FORMAL_I

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23