/[eiffelstudio]/vendor/gobosoft.com/gobo/4.0d/library/tools/src/eiffel/compilation/et_identifier_type_resolver.e
ViewVC logotype

Contents of /vendor/gobosoft.com/gobo/4.0d/library/tools/src/eiffel/compilation/et_identifier_type_resolver.e

Parent Directory Parent Directory | Revision Log Revision Log


Revision 98698 - (show annotations)
Mon May 9 13:53:54 2016 UTC (3 years, 5 months ago) by manus
File size: 5072 byte(s)
Update 4.0d version with changes in Gobo from 2016/05/09

1 note
2
3 description:
4
5 "Eiffel identifier type resolvers"
6
7 library: "Gobo Eiffel Tools Library"
8 copyright: "Copyright (c) 2003-2016, Eric Bezault and others"
9 license: "MIT License"
10 date: "$Date$"
11 revision: "$Revision$"
12
13 class ET_IDENTIFIER_TYPE_RESOLVER
14
15 inherit
16
17 ET_CLASS_SUBPROCESSOR
18
19 ET_AST_NULL_PROCESSOR
20 undefine
21 make
22 redefine
23 process_class,
24 process_class_type,
25 process_like_feature,
26 process_qualified_like_braced_type,
27 process_qualified_like_type,
28 process_tuple_type
29 end
30
31 create
32
33 make
34
35 feature -- Access
36
37 current_feature: detachable ET_FEATURE
38 -- Feature where the type appears;
39 -- Void if the type does not appear in a feature
40
41 feature -- Type resolving
42
43 resolve_type (a_type: ET_TYPE; a_feature: detachable ET_FEATURE; a_class: ET_CLASS)
44 -- Resolve identifiers (such as 'like identifier') in type `a_type'
45 -- when it appears in `a_feature' in `a_class'. Do not try to resolve
46 -- qualified anchored types. This is done after the
47 -- features of the corresponding classes have been
48 -- flattened.
49 -- Set `has_fatal_error' if a fatal error occurred.
50 require
51 a_type_not_void: a_type /= Void
52 a_feature_registered: a_feature /= Void implies a_feature.is_registered
53 a_class_not_void: a_class /= Void
54 a_class_preparsed: a_class.is_preparsed
55 local
56 old_feature: detachable ET_FEATURE
57 old_class: ET_CLASS
58 do
59 has_fatal_error := False
60 old_feature := current_feature
61 current_feature := a_feature
62 old_class := current_class
63 current_class := a_class
64 a_type.process (Current)
65 current_class := old_class
66 current_feature := old_feature
67 end
68
69 feature {NONE} -- Type resolving
70
71 resolve_like_feature (a_type: ET_LIKE_FEATURE)
72 -- Resolve 'like identifier' type.
73 -- Set `has_fatal_error' if a fatal error occurred.
74 require
75 a_type_not_void: a_type /= Void
76 local
77 l_name: ET_FEATURE_NAME
78 l_index: INTEGER
79 resolved: BOOLEAN
80 do
81 has_fatal_error := False
82 l_name := a_type.name
83 if attached current_class.named_query (l_name) as l_query then
84 -- This is a 'like feature'.
85 a_type.resolve_like_feature (l_query)
86 resolved := True
87 elseif attached current_feature as l_current_feature then
88 -- This has to be a 'like argument', otherwise this is an error.
89 -- Note that 'like argument' is not a valid construct in ECMA Eiffel.
90 -- This is supported here for backward compatibility.
91 if attached {ET_IDENTIFIER} l_name as l_argument_name then
92 if attached l_current_feature.arguments as args then
93 l_index := args.index_of (l_argument_name)
94 if l_index /= 0 then
95 l_argument_name.set_seed (l_index)
96 l_argument_name.set_argument (True)
97 a_type.resolve_like_argument (l_current_feature)
98 resolved := True
99 end
100 end
101 end
102 end
103 if not resolved then
104 set_fatal_error
105 if attached current_feature as l_current_feature then
106 error_handler.report_vtat1b_error (current_class, l_current_feature, a_type)
107 else
108 error_handler.report_vtat1a_error (current_class, a_type)
109 end
110 end
111 end
112
113 resolve_qualified_like_identifier (a_type: ET_QUALIFIED_LIKE_IDENTIFIER)
114 -- Resolve 'identifier' in 'like identifier.b'
115 -- and 'like {like identifier}.b'.
116 -- Set `has_fatal_error' if a fatal error occurred.
117 require
118 a_type_not_void: a_type /= Void
119 do
120 resolve_type (a_type.target_type, current_feature, current_class)
121 end
122
123 resolve_actual_parameters (a_parameters: ET_ACTUAL_PARAMETERS)
124 -- Resolve the actual parameter types.
125 -- Set `has_fatal_error' if a fatal error occurred.
126 require
127 a_parameters_not_void: a_parameters /= Void
128 local
129 i, nb: INTEGER
130 had_error: BOOLEAN
131 do
132 has_fatal_error := False
133 nb := a_parameters.count
134 from i := 1 until i > nb loop
135 resolve_type (a_parameters.type (i), current_feature, current_class)
136 if has_fatal_error then
137 had_error := True
138 end
139 i := i + 1
140 end
141 reset_fatal_error (had_error)
142 end
143
144 feature {ET_AST_NODE} -- Type processing
145
146 process_class (a_type: ET_CLASS)
147 -- Process `a_type'.
148 do
149 process_class_type (a_type)
150 end
151
152 process_class_type (a_type: ET_CLASS_TYPE)
153 -- Process `a_type'.
154 do
155 if attached a_type.actual_parameters as l_parameters then
156 resolve_actual_parameters (l_parameters)
157 end
158 end
159
160 process_like_feature (a_type: ET_LIKE_FEATURE)
161 -- Process `a_type'.
162 do
163 resolve_like_feature (a_type)
164 end
165
166 process_qualified_like_braced_type (a_type: ET_QUALIFIED_LIKE_BRACED_TYPE)
167 -- Process `a_type'.
168 do
169 resolve_qualified_like_identifier (a_type)
170 end
171
172 process_qualified_like_type (a_type: ET_QUALIFIED_LIKE_TYPE)
173 -- Process `a_type'.
174 do
175 resolve_qualified_like_identifier (a_type)
176 end
177
178 process_tuple_type (a_type: ET_TUPLE_TYPE)
179 -- Process `a_type'.
180 do
181 if attached a_type.actual_parameters as l_parameters then
182 resolve_actual_parameters (l_parameters)
183 end
184 end
185
186 invariant
187
188 current_feature_registered: attached current_feature as l_current_feature implies l_current_feature.is_registered
189
190 end

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23