/[eiffelstudio]/branches/CAT_mono/Src/Eiffel/API/evaluated_type/like_current.e
ViewVC logotype

Contents of /branches/CAT_mono/Src/Eiffel/API/evaluated_type/like_current.e

Parent Directory Parent Directory | Revision Log Revision Log


Revision 69650 - (show annotations)
Tue Jul 24 17:18:14 2007 UTC (12 years, 4 months ago) by juliant
File size: 6732 byte(s)
Added monomorph mark for class types, either "frozen" or "invariant".
First (simple) conformance check for monomorphic types.
1 indexing
2 description:"Actual type like Current."
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
9 LIKE_CURRENT
10
11 inherit
12 LIKE_TYPE_A
13 redefine
14 actual_type, associated_class, conform_to, conformance_type, convert_to,
15 generics, has_associated_class, instantiated_in,
16 is_basic, is_expanded, is_external, is_like_current, is_none, is_reference,
17 meta_type, set_actual_type, type_i, evaluated_type_in_descendant,
18 is_monomorph
19 end
20
21 feature -- Visitor
22
23 process (v: TYPE_A_VISITOR) is
24 -- Process current element.
25 do
26 v.process_like_current (Current)
27 end
28
29 feature -- Properties
30
31 actual_type: LIKE_CURRENT
32 -- Actual type of the anchored type in a given class
33
34 conformance_type: TYPE_A
35 -- Type of the anchored type as specified in `set_actual_type'
36
37 has_associated_class: BOOLEAN is
38 -- Does Current have an associated class?
39 do
40 Result :=
41 conformance_type /= Void and then
42 conformance_type.has_associated_class
43 end
44
45 is_like_current: BOOLEAN is True
46 -- Is the current type an anchored type on Current ?
47
48 is_expanded: BOOLEAN is
49 -- Is type expanded?
50 do
51 if conformance_type /= Void then
52 Result := conformance_type.is_expanded
53 end
54 end
55
56 is_reference: BOOLEAN is
57 -- Is type reference?
58 do
59 if conformance_type /= Void then
60 Result := conformance_type.is_reference
61 end
62 end
63
64 is_external: BOOLEAN is False
65 -- Is type external?
66
67 is_none: BOOLEAN is False
68 -- Is current actual type NONE?
69
70 is_basic: BOOLEAN is False
71 -- Is the current actual type a basic one?
72
73 same_as (other: TYPE_A): BOOLEAN is
74 -- Is the current type the same as `other' ?
75 do
76 Result := other.is_like_current
77 end
78
79 is_monomorph: BOOLEAN is True
80 -- Is the current type monomorph?
81 --| like Current types are always monomorph
82
83 feature -- Access
84
85 associated_class: CLASS_C is
86 -- Associated class
87 do
88 Result := conformance_type.associated_class
89 end
90
91 generics: ARRAY [TYPE_A] is
92 -- Actual generic types
93 do
94 if conformance_type /= Void then
95 Result := conformance_type.generics
96 end
97 end
98
99 feature -- Comparison
100
101 is_equivalent (other: like Current): BOOLEAN is
102 -- Is `other' equivalent to the current object ?
103 do
104 Result := same_as (other)
105 end
106
107 feature -- Output
108
109 dump: STRING is
110 -- Dumped trace
111 local
112 actual_dump: STRING
113 do
114 actual_dump := conformance_type.dump
115 create Result.make (15 + actual_dump.count)
116 Result.append ("[like Current] ")
117 Result.append (actual_dump)
118 end
119
120 ext_append_to (st: TEXT_FORMATTER; c: CLASS_C) is
121 do
122 st.process_symbol_text (ti_L_bracket)
123 st.process_keyword_text (ti_Like_keyword, Void)
124 st.add_space
125 st.process_keyword_text (ti_Current, Void)
126 st.process_symbol_text (ti_R_bracket)
127 st.add_space
128 conformance_type.ext_append_to (st, c)
129 end
130
131 feature {COMPILER_EXPORTER} -- Primitives
132
133 set_actual_type (a: TYPE_A) is
134 -- Assign `a' to `original_actual_type'.
135 do
136 conformance_type := a
137 actual_type := Current
138 end
139
140 instantiation_in (type: TYPE_A; written_id: INTEGER): TYPE_A is
141 -- Instantiation of Current in the context of `class_type',
142 -- assuming that Current is written in class of id `written_id'.
143 do
144 -- Special cases for calls on a target which is a manifest integer
145 -- that might be compatible with _8 or _16. The returned
146 -- `actual_type' should not take into consideration the
147 -- `compatibility_size' of `type', just its intrinsic type.
148 -- Because manifest integers are by default 32 bits, when
149 -- you apply a routine whose result is of type `like Current'
150 -- then it should really be a 32 bits integer. Note that in the
151 -- past we were keeping the size of the manifest integers and the
152 -- following code was accepted:
153 -- i16: INTEGER_16
154 -- i8: INTEGER_8
155 -- i16 := 0x00FF & i8
156 -- Now the code is rejected because target expect an INTEGER_16
157 -- and not an INTEGER, therefore the code needs to be fixed with:
158 -- i16 := (0x00FF).to_integer_16 & i8
159 -- or
160 -- i16 := (0x00FF & i8).to_integer_16
161 Result := type.intrinsic_type
162 end
163
164 instantiated_in (class_type: TYPE_A): TYPE_A is
165 -- Instantiation of Current in the context of `class_type'
166 -- assuming that Current is written in the associated class
167 -- of `class_type'.
168 do
169 Result := class_type
170 end
171
172 evaluated_type_in_descendant (a_ancestor, a_descendant: CLASS_C; a_feature: FEATURE_I): LIKE_CURRENT is
173 do
174 if a_ancestor /= a_descendant then
175 create Result
176 Result.set_actual_type (a_descendant.actual_type)
177 else
178 Result := Current
179 end
180 end
181
182 create_info: CREATE_CURRENT is
183 -- Byte code information for entity type creation
184 once
185 create Result
186 end
187
188 conform_to (other: TYPE_A): BOOLEAN is
189 -- Does `Current' conform to `other'?
190 do
191 Result := other.is_like_current or else conformance_type.conform_to (other.conformance_type)
192 end
193
194 convert_to (a_context_class: CLASS_C; a_target_type: TYPE_A): BOOLEAN is
195 -- Does current convert to `a_target_type' in `a_context_class'?
196 -- Update `last_conversion_info' of AST_CONTEXT.
197 do
198 Result := conformance_type.convert_to (a_context_class, a_target_type)
199 end
200
201 type_i: TYPE_I is
202 -- C type.
203 once
204 create {LIKE_CURRENT_I} Result
205 end
206
207 meta_type: TYPE_I is
208 -- Meta type.
209 do
210 Result := type_i
211 end
212
213 indexing
214 copyright: "Copyright (c) 1984-2006, Eiffel Software"
215 license: "GPL version 2 (see http://www.eiffel.com/licensing/gpl.txt)"
216 licensing_options: "http://www.eiffel.com/licensing"
217 copying: "[
218 This file is part of Eiffel Software's Eiffel Development Environment.
219
220 Eiffel Software's Eiffel Development Environment is free
221 software; you can redistribute it and/or modify it under
222 the terms of the GNU General Public License as published
223 by the Free Software Foundation, version 2 of the License
224 (available at the URL listed under "license" above).
225
226 Eiffel Software's Eiffel Development Environment is
227 distributed in the hope that it will be useful, but
228 WITHOUT ANY WARRANTY; without even the implied warranty
229 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
230 See the GNU General Public License for more details.
231
232 You should have received a copy of the GNU General Public
233 License along with Eiffel Software's Eiffel Development
234 Environment; if not, write to the Free Software Foundation,
235 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
236 ]"
237 source: "[
238 Eiffel Software
239 356 Storke Road, Goleta, CA 93117 USA
240 Telephone 805-685-1006, Fax 805-685-6869
241 Website http://www.eiffel.com
242 Customer support http://support.eiffel.com
243 ]"
244
245 end

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23