/[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 850 - (hide annotations)
Sat Aug 20 01:04:52 1994 UTC (25 years, 6 months ago) by grator
Original Path: trunk/Src/bench/Eiffel/eiffel/genericity/cl_type_i.e
File size: 3977 byte(s)
optimization and then

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     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 grator 236 is_valid: BOOLEAN is
50     -- Is the base class still in the system ?
51     do
52     Result := base_class /= Void;
53     end;
54    
55 grator 18 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.base_id = base_id
70     and then
71 grator 850 other_cl_type.is_expanded = is_expanded
72     and then
73     other_cl_type.meta_generic = Void
74 grator 18 end;
75    
76     instantiation_in (other: GEN_TYPE_I): CL_TYPE_I is
77     -- Instantiation of Current in context of `other'
78 grator 282 require else
79     True
80 grator 18 do
81     Result := Current;
82     end;
83    
84     description: ATTR_DESC is
85     -- Type description for skeletons
86     local
87     exp: EXPANDED_DESC;
88 grator 485 types: TYPE_LIST;
89     pos: INTEGER;
90     do
91 grator 18 if is_expanded then
92     !!exp;
93     is_expanded := False;
94    
95 grator 485 types := base_class.types;
96 grator 541 pos := types.index;
97 grator 605 types.compare_references
98 grator 485 types.search (Current);
99 grator 18 exp.set_class_type (types.item);
100 grator 541 types.go_i_th (pos);
101 grator 18
102     is_expanded := True;
103     Result := exp;
104     else
105     Result := c_type.description;
106     end;
107     end;
108    
109     c_type: TYPE_C is
110     -- Associated C type
111     do
112     Result := Reference_c_type;
113     end;
114    
115 grator 552 append_clickable_signature (a_clickable: CLICK_WINDOW) is
116     do
117     if is_expanded then
118     a_clickable.put_string ("expanded ");
119     end;
120     base_class.append_clickable_signature (a_clickable)
121     end;
122    
123 grator 605 dump (file: FILE) is
124 grator 18 do
125     if is_expanded then
126     file.putstring ("expanded ");
127     end;
128     file.putstring (base_class.class_name);
129     end;
130    
131     associated_class_type: CLASS_TYPE is
132     -- Associated class type
133     local
134 grator 485 types: TYPE_LIST;
135     pos: INTEGER;
136     do
137     if is_expanded then
138     Result := associated_expanded_class_type
139     else
140     types := base_class.types;
141 grator 541 pos := types.index;
142 grator 605 types.compare_references
143 grator 485 types.search (Current);
144     Result := types.item;
145 grator 541 types.go_i_th (pos);
146 grator 485 end;
147     end;
148 grator 18
149     associated_expanded_class_type: CLASS_TYPE is
150     -- Associated expanded class type
151     require
152     is_expanded: is_expanded
153     do
154     is_expanded := false;
155 grator 485 Result := associated_class_type;
156     is_expanded := true;
157 grator 18 end;
158    
159     type_id: INTEGER is
160     -- Type id of the correponding class type
161     do
162     Result := associated_class_type.type_id;
163     end;
164    
165     expanded_type_id: INTEGER is
166     -- Type id of the corresponding expanded class type
167     do
168     Result := associated_expanded_class_type.type_id
169     end;
170    
171 grator 621 generate_cecil_value (file: INDENT_FILE) is
172 grator 18 -- Generate cecil value
173     do
174     if not is_expanded then
175     file.putstring ("SK_DTYPE");
176     else
177     file.putstring ("SK_EXP + (uint32) ");
178     file.putint (base_id);
179     end;
180     end;
181    
182     hash_code: INTEGER is
183     -- Hash code for current type
184     do
185     Result := Other_code + base_id;
186     end;
187    
188     sk_value: INTEGER is
189     -- Generate SK value associated to the current type.
190     do
191     if not is_expanded then
192     Result := Sk_ref + (type_id - 1);
193     else
194     is_expanded := False;
195     Result := Sk_exp + (type_id - 1);
196     is_expanded := True;
197     end;
198     end;
199    
200 grator 508 cecil_value: INTEGER is
201     do
202     if not is_expanded then
203     Result := Sk_dtype
204     else
205     Result := Sk_exp + base_id
206     end;
207     end;
208    
209 grator 18 end

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23