/[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 18 - (show annotations)
Fri Mar 12 17:44:01 1993 UTC (26 years, 11 months ago) by grator
Original Path: trunk/Src/bench/Eiffel/eiffel/genericity/cl_type_i.e
File size: 3653 byte(s)
Initial revision

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23