/[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 541 - (hide annotations)
Wed May 4 14:50:03 1994 UTC (25 years, 9 months ago) by grator
Original Path: trunk/Src/bench/Eiffel/eiffel/genericity/cl_type_i.e
File size: 3723 byte(s)
*** empty log message ***

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.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 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 485 types.search (Current);
98 grator 18 exp.set_class_type (types.item);
99 grator 541 types.go_i_th (pos);
100 grator 18
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     dump (file: UNIX_FILE) is
115     do
116     if is_expanded then
117     file.putstring ("expanded ");
118     end;
119     file.putstring (base_class.class_name);
120     end;
121    
122     associated_class_type: CLASS_TYPE is
123     -- Associated class type
124     local
125 grator 485 types: TYPE_LIST;
126     pos: INTEGER;
127     do
128     if is_expanded then
129     Result := associated_expanded_class_type
130     else
131     types := base_class.types;
132 grator 541 pos := types.index;
133 grator 485 types.search (Current);
134     Result := types.item;
135 grator 541 types.go_i_th (pos);
136 grator 485 end;
137     end;
138 grator 18
139     associated_expanded_class_type: CLASS_TYPE is
140     -- Associated expanded class type
141     require
142     is_expanded: is_expanded
143     do
144     is_expanded := false;
145 grator 485 Result := associated_class_type;
146     is_expanded := true;
147 grator 18 end;
148    
149     type_id: INTEGER is
150     -- Type id of the correponding class type
151     do
152     Result := associated_class_type.type_id;
153     end;
154    
155     expanded_type_id: INTEGER is
156     -- Type id of the corresponding expanded class type
157     do
158     Result := associated_expanded_class_type.type_id
159     end;
160    
161     generate_cecil_value (file: UNIX_FILE) is
162     -- Generate cecil value
163     do
164     if not is_expanded then
165     file.putstring ("SK_DTYPE");
166     else
167     file.putstring ("SK_EXP + (uint32) ");
168     file.putint (base_id);
169     end;
170     end;
171    
172     hash_code: INTEGER is
173     -- Hash code for current type
174     do
175     Result := Other_code + base_id;
176     end;
177    
178     sk_value: INTEGER is
179     -- Generate SK value associated to the current type.
180     do
181     if not is_expanded then
182     Result := Sk_ref + (type_id - 1);
183     else
184     is_expanded := False;
185     Result := Sk_exp + (type_id - 1);
186     is_expanded := True;
187     end;
188     end;
189    
190 grator 508 cecil_value: INTEGER is
191     do
192     if not is_expanded then
193     Result := Sk_dtype
194     else
195     Result := Sk_exp + base_id
196     end;
197     end;
198    
199 grator 18 end

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23