/[eiffelstudio]/branches/CAT_mono/Src/framework/parser/AST/types/class_type_as.e
ViewVC logotype

Contents of /branches/CAT_mono/Src/framework/parser/AST/types/class_type_as.e

Parent Directory Parent Directory | Revision Log Revision Log


Revision 69650 - (show annotations)
Tue Jul 24 17:18:14 2007 UTC (12 years, 4 months ago) by juliant
File size: 5942 byte(s)
Added monomorph mark for class types, either "frozen" or "invariant".
First (simple) conformance check for monomorphic types.
1 indexing
2 description: "Node for normal class type. Version for Bench."
3 legal: "See notice at end of class."
4 status: "See notice at end of class."
5 date: "$Date$"
6 revision: "$Revision$"
7
8 class CLASS_TYPE_AS
9
10 inherit
11 TYPE_AS
12 redefine
13 is_equivalent, start_location, end_location,
14 first_token, last_token
15 end
16
17 CLICKABLE_AST
18 redefine
19 is_class, class_name
20 end
21
22 create
23 initialize
24
25 feature {NONE} -- Initialization
26
27 initialize (n: like class_name; g: like generics) is
28 -- Create a new CLASS_TYPE AST node.
29 require
30 n_not_void: n /= Void
31 n_upper: n.name.is_equal (n.name.as_upper)
32 do
33 class_name := n
34 internal_generics := g
35 ensure
36 class_name_set: class_name.name.is_equal (n.name)
37 internal_generics_set: internal_generics = g
38 end
39
40 feature -- Visitor
41
42 process (v: AST_VISITOR) is
43 -- process current element.
44 do
45 v.process_class_type_as (Current)
46 end
47
48 feature -- Attributes
49
50 class_name: ID_AS
51 -- Class type name
52
53 generics: TYPE_LIST_AS is
54 -- Possible generical parameters
55 do
56 if internal_generics = Void or else internal_generics.is_empty then
57 Result := Void
58 else
59 Result := internal_generics
60 end
61 end
62
63 is_class: BOOLEAN is True
64 -- Does the Current AST represent a class?
65
66 is_expanded: BOOLEAN
67 -- Is current type used with `expanded' keyword?
68
69 is_separate: BOOLEAN
70 -- Is current type used with `separate' keyword?
71
72 is_monomorph: BOOLEAN
73 -- Is current type marked as monomorph?
74
75 feature -- Roundtrip
76
77 expanded_keyword: KEYWORD_AS
78 -- Keyword "expanded" associated with this structure.
79
80 separate_keyword: KEYWORD_AS
81 -- Keyword "separate" associated with this structure.
82
83 monomorph_keyword: KEYWORD_AS
84 -- Keyword which marks type as monomorph
85
86 internal_generics: like generics
87 -- Internal possible generical parameters
88
89 feature -- Roundtrip/Token
90
91 first_token (a_list: LEAF_AS_LIST): LEAF_AS is
92 do
93 Result := Precursor (a_list)
94 if Result = Void then
95 if a_list = Void then
96 Result := class_name.first_token (a_list)
97 else
98 if expanded_keyword /= Void then
99 Result := expanded_keyword.first_token (a_list)
100 elseif separate_keyword /= Void then
101 Result := separate_keyword.first_token (a_list)
102 elseif monomorph_keyword /= Void then
103 Result := monomorph_keyword.first_token (a_list)
104 else
105 Result := class_name.first_token (a_list)
106 end
107 end
108 end
109 end
110
111 last_token (a_list: LEAF_AS_LIST): LEAF_AS is
112 do
113 Result := Precursor (a_list)
114 if Result = Void then
115 if a_list = Void then
116 if generics /= Void then
117 Result := generics.last_token (a_list)
118 else
119 Result := class_name.last_token (a_list)
120 end
121 else
122 if internal_generics /= Void then
123 Result := internal_generics.last_token (a_list)
124 else
125 Result := class_name.last_token (a_list)
126 end
127 end
128 end
129 end
130
131 feature -- Comparison
132
133 is_equivalent (other: like Current): BOOLEAN is
134 -- Is `other' equivalent to the current object ?
135 do
136 Result := equivalent (class_name, other.class_name) and then
137 equivalent (generics, other.generics) and then
138 is_expanded = other.is_expanded and then
139 is_monomorph = other.is_monomorph
140 end
141
142 feature {AST_FACTORY, COMPILER_EXPORTER} -- Conveniences
143
144 set_is_expanded (i: like is_expanded; s_as: like expanded_keyword) is
145 -- Set `is_separate' to `i'.
146 do
147 is_expanded := i
148 expanded_keyword := s_as
149 ensure
150 is_expanded_set: is_expanded = i
151 expanded_keyword_set: expanded_keyword = s_as
152 end
153
154 set_is_separate (i: like is_separate; s_as: like separate_keyword) is
155 -- Set `is_separate' to `i'.
156 do
157 is_separate := i
158 separate_keyword := s_as
159 ensure
160 is_separate_set: is_separate = i
161 separate_keyword_set: separate_keyword = s_as
162 end
163
164 set_is_monomorph (i: like is_monomorph; s_as: like monomorph_keyword) is
165 -- Set `is_monomorph' to `i'.
166 do
167 is_monomorph := i
168 monomorph_keyword := s_as
169 ensure
170 is_monomorph_set: is_monomorph = i
171 monomorph_keyword_set: monomorph_keyword = s_as
172 end
173
174 set_class_name (s: like class_name) is
175 -- Assign `s' to `class_name'.
176 do
177 class_name := s
178 end
179
180 dump: STRING is
181 -- Dumped string
182 do
183 create Result.make (class_name.name.count)
184 Result.append (class_name.name)
185 if generics /= Void then
186 from
187 generics.start;
188 Result.append (" [")
189 until
190 generics.after
191 loop
192 Result.append (generics.item.dump)
193 if not generics.islast then
194 Result.append (", ")
195 end
196 generics.forth
197 end
198 Result.append ("]")
199 end
200 end
201
202 indexing
203 copyright: "Copyright (c) 1984-2006, Eiffel Software"
204 license: "GPL version 2 (see http://www.eiffel.com/licensing/gpl.txt)"
205 licensing_options: "http://www.eiffel.com/licensing"
206 copying: "[
207 This file is part of Eiffel Software's Eiffel Development Environment.
208
209 Eiffel Software's Eiffel Development Environment is free
210 software; you can redistribute it and/or modify it under
211 the terms of the GNU General Public License as published
212 by the Free Software Foundation, version 2 of the License
213 (available at the URL listed under "license" above).
214
215 Eiffel Software's Eiffel Development Environment is
216 distributed in the hope that it will be useful, but
217 WITHOUT ANY WARRANTY; without even the implied warranty
218 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
219 See the GNU General Public License for more details.
220
221 You should have received a copy of the GNU General Public
222 License along with Eiffel Software's Eiffel Development
223 Environment; if not, write to the Free Software Foundation,
224 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
225 ]"
226 source: "[
227 Eiffel Software
228 356 Storke Road, Goleta, CA 93117 USA
229 Telephone 805-685-1006, Fax 805-685-6869
230 Website http://www.eiffel.com
231 Customer support http://support.eiffel.com
232 ]"
233
234 end -- class CLASS_TYPE_AS

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23