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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 89347 - (show annotations)
Fri Aug 10 15:09:25 2012 UTC (7 years, 4 months ago) by jasonw
File size: 6691 byte(s)
<<Merged from trunk#89346.>>
1 note
2 description: "Actual type for simple types."
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 BASIC_A
10
11 inherit
12 CL_TYPE_A
13 undefine
14 c_type
15 redefine
16 instantiation_of,
17 meta_type, is_basic, reference_type,
18 good_generics, internal_is_valid_for_class, error_generics,
19 description, description_with_detachable_type,
20 generic_il_type_name, hash_code, internal_generic_derivation, generic_derivation,
21 internal_same_generic_derivation_as, generate_cecil_value,
22 sk_value, element_type, make, is_processor_attachable_to
23 end
24
25 feature {NONE} -- Initialization
26
27 make (a_class_id: INTEGER)
28 local
29 l_class: like base_class
30 do
31 class_id := a_class_id
32 l_class := system.class_of_id (a_class_id)
33 -- A basic type has always its base class expanded.
34 set_expanded_class_mark
35 end
36
37 feature -- Access
38
39 generic_derivation: CL_TYPE_A
40 -- <Precursor>
41 do
42 Result := internal_generic_derivation (0)
43 end
44
45 feature -- FIXME
46
47 associated_reference_class_type: CLASS_TYPE
48 -- Reference class type of Current
49 do
50 -- We can safely use `Void' here because basic types are not generic.
51 -- FIXME: Manu: check that it works fine for TYPED_POINTER_A.
52 Result := reference_type.associated_class_type (Void)
53 ensure
54 associated_reference_class_type_not_void: Result /= Void
55 end
56
57 feature -- Status Report
58
59 is_basic: BOOLEAN = True
60 -- Is the current actual type a basic one ?
61
62 feature -- Access
63
64 hash_code: INTEGER
65 do
66 Result := c_type.hash_code
67 end
68
69 description: ATTR_DESC
70 -- Type description for skeleton
71 do
72 Result := c_type.new_attribute_description
73 end
74
75 description_with_detachable_type: ATTR_DESC
76 -- Type description for skeleton
77 do
78 Result := c_type.new_attribute_description
79 end
80
81 element_type: INTEGER_8
82 do
83 Result := c_type.element_type
84 end
85
86 sk_value (a_context_type: TYPE_A): NATURAL_32
87 do
88 Result := c_type.sk_value
89 end
90
91 meta_type: BASIC_A
92 -- Associated meta type
93 do
94 Result := Current
95 end
96
97 good_generics: BOOLEAN
98 -- Has the current type the right number of generic types ?
99 do
100 Result := True
101 end
102
103 error_generics: VTUG
104 do
105 end
106
107 feature -- IL code generation
108
109 generic_il_type_name (a_context_type: TYPE_A): STRING
110 -- Associated name to for naming in generic derivation.
111 do
112 Result := base_class.name.twin
113 end
114
115 feature -- C code generation
116
117 metamorphose (reg, value: REGISTRABLE; buffer: GENERATION_BUFFER)
118 -- Generate the metamorphism from simple type to reference and
119 -- put result in register `reg'. The value of the basic type is
120 -- held in `value'.
121 require
122 valid_reg: reg /= Void
123 valid_value: value /= Void
124 valid_file: buffer /= Void
125 local
126 c: CREATE_TYPE
127 buf: like buffer
128 g: GEN_TYPE_A
129 do
130 buf := buffer
131 create c.make (Current)
132 if generics /= Void then
133 g ?= Current
134 buf.put_new_line
135 buf.put_character ('{')
136 buf.indent
137 system.byte_context.generate_gen_type_conversion (g, 0)
138 end
139 buf.put_new_line
140 reg.print_register
141 buf.put_string (" = ")
142 c.generate
143 buf.put_character (';')
144 if generics /= Void then
145 buf.exdent
146 buf.put_new_line
147 buf.put_character ('}')
148 end
149 buf.put_new_line
150 buf.put_character ('*')
151 c_type.generate_access_cast (buffer)
152 reg.print_register
153 buf.put_string (" = ")
154 value.print_register
155 end
156
157 generate_cecil_value (buffer: GENERATION_BUFFER; a_context_type: TYPE_A)
158 do
159 c_type.generate_sk_value (buffer)
160 end
161
162 feature {TYPE_A} -- Helpers
163
164 internal_is_valid_for_class (a_class: CLASS_C): BOOLEAN
165 -- The associated class is still in the system
166 do
167 Result := True
168 end
169
170 internal_generic_derivation (a_level: INTEGER): CL_TYPE_A
171 -- Precise generic derivation of current type.
172 -- That is to say given a type, it gives the associated TYPE_I
173 -- which can be used to search its associated CLASS_TYPE.
174 do
175 -- We do a special thing for basic types, since for generating the code
176 -- which is in their base class, we need a reference and not a basic type.
177 if a_level = 0 and not system.il_generation then
178 create Result.make (class_id)
179 else
180 Result := Current
181 end
182 end
183
184 internal_same_generic_derivation_as (current_type, other: TYPE_A; a_level: INTEGER): BOOLEAN
185 do
186 if a_level = 0 and not system.il_generation then
187 if attached {CL_TYPE_A} other as l_type then
188 Result := class_id = l_type.class_id and then
189 (l_type.declaration_mark /= declaration_mark implies
190 (l_type.is_expanded = is_expanded and then
191 l_type.is_separate = is_separate)) and then
192 l_type.generics = Void
193 end
194 else
195 Result := same_as (other)
196 end
197 end
198
199 feature -- Comparison
200
201 is_processor_attachable_to (other: TYPE_A): BOOLEAN
202 -- <Precursor>
203 do
204 Result := True
205 end
206
207 feature {COMPILER_EXPORTER}
208
209 instantiation_of (type: TYPE_A; a_class_id: INTEGER): TYPE_A
210 -- Insatiation of `type' in s simple type
211 do
212 Result := type.actual_type
213 end
214
215 reference_type: CL_TYPE_A
216 -- Reference counterpart of an expanded type
217 do
218 create Result.make (class_id)
219 if class_declaration_mark = expanded_mark then
220 Result.set_expanded_class_mark
221 end
222 Result.set_reference_mark
223 end
224
225 invariant
226 is_basic: is_basic
227 is_expanded: is_expanded
228
229 note
230 copyright: "Copyright (c) 1984-2011, Eiffel Software"
231 license: "GPL version 2 (see http://www.eiffel.com/licensing/gpl.txt)"
232 licensing_options: "http://www.eiffel.com/licensing"
233 copying: "[
234 This file is part of Eiffel Software's Eiffel Development Environment.
235
236 Eiffel Software's Eiffel Development Environment is free
237 software; you can redistribute it and/or modify it under
238 the terms of the GNU General Public License as published
239 by the Free Software Foundation, version 2 of the License
240 (available at the URL listed under "license" above).
241
242 Eiffel Software's Eiffel Development Environment is
243 distributed in the hope that it will be useful, but
244 WITHOUT ANY WARRANTY; without even the implied warranty
245 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
246 See the GNU General Public License for more details.
247
248 You should have received a copy of the GNU General Public
249 License along with Eiffel Software's Eiffel Development
250 Environment; if not, write to the Free Software Foundation,
251 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
252 ]"
253 source: "[
254 Eiffel Software
255 5949 Hollister Ave., Goleta, CA 93117 USA
256 Telephone 805-685-1006, Fax 805-685-6869
257 Website http://www.eiffel.com
258 Customer support http://support.eiffel.com
259 ]"
260
261 end -- class BASIC_A

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23