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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1204 - (hide annotations)
Wed Oct 5 00:16:03 1994 UTC (25 years, 4 months ago) by grator
Original Path: trunk/Src/bench/Eiffel/eiffel/genericity/cl_type_i.e
File size: 4382 byte(s)
array optimization

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23