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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 92516 - (show annotations)
Fri May 3 04:29:22 2013 UTC (6 years, 9 months ago) by jasonw
File size: 7257 byte(s)
<<Merged from trunk#92515.>>
1 note
2 description: "Class for an staticed type on a feature."
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_FEATURE
10
11 inherit
12 LIKE_TYPE_A
13 redefine
14 dispatch_anchors,
15 evaluated_type_in_descendant,
16 initialize_info,
17 is_explicit,
18 is_syntactically_equal,
19 update_dependance
20 end
21
22 SHARED_NAMES_HEAP
23 export
24 {NONE} all
25 end
26
27 SHARED_ENCODING_CONVERTER
28 export
29 {NONE} all
30 end
31
32 create
33 make
34
35 feature -- Initialization and reinitialization
36
37 make (f: FEATURE_I; a_context_class_id: INTEGER)
38 -- Creation
39 require
40 valid_argument: f /= Void
41 a_context_class_id_positive: a_context_class_id > 0
42 do
43 feature_id := f.feature_id
44 routine_id := f.rout_id_set.first
45 feature_name_id := f.feature_name_id
46 class_id := a_context_class_id
47 ensure
48 feature_id_set: feature_id = f.feature_id
49 routine_id_set: routine_id = f.rout_id_set.first
50 feature_name_id_set: feature_name_id = f.feature_name_id
51 class_id_set: class_id = a_context_class_id
52 end
53
54 feature -- Visitor
55
56 process (v: TYPE_A_VISITOR)
57 -- Process current element.
58 do
59 v.process_like_feature (Current)
60 end
61
62 feature -- Properties
63
64 feature_name_id: INTEGER
65 -- Feature name ID of anchor
66
67 class_id: INTEGER;
68 -- Class ID of the class where the anchor is referenced
69
70 feature {INTERNAL_COMPILER_STRING_EXPORTER} -- Properties
71
72 feature_name: STRING
73 -- Final name of anchor.
74 require
75 feature_name_id_set: feature_name_id >= 1
76 do
77 Result := Names_heap.item (feature_name_id)
78 ensure
79 Result_not_void: Result /= Void
80 Result_not_empty: not Result.is_empty
81 end
82
83 feature -- Status Report
84
85 is_explicit: BOOLEAN
86 -- Is type fixed at compile time without anchors or formals?
87 do
88 if system.in_final_mode then
89 initialize_info (shared_create_info)
90 Result := shared_create_info.is_explicit
91 else
92 Result := False
93 end
94 end
95
96 feature {COMPILER_EXPORTER} -- Implementation: Access
97
98 feature_id: INTEGER
99 -- Feature ID of the anchor
100
101 routine_id: INTEGER
102 -- Routine ID of anchor in context of `class_id'.
103
104 feature -- Access
105
106 same_as (other: TYPE_A): BOOLEAN
107 -- Is the current type the same as `other' ?
108 do
109 if
110 attached {LIKE_FEATURE} other as o and then
111 o.routine_id = routine_id and then
112 has_same_marks (o)
113 then
114 -- Compare computed actual types as otherwise they may be left
115 -- from the previous compilation in an invalid state.
116 if attached actual_type as a then
117 Result :=
118 is_valid and then
119 o.is_valid and then
120 attached o.actual_type as oa and then
121 a.same_as (oa)
122 else
123 Result := not attached o.actual_type
124 end
125 end
126 end
127
128 update_dependance (feat_depend: FEATURE_DEPENDANCE)
129 -- Update dependency for Dead Code Removal
130 local
131 a_class: CLASS_C
132 feature_i: FEATURE_I
133 do
134 -- we must had a dependance to the anchor feature
135 a_class := System.class_of_id (class_id)
136 feature_i := a_class.feature_table.item_id (feature_name_id)
137 feat_depend.extend_depend_unit_with_level (class_id, feature_i, 0)
138 end
139
140 feature -- Generic conformance
141
142 initialize_info (an_info: like shared_create_info)
143 do
144 -- FIXME: Should we use `make' or just `set_info'?
145 an_info.make (feature_id, routine_id)
146 end
147
148 create_info: CREATE_FEAT
149 do
150 create Result.make (feature_id, routine_id)
151 end
152
153 shared_create_info: CREATE_FEAT
154 once
155 create Result
156 end
157
158 feature -- IL code generation
159
160 dispatch_anchors (a_context_class: CLASS_C)
161 -- <Precursor>
162 do
163 a_context_class.extend_type_set (routine_id)
164 end
165
166 feature -- Output
167
168 dump: STRING
169 -- Dumped trace
170 local
171 s: STRING
172 do
173 s := actual_type.dump
174 create Result.make (20 + s.count)
175 Result.append_character ('[')
176 dump_marks (Result)
177 Result.append ("like " + feature_name +"] ")
178 Result.append (s)
179 end
180
181 ext_append_to (a_text_formatter: TEXT_FORMATTER; a_context_class: CLASS_C)
182 -- <Precursor>
183 local
184 ec: CLASS_C
185 l_feat: E_FEATURE
186 l_full_feat_name: STRING_32
187 do
188 ec := Eiffel_system.class_of_id (class_id)
189 a_text_formatter.process_symbol_text ({SHARED_TEXT_ITEMS}.ti_l_bracket)
190 ext_append_marks (a_text_formatter)
191 a_text_formatter.process_keyword_text ({SHARED_TEXT_ITEMS}.ti_like_keyword, Void)
192 a_text_formatter.add_space
193 if ec.has_feature_table then
194 l_feat := ec.feature_with_name (feature_name)
195 end
196 l_full_feat_name := encoding_converter.utf8_to_utf32 (feature_name)
197 if l_feat /= Void then
198 a_text_formatter.add_feature (l_feat, l_full_feat_name)
199 else
200 a_text_formatter.add_feature_name (l_full_feat_name, ec)
201 end
202 a_text_formatter.process_symbol_text ({SHARED_TEXT_ITEMS}.ti_r_bracket)
203 a_text_formatter.add_space
204 if is_valid then
205 actual_type.ext_append_to (a_text_formatter, a_context_class)
206 end
207 end
208
209 feature -- Primitives
210
211 evaluated_type_in_descendant (a_ancestor, a_descendant: CLASS_C; a_feature: FEATURE_I): LIKE_FEATURE
212 local
213 l_anchor: FEATURE_I
214 do
215 if a_ancestor /= a_descendant then
216 l_anchor := a_descendant.feature_of_rout_id (routine_id)
217 check l_anchor_not_void: l_anchor /= Void end
218 create Result.make (l_anchor, a_descendant.class_id)
219 Result.set_actual_type (l_anchor.type.actual_type)
220 Result.set_marks_from (Current)
221 else
222 Result := Current
223 end
224 end
225
226 feature -- Comparison
227
228 is_equivalent (other: like Current): BOOLEAN
229 -- Is `other' equivalent to the current object ?
230 do
231 Result := routine_id = other.routine_id and then
232 equivalent (actual_type, other.actual_type) and then
233 has_same_marks (other)
234 end
235
236 is_syntactically_equal (other: TYPE_A): BOOLEAN
237 -- <Precursor>
238 do
239 if attached {like Current} other then
240 Result := same_as (other)
241 elseif attached {UNEVALUATED_LIKE_TYPE} other as o then
242 Result := feature_name_id = o.anchor_name_id and then has_same_marks (o)
243 end
244 end
245
246 note
247 copyright: "Copyright (c) 1984-2013, Eiffel Software"
248 license: "GPL version 2 (see http://www.eiffel.com/licensing/gpl.txt)"
249 licensing_options: "http://www.eiffel.com/licensing"
250 copying: "[
251 This file is part of Eiffel Software's Eiffel Development Environment.
252
253 Eiffel Software's Eiffel Development Environment is free
254 software; you can redistribute it and/or modify it under
255 the terms of the GNU General Public License as published
256 by the Free Software Foundation, version 2 of the License
257 (available at the URL listed under "license" above).
258
259 Eiffel Software's Eiffel Development Environment is
260 distributed in the hope that it will be useful, but
261 WITHOUT ANY WARRANTY; without even the implied warranty
262 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
263 See the GNU General Public License for more details.
264
265 You should have received a copy of the GNU General Public
266 License along with Eiffel Software's Eiffel Development
267 Environment; if not, write to the Free Software Foundation,
268 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
269 ]"
270 source: "[
271 Eiffel Software
272 5949 Hollister Ave., Goleta, CA 93117 USA
273 Telephone 805-685-1006, Fax 805-685-6869
274 Website http://www.eiffel.com
275 Customer support http://support.eiffel.com
276 ]"
277
278 end

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23