1 |
indexing |
2 |
description: "Representation of an anchored type" |
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 |
LIKE_TYPE_A |
10 |
|
11 |
inherit |
12 |
TYPE_A |
13 |
undefine |
14 |
instantiation_in, same_as |
15 |
redefine |
16 |
actual_type, |
17 |
conformance_type, |
18 |
convert_to, |
19 |
has_associated_class, |
20 |
has_like, |
21 |
instantiated_in, |
22 |
is_basic, |
23 |
is_expanded, |
24 |
is_external, |
25 |
is_like, |
26 |
is_loose, |
27 |
is_none, |
28 |
is_reference, |
29 |
is_valid, |
30 |
is_monomorph, |
31 |
meta_type |
32 |
end |
33 |
|
34 |
feature -- Properties |
35 |
|
36 |
actual_type: TYPE_A |
37 |
-- Actual type of the anchored type in a given class |
38 |
|
39 |
conformance_type: TYPE_A is |
40 |
-- Type which is used to check conformance |
41 |
do |
42 |
-- `conformance_type' has to be called because |
43 |
-- `actual_type' may yield yet another anchored type. |
44 |
Result := actual_type.conformance_type |
45 |
end |
46 |
|
47 |
has_associated_class: BOOLEAN is |
48 |
-- Does Current have an associated class? |
49 |
do |
50 |
Result := actual_type /= Void and then |
51 |
actual_type.has_associated_class |
52 |
end |
53 |
|
54 |
has_like: BOOLEAN is True |
55 |
-- Does the type have anchored type in its definition ? |
56 |
|
57 |
is_like: BOOLEAN is True |
58 |
-- Is the type anchored one ? |
59 |
|
60 |
is_loose: BOOLEAN is True |
61 |
-- Does type depend on formal generic parameters and/or anchors? |
62 |
|
63 |
is_basic: BOOLEAN is |
64 |
-- Is the current actual type a basic one ? |
65 |
do |
66 |
Result := actual_type.is_basic |
67 |
end |
68 |
|
69 |
is_external: BOOLEAN is |
70 |
-- Is current type based on an external class? |
71 |
do |
72 |
Result := actual_type.is_external |
73 |
end |
74 |
|
75 |
is_reference: BOOLEAN is |
76 |
-- Is current actual type a reference one? |
77 |
do |
78 |
Result := actual_type.is_reference |
79 |
end |
80 |
|
81 |
is_expanded: BOOLEAN is |
82 |
-- Is current actual type an expanded one? |
83 |
do |
84 |
Result := actual_type.is_expanded |
85 |
end |
86 |
|
87 |
is_none: BOOLEAN is |
88 |
-- Is current actual type NONE? |
89 |
do |
90 |
Result := actual_type.is_none |
91 |
end |
92 |
|
93 |
is_valid: BOOLEAN is |
94 |
-- Is current type valid? |
95 |
do |
96 |
Result := actual_type /= Void |
97 |
end |
98 |
|
99 |
is_monomorph: BOOLEAN is |
100 |
-- Is the current type monomorph? |
101 |
do |
102 |
if actual_type.is_like then |
103 |
Result := conformance_type.is_monomorph |
104 |
else |
105 |
Result := actual_type.is_monomorph |
106 |
end |
107 |
end |
108 |
|
109 |
same_as (other: TYPE_A): BOOLEAN is |
110 |
-- Is the current type the same as `other' ? |
111 |
deferred |
112 |
end |
113 |
|
114 |
feature -- Access |
115 |
|
116 |
associated_class: CLASS_C is |
117 |
-- Associated class |
118 |
do |
119 |
Result := actual_type.associated_class |
120 |
end |
121 |
|
122 |
feature -- Primitives |
123 |
|
124 |
set_actual_type (a: TYPE_A) is |
125 |
-- Assign `a' to `actual_type'. |
126 |
do |
127 |
actual_type := a |
128 |
end |
129 |
|
130 |
instantiation_in (type: TYPE_A written_id: INTEGER): TYPE_A is |
131 |
-- Instantiation of Current in the context of `class_type', |
132 |
-- assuming that Current is written in class of id `written_id'. |
133 |
deferred |
134 |
end |
135 |
|
136 |
instantiated_in (class_type: TYPE_A): TYPE_A is |
137 |
-- Instantiation of Current in the context of `class_type' |
138 |
-- assuming that Current is written in the associated class |
139 |
-- of `class_type'. |
140 |
local |
141 |
t: like Current |
142 |
do |
143 |
t := twin |
144 |
t.set_actual_type (actual_type.instantiated_in (class_type)) |
145 |
Result := t |
146 |
end |
147 |
|
148 |
conform_to (other: TYPE_A): BOOLEAN is |
149 |
-- Does `actual_type' conform to `other'? |
150 |
do |
151 |
Result := actual_type.conform_to (other.conformance_type) |
152 |
end |
153 |
|
154 |
convert_to (a_context_class: CLASS_C; a_target_type: TYPE_A): BOOLEAN is |
155 |
-- Does current convert to `a_target_type' in `a_context_class'? |
156 |
-- Update `last_conversion_info' of AST_CONTEXT. |
157 |
do |
158 |
Result := actual_type.convert_to (a_context_class, a_target_type) |
159 |
end |
160 |
|
161 |
type_i: TYPE_I is |
162 |
-- Reduced type of `actual_type' |
163 |
local |
164 |
cl_type : CL_TYPE_I |
165 |
do |
166 |
Result := actual_type.type_i |
167 |
cl_type ?= Result |
168 |
|
169 |
if cl_type /= Void and then not cl_type.is_expanded then |
170 |
-- Remember that it's an anchored type, not needed |
171 |
-- when handling expanded types. |
172 |
cl_type.set_cr_info (create_info) |
173 |
end |
174 |
end |
175 |
|
176 |
meta_type: TYPE_I is |
177 |
-- C type for `actual_type' |
178 |
do |
179 |
Result := actual_type.meta_type |
180 |
end |
181 |
|
182 |
indexing |
183 |
copyright: "Copyright (c) 1984-2006, Eiffel Software" |
184 |
license: "GPL version 2 (see http://www.eiffel.com/licensing/gpl.txt)" |
185 |
licensing_options: "http://www.eiffel.com/licensing" |
186 |
copying: "[ |
187 |
This file is part of Eiffel Software's Eiffel Development Environment. |
188 |
|
189 |
Eiffel Software's Eiffel Development Environment is free |
190 |
software; you can redistribute it and/or modify it under |
191 |
the terms of the GNU General Public License as published |
192 |
by the Free Software Foundation, version 2 of the License |
193 |
(available at the URL listed under "license" above). |
194 |
|
195 |
Eiffel Software's Eiffel Development Environment is |
196 |
distributed in the hope that it will be useful, but |
197 |
WITHOUT ANY WARRANTY; without even the implied warranty |
198 |
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
199 |
See the GNU General Public License for more details. |
200 |
|
201 |
You should have received a copy of the GNU General Public |
202 |
License along with Eiffel Software's Eiffel Development |
203 |
Environment; if not, write to the Free Software Foundation, |
204 |
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
205 |
]" |
206 |
source: "[ |
207 |
Eiffel Software |
208 |
356 Storke Road, Goleta, CA 93117 USA |
209 |
Telephone 805-685-1006, Fax 805-685-6869 |
210 |
Website http://www.eiffel.com |
211 |
Customer support http://support.eiffel.com |
212 |
]" |
213 |
|
214 |
end -- class LIKE_TYPE_A |