/[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 236 - (hide annotations)
Tue Jun 8 12:09:28 1993 UTC (26 years, 8 months ago) by grator
Original Path: trunk/Src/bench/Eiffel/eiffel/genericity/cl_type_i.e
File size: 3780 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     do
79     Result := Current;
80     end;
81    
82     description: ATTR_DESC is
83     -- Type description for skeletons
84     local
85     exp: EXPANDED_DESC;
86     types: TYPE_LIST;
87     pos: INTEGER;
88     do
89     if is_expanded then
90     !!exp;
91     is_expanded := False;
92    
93     types := base_class.types;
94     pos := types.position;
95     types.search (Current);
96     exp.set_class_type (types.item);
97     types.go (pos);
98    
99     is_expanded := True;
100     Result := exp;
101     else
102     Result := c_type.description;
103     end;
104     end;
105    
106     c_type: TYPE_C is
107     -- Associated C type
108     do
109     Result := Reference_c_type;
110     end;
111    
112     dump (file: UNIX_FILE) is
113     do
114     if is_expanded then
115     file.putstring ("expanded ");
116     end;
117     file.putstring (base_class.class_name);
118     end;
119    
120     associated_class_type: CLASS_TYPE is
121     -- Associated class type
122     local
123     types: TYPE_LIST;
124     pos: INTEGER;
125     do
126     if is_expanded then
127     Result := associated_expanded_class_type
128     else
129     types := base_class.types;
130     pos := types.position;
131     types.search (Current);
132     Result := types.item;
133     types.go (pos);
134     end;
135     end;
136    
137     associated_expanded_class_type: CLASS_TYPE is
138     -- Associated expanded class type
139     require
140     is_expanded: is_expanded
141     do
142     is_expanded := false;
143     Result := associated_class_type;
144     is_expanded := true;
145     end;
146    
147     type_id: INTEGER is
148     -- Type id of the correponding class type
149     do
150     Result := associated_class_type.type_id;
151     end;
152    
153     expanded_type_id: INTEGER is
154     -- Type id of the corresponding expanded class type
155     do
156     Result := associated_expanded_class_type.type_id
157     end;
158    
159     generate_cecil_value (file: UNIX_FILE) is
160     -- Generate cecil value
161     do
162     if not is_expanded then
163     file.putstring ("SK_DTYPE");
164     else
165     file.putstring ("SK_EXP + (uint32) ");
166     file.putint (base_id);
167     end;
168     end;
169    
170     hash_code: INTEGER is
171     -- Hash code for current type
172     do
173     Result := Other_code + base_id;
174     end;
175    
176     sk_value: INTEGER is
177     -- Generate SK value associated to the current type.
178     do
179     if not is_expanded then
180     Result := Sk_ref + (type_id - 1);
181     else
182     is_expanded := False;
183     Result := Sk_exp + (type_id - 1);
184     is_expanded := True;
185     end;
186     end;
187    
188     end

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23