/[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 1323 - (hide annotations)
Sat Oct 29 18:24:38 1994 UTC (25 years, 3 months ago) by grator
Original Path: trunk/Src/bench/Eiffel/eiffel/genericity/cl_type_i.e
File size: 4437 byte(s)
`dump' generates a standard string (classes in upper case)

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 1323 local
126     s: STRING
127 grator 18 do
128     if is_expanded then
129     file.putstring ("expanded ");
130     end;
131 grator 1323 s := clone (base_class.class_name);
132     s.to_upper;
133     file.putstring (s);
134 grator 18 end;
135    
136     associated_class_type: CLASS_TYPE is
137     -- Associated class type
138     local
139 grator 485 types: TYPE_LIST;
140     pos: INTEGER;
141     do
142     if is_expanded then
143     Result := associated_expanded_class_type
144     else
145     types := base_class.types;
146 grator 541 pos := types.index;
147 grator 605 types.compare_references
148 grator 485 types.search (Current);
149     Result := types.item;
150 grator 541 types.go_i_th (pos);
151 grator 485 end;
152     end;
153 grator 18
154     associated_expanded_class_type: CLASS_TYPE is
155     -- Associated expanded class type
156     require
157     is_expanded: is_expanded
158     do
159     is_expanded := false;
160 grator 485 Result := associated_class_type;
161     is_expanded := true;
162 grator 18 end;
163    
164     type_id: INTEGER is
165     -- Type id of the correponding class type
166     do
167     Result := associated_class_type.type_id;
168     end;
169    
170     expanded_type_id: INTEGER is
171     -- Type id of the corresponding expanded class type
172     do
173     Result := associated_expanded_class_type.type_id
174     end;
175    
176 grator 621 generate_cecil_value (file: INDENT_FILE) is
177 grator 18 -- Generate cecil value
178     do
179     if not is_expanded then
180     file.putstring ("SK_DTYPE");
181     else
182     file.putstring ("SK_EXP + (uint32) ");
183     file.putint (base_id);
184     end;
185     end;
186    
187     hash_code: INTEGER is
188     -- Hash code for current type
189     do
190     Result := Other_code + base_id;
191     end;
192    
193     sk_value: INTEGER is
194     -- Generate SK value associated to the current type.
195     do
196     if not is_expanded then
197     Result := Sk_ref + (type_id - 1);
198     else
199     is_expanded := False;
200     Result := Sk_exp + (type_id - 1);
201     is_expanded := True;
202     end;
203     end;
204    
205 grator 508 cecil_value: INTEGER is
206     do
207     if not is_expanded then
208     Result := Sk_dtype
209     else
210     Result := Sk_exp + base_id
211     end;
212     end;
213    
214 grator 930 feature -- Array optimization
215    
216     conforms_to_array: BOOLEAN is
217     do
218     Result := base_class.conform_to (array_class_c)
219     end;
220    
221     feature {NONE} -- Array optimization
222    
223     array_class_c: CLASS_C is
224     once
225     Result := System.array_class.compiled_class
226     end;
227    
228 grator 1204 feature
229    
230     type_a: CL_TYPE_A is
231     do
232     !!Result
233     Result.set_is_expanded (is_expanded);
234     Result.set_base_type (base_id)
235     end
236    
237 grator 18 end

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23