/[eiffelstudio]/branches/CAT_mono/Src/Eiffel/eiffel/interface/special_b.e
ViewVC logotype

Contents of /branches/CAT_mono/Src/Eiffel/eiffel/interface/special_b.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: 9215 byte(s)
enabled more types to store monomorph information
1 indexing
2 description: "Compiled class SPECIAL"
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 SPECIAL_B
9
10 inherit
11 EIFFEL_CLASS_C
12 redefine
13 check_validity, new_type, is_special
14 end
15
16 SPECIAL_CONST
17
18 create
19 make
20
21 feature -- Validity
22
23 check_validity is
24 -- Check validity of class SPECIAL
25 local
26 special_error: SPECIAL_ERROR
27 feat_table: FEATURE_TABLE
28 item_feature, put_feature, make_feature: FEATURE_I
29 done: BOOLEAN
30 do
31 -- Check if class has one formal generic parameter
32 if generics = Void or else generics.count /= 1 or else not is_frozen then
33 create special_error.make (special_case_1, Current)
34 Error_handler.insert_error (special_error)
35 end
36
37 feat_table := feature_table
38
39 -- Check if class has a feature make (INTEGER)
40 make_feature := feat_table.item_id (names_heap.make_name_id)
41 if
42 make_feature = Void
43 or else not (make_feature.written_in = class_id)
44 or else not make_feature.same_signature (make_signature)
45 then
46 create special_error.make (special_case_2, Current)
47 Error_handler.insert_error (special_error)
48 end
49
50 -- Check that `make' is indeed a creation procedure
51 if creators = Void then
52 create special_error.make (special_case_3, Current)
53 Error_handler.insert_error (special_error)
54 else
55 from
56 creators.start
57 until
58 done or else creators.after
59 loop
60 done := creators.key_for_iteration.
61 is_equal (names_heap.item (Names_heap.make_name_id))
62 creators.forth
63 end
64 if not done then
65 create special_error.make (special_case_3, Current)
66 Error_handler.insert_error (special_error)
67 end
68 end
69
70 -- Check if class has a feature item (INTEGER): G#1
71 item_feature := feat_table.item_id (names_heap.item_name_id)
72 if item_feature = Void
73 or else not (item_feature.written_in = class_id)
74 or else not item_feature.same_signature (item_signature)
75 then
76 create special_error.make (special_case_4, Current)
77 Error_handler.insert_error (special_error)
78 end
79
80 -- Check if class has a feature put (G#1, INTEGER)
81 put_feature := feat_table.item_id (names_heap.put_name_id)
82 if put_feature = Void
83 or else not (put_feature.written_in = class_id)
84 or else not put_feature.same_signature (put_signature)
85 then
86 create special_error.make (special_case_5, Current)
87 Error_handler.insert_error (special_error)
88 end
89 end
90
91 feature -- Typing
92
93 new_type (data: CL_TYPE_I): SPECIAL_CLASS_TYPE is
94 -- New class type for class SPECIAL
95 local
96 l_data: GEN_TYPE_I
97 do
98 l_data ?= data
99 check
100 l_data_not_void: l_data /= Void
101 end
102 create Result.make (l_data)
103 -- Unlike the parent version, each time a new SPECIAL derivation
104 -- is added we need to freeze so that we call the right version of
105 -- `put' and `item'.
106 system.request_freeze
107 if already_compiled then
108 -- Melt all the code written in the associated class of the new class type
109 melt_all
110 end
111 end
112
113 feature -- Status report
114
115 is_special: BOOLEAN is True
116 -- Is class SPECIAL?
117
118 feature -- Code generation
119
120 generate_dynamic_types (buffer: GENERATION_BUFFER) is
121 -- Generate dynamic types of type classes available in the system
122 local
123 class_type: CLASS_TYPE
124 gen_type: GEN_TYPE_I
125 gen_param: TYPE_I
126 int_i: INTEGER_I
127 nat_i: NATURAL_I
128 char_i: CHAR_I
129 dtype, char_dtype, uint8_dtype, uint16_dtype,
130 uint32_dtype, uint64_dtype, int8_dtype, int16_dtype,
131 int32_dtype, int64_dtype, wchar_dtype,
132 real32_dtype, real64_dtype,
133 pointer_dtype, boolean_dtype, ref_dtype: INTEGER
134 do
135 from
136 char_dtype := -1
137 wchar_dtype := -1
138 uint8_dtype := -1
139 uint16_dtype := -1
140 uint32_dtype := -1
141 uint64_dtype := -1
142 int8_dtype := -1
143 int16_dtype := -1
144 int32_dtype := -1
145 int64_dtype := -1
146 real32_dtype := -1
147 real64_dtype := -1
148 boolean_dtype := -1
149 pointer_dtype := -1
150 ref_dtype := -1
151 types.start
152 until
153 types.after
154 loop
155 class_type := types.item
156 dtype := class_type.type_id - 1
157 gen_type ?= class_type.type
158 gen_param := gen_type.meta_generic.item (1)
159 if gen_param.is_char then
160 char_i ?= gen_param
161 if char_i.is_character_32 then
162 wchar_dtype := dtype
163 else
164 char_dtype := dtype
165 end
166 elseif gen_param.is_natural then
167 nat_i ?= gen_param
168 inspect nat_i.size
169 when 8 then uint8_dtype := dtype
170 when 16 then uint16_dtype := dtype
171 when 32 then uint32_dtype := dtype
172 when 64 then uint64_dtype := dtype
173 end
174 elseif gen_param.is_integer then
175 int_i ?= gen_param
176 inspect int_i.size
177 when 8 then int8_dtype := dtype
178 when 16 then int16_dtype := dtype
179 when 32 then int32_dtype := dtype
180 when 64 then int64_dtype := dtype
181 end
182 elseif gen_param.is_real_32 then
183 real32_dtype := dtype
184 elseif gen_param.is_real_64 then
185 real64_dtype := dtype
186 elseif gen_param.is_boolean then
187 boolean_dtype := dtype
188 elseif gen_param.is_feature_pointer then
189 pointer_dtype := dtype
190 elseif not gen_param.is_expanded then
191 ref_dtype := dtype
192 end
193 types.forth
194 end
195 buffer.put_string ("%N%Tegc_sp_char = (uint32)")
196 buffer.put_integer (char_dtype)
197 buffer.put_string (";%N%Tegc_sp_wchar = (uint32)")
198 buffer.put_integer (wchar_dtype)
199 buffer.put_string (";%N%Tegc_sp_bool = (uint32)")
200 buffer.put_integer (boolean_dtype)
201 buffer.put_string (";%N%Tegc_sp_uint8 = (uint32)")
202 buffer.put_integer (uint8_dtype)
203 buffer.put_string (";%N%Tegc_sp_uint16 = (uint32)")
204 buffer.put_integer (uint16_dtype)
205 buffer.put_string (";%N%Tegc_sp_uint32 = (uint32)")
206 buffer.put_integer (uint32_dtype)
207 buffer.put_string (";%N%Tegc_sp_uint64 = (uint32)")
208 buffer.put_integer (uint64_dtype)
209 buffer.put_string (";%N%Tegc_sp_int8 = (uint32)")
210 buffer.put_integer (int8_dtype)
211 buffer.put_string (";%N%Tegc_sp_int16 = (uint32)")
212 buffer.put_integer (int16_dtype)
213 buffer.put_string (";%N%Tegc_sp_int32 = (uint32)")
214 buffer.put_integer (int32_dtype)
215 buffer.put_string (";%N%Tegc_sp_int64 = (uint32)")
216 buffer.put_integer (int64_dtype)
217 buffer.put_string (";%N%Tegc_sp_real32 = (uint32)")
218 buffer.put_integer (real32_dtype)
219 buffer.put_string (";%N%Tegc_sp_real64 = (uint32)")
220 buffer.put_integer (real64_dtype)
221 buffer.put_string (";%N%Tegc_sp_pointer = (uint32)")
222 buffer.put_integer (pointer_dtype)
223 buffer.put_string (";%N%Tegc_sp_ref = (uint32)")
224 buffer.put_integer (ref_dtype)
225 buffer.put_string (";%N")
226 end
227
228 feature {NONE} -- Implementation
229
230 make_signature: DYN_PROC_I is
231 -- Required signature for feature `make' of class SPECIAL
232 local
233 args: FEAT_ARG
234 do
235 create args.make (1)
236 args.put_i_th (Integer_type, 1)
237 create Result
238 Result.set_arguments (args)
239 Result.set_feature_name_id (Names_heap.make_name_id, 0)
240 ensure
241 item_signature_not_void: Result /= Void
242 end
243
244 item_signature: DYN_FUNC_I is
245 -- Required signature for feature `item' of class SPECIAL
246 local
247 args: FEAT_ARG
248 f: FORMAL_A
249 do
250 create args.make (1)
251 args.put_i_th (Integer_type, 1)
252 create Result
253 Result.set_arguments (args)
254 -- TODO: is polymorph ok? (3rd False)
255 create f.make (False, False, False, 1)
256 Result.set_type (f, 0)
257 Result.set_feature_name_id (Names_heap.item_name_id, 0)
258 ensure
259 item_signature_not_void: Result /= Void
260 end
261
262 put_signature: DYN_PROC_I is
263 -- Required signature for feature `put' of class SPECIAL
264 local
265 args: FEAT_ARG
266 f: FORMAL_A
267 do
268 create f.make (False, False, False, 1)
269 create args.make (2)
270 args.put_i_th (f, 1)
271 args.put_i_th (Integer_type, 2)
272 create Result
273 Result.set_arguments (args)
274 Result.set_feature_name_id (Names_heap.put_name_id, 0)
275 ensure
276 put_signature_not_void: Result /= Void
277 end
278
279 indexing
280 copyright: "Copyright (c) 1984-2006, Eiffel Software"
281 license: "GPL version 2 (see http://www.eiffel.com/licensing/gpl.txt)"
282 licensing_options: "http://www.eiffel.com/licensing"
283 copying: "[
284 This file is part of Eiffel Software's Eiffel Development Environment.
285
286 Eiffel Software's Eiffel Development Environment is free
287 software; you can redistribute it and/or modify it under
288 the terms of the GNU General Public License as published
289 by the Free Software Foundation, version 2 of the License
290 (available at the URL listed under "license" above).
291
292 Eiffel Software's Eiffel Development Environment is
293 distributed in the hope that it will be useful, but
294 WITHOUT ANY WARRANTY; without even the implied warranty
295 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
296 See the GNU General Public License for more details.
297
298 You should have received a copy of the GNU General Public
299 License along with Eiffel Software's Eiffel Development
300 Environment; if not, write to the Free Software Foundation,
301 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
302 ]"
303 source: "[
304 Eiffel Software
305 356 Storke Road, Goleta, CA 93117 USA
306 Telephone 805-685-1006, Fax 805-685-6869
307 Website http://www.eiffel.com
308 Customer support http://support.eiffel.com
309 ]"
310
311 end

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23