/[eiffelstudio]/branches/CAT_mono/Src/Eiffel/eiffel/genericity/cl_type_i.e
ViewVC logotype

Contents of /branches/CAT_mono/Src/Eiffel/eiffel/genericity/cl_type_i.e

Parent Directory Parent Directory | Revision Log Revision Log


Revision 552 - (show annotations)
Wed May 11 11:14:08 1994 UTC (25 years, 9 months ago) by grator
Original Path: trunk/Src/bench/Eiffel/eiffel/genericity/cl_type_i.e
File size: 3923 byte(s)
*** empty log message ***

1 -- Type class
2
3 class CL_TYPE_I
4
5 inherit
6
7 TYPE_I
8 redefine
9 is_reference,
10 is_expanded,
11 is_valid,
12 same_as,
13 c_type,
14 instantiation_in
15 end
16
17 feature
18
19 base_id: INTEGER;
20 -- Base class id of the type class
21
22 is_expanded: BOOLEAN;
23 -- Is the type expanded ?
24
25 set_base_id (c: INTEGER) is
26 -- Assign `c' to `base_id'.
27 do
28 base_id := c;
29 end;
30
31 set_is_expanded (b: BOOLEAN) is
32 -- Assign `b' to `is_expanded'.
33 do
34 is_expanded := b;
35 end;
36
37 meta_generic: META_GENERIC is
38 -- Meta generic array describing the type class
39 do
40 -- No meta generic in non-generic type
41 end;
42
43 base_class: CLASS_C is
44 -- Base class associated to the class type
45 do
46 Result := System.class_of_id (base_id);
47 end;
48
49 is_valid: BOOLEAN is
50 -- Is the base class still in the system ?
51 do
52 Result := base_class /= Void;
53 end;
54
55 is_reference: BOOLEAN is
56 -- Is the type a reference type ?
57 do
58 Result := not is_expanded;
59 end;
60
61 same_as (other: TYPE_I): BOOLEAN is
62 -- Is `other' equal to Current ?
63 local
64 other_cl_type: CL_TYPE_I;
65 do
66 other_cl_type ?= other;
67 Result := other_cl_type /= Void
68 and then
69 other_cl_type.meta_generic = Void
70 and then
71 other_cl_type.base_id = base_id
72 and then
73 other_cl_type.is_expanded = is_expanded;
74 end;
75
76 instantiation_in (other: GEN_TYPE_I): CL_TYPE_I is
77 -- Instantiation of Current in context of `other'
78 require else
79 True
80 do
81 Result := Current;
82 end;
83
84 description: ATTR_DESC is
85 -- Type description for skeletons
86 local
87 exp: EXPANDED_DESC;
88 types: TYPE_LIST;
89 pos: INTEGER;
90 do
91 if is_expanded then
92 !!exp;
93 is_expanded := False;
94
95 types := base_class.types;
96 pos := types.index;
97 types.search (Current);
98 exp.set_class_type (types.item);
99 types.go_i_th (pos);
100
101 is_expanded := True;
102 Result := exp;
103 else
104 Result := c_type.description;
105 end;
106 end;
107
108 c_type: TYPE_C is
109 -- Associated C type
110 do
111 Result := Reference_c_type;
112 end;
113
114 append_clickable_signature (a_clickable: CLICK_WINDOW) is
115 do
116 if is_expanded then
117 a_clickable.put_string ("expanded ");
118 end;
119 base_class.append_clickable_signature (a_clickable)
120 end;
121
122 dump (file: UNIX_FILE) is
123 do
124 if is_expanded then
125 file.putstring ("expanded ");
126 end;
127 file.putstring (base_class.class_name);
128 end;
129
130 associated_class_type: CLASS_TYPE is
131 -- Associated class type
132 local
133 types: TYPE_LIST;
134 pos: INTEGER;
135 do
136 if is_expanded then
137 Result := associated_expanded_class_type
138 else
139 types := base_class.types;
140 pos := types.index;
141 types.search (Current);
142 Result := types.item;
143 types.go_i_th (pos);
144 end;
145 end;
146
147 associated_expanded_class_type: CLASS_TYPE is
148 -- Associated expanded class type
149 require
150 is_expanded: is_expanded
151 do
152 is_expanded := false;
153 Result := associated_class_type;
154 is_expanded := true;
155 end;
156
157 type_id: INTEGER is
158 -- Type id of the correponding class type
159 do
160 Result := associated_class_type.type_id;
161 end;
162
163 expanded_type_id: INTEGER is
164 -- Type id of the corresponding expanded class type
165 do
166 Result := associated_expanded_class_type.type_id
167 end;
168
169 generate_cecil_value (file: UNIX_FILE) is
170 -- Generate cecil value
171 do
172 if not is_expanded then
173 file.putstring ("SK_DTYPE");
174 else
175 file.putstring ("SK_EXP + (uint32) ");
176 file.putint (base_id);
177 end;
178 end;
179
180 hash_code: INTEGER is
181 -- Hash code for current type
182 do
183 Result := Other_code + base_id;
184 end;
185
186 sk_value: INTEGER is
187 -- Generate SK value associated to the current type.
188 do
189 if not is_expanded then
190 Result := Sk_ref + (type_id - 1);
191 else
192 is_expanded := False;
193 Result := Sk_exp + (type_id - 1);
194 is_expanded := True;
195 end;
196 end;
197
198 cecil_value: INTEGER is
199 do
200 if not is_expanded then
201 Result := Sk_dtype
202 else
203 Result := Sk_exp + base_id
204 end;
205 end;
206
207 end

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23