PageRenderTime 24ms CodeModel.GetById 12ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/src/tools/semantics/types/impl/liberty_known_type.e

http://github.com/tybor/Liberty
Specman e | 243 lines | 185 code | 38 blank | 20 comment | 4 complexity | 5d4245e303c4892bf59670a1cfcc45f9 MD5 | raw file
  1-- This file is part of Liberty Eiffel.
  2--
  3-- Liberty Eiffel is free software: you can redistribute it and/or modify
  4-- it under the terms of the GNU General Public License as published by
  5-- the Free Software Foundation, version 3 of the License.
  6--
  7-- Liberty Eiffel is distributed in the hope that it will be useful,
  8-- but WITHOUT ANY WARRANTY; without even the implied warranty of
  9-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 10-- GNU General Public License for more details.
 11--
 12-- You should have received a copy of the GNU General Public License
 13-- along with Liberty Eiffel.  If not, see <http://www.gnu.org/licenses/>.
 14--
 15deferred class LIBERTY_KNOWN_TYPE
 16   --
 17   -- A known type. May be either LIBERTY_ACTUAL_TYPE or LIBERTY_VOID_TYPE.
 18   --
 19
 20inherit
 21   LIBERTY_TYPE
 22      export {LIBERTY_TYPE_LISTENER, LIBERTY_TYPE}
 23         add_listener, has_listener
 24      undefine
 25         mark_reachable_code, add_listener
 26      end
 27
 28feature {ANY}
 29   current_entity: LIBERTY_CURRENT is
 30      deferred
 31      end
 32
 33   is_known: BOOLEAN is True
 34
 35   file: FIXED_STRING is
 36      deferred
 37      end
 38
 39   hash_code: INTEGER is
 40      deferred
 41      end
 42
 43   is_obsolete: BOOLEAN is
 44      deferred
 45      end
 46
 47   cluster: LIBERTY_CLUSTER is
 48      deferred
 49      end
 50
 51   name: FIXED_STRING is
 52      deferred
 53      end
 54
 55   parameters: TRAVERSABLE[LIBERTY_TYPE] is
 56      deferred
 57      end
 58
 59   full_name: FIXED_STRING is
 60      local
 61         buffer: STRING
 62      do
 63         if full_name_memory /= Void then
 64            Result := full_name_memory
 65         else
 66            buffer := full_name_pool.new
 67            full_name_in(buffer)
 68            Result := buffer.intern
 69            full_name_memory := Result
 70            full_name_pool.recycle(buffer)
 71         end
 72      end
 73
 74   is_deferred: BOOLEAN is
 75      require
 76         is_runtime_category_set
 77      deferred
 78      end
 79
 80   is_expanded: BOOLEAN is
 81      require
 82         is_runtime_category_set
 83      deferred
 84      end
 85
 86   is_separate: BOOLEAN is
 87      require
 88         is_runtime_category_set
 89      deferred
 90      end
 91
 92   is_reference: BOOLEAN is
 93      require
 94         is_runtime_category_set
 95      deferred
 96      end
 97
 98   is_runtime_category_set: BOOLEAN is
 99      deferred
100      end
101
102   the_invariant: LIBERTY_INVARIANT is
103      deferred
104      end
105
106   has_feature (a_feature_name: LIBERTY_FEATURE_NAME): BOOLEAN is
107      deferred
108      end
109
110   feature_definition (a_feature_name: LIBERTY_FEATURE_NAME): LIBERTY_FEATURE_DEFINITION is
111      require
112         has_feature(a_feature_name)
113      deferred
114      end
115
116   specialized_in (a_type: LIBERTY_ACTUAL_TYPE): like Current is
117      do
118         Result := Current
119      end
120
121   accept (visitor: LIBERTY_TYPE_VISITOR) is
122      deferred
123      end
124
125feature {ANY}
126   debug_display (o: OUTPUT_STREAM; show_features: BOOLEAN) is
127      deferred
128      end
129
130feature {LIBERTY_KNOWN_TYPE}
131   full_name_in (buffer: STRING) is
132      deferred
133      end
134
135   same_base_class_as (other: LIBERTY_ACTUAL_TYPE): BOOLEAN is
136      require
137         other /= Void
138      deferred
139      end
140
141feature {ANY} -- Inheritance
142   is_conform_to (other: LIBERTY_KNOWN_TYPE): BOOLEAN is
143      require
144         other /= Void
145      deferred
146      ensure
147         Result implies is_child_of(other)
148      end
149
150   is_child_of (other: LIBERTY_KNOWN_TYPE): BOOLEAN is
151      require
152         other /= Void
153      do
154         Result := is_conform_to(other) or else is_non_conformant_child_of(other)
155      end
156
157   is_non_conformant_child_of (other: LIBERTY_KNOWN_TYPE): BOOLEAN is
158      require
159         other /= Void
160      deferred
161      ensure
162         Result implies is_child_of(other)
163      end
164
165   common_conformant_parent_with (other: LIBERTY_KNOWN_TYPE): LIBERTY_KNOWN_TYPE is
166      require
167         other /= Void
168      do
169         if other = Current then
170            Result := Current
171         elseif other.is_conform_to(Current) then
172            Result := Current
173         elseif is_conform_to(other) then
174            Result := other
175         else
176            Result := common_parent(other)
177            if Result = Void then
178               --| *** TODO: check if the symmetric lookup is mandatory
179               Result := other.common_parent(Current)
180            end
181         end
182      end
183
184   converts_to (target_type: LIBERTY_KNOWN_TYPE): BOOLEAN is
185      require
186         target_type /= Void
187      deferred
188      end
189
190   do_convert (target_type: LIBERTY_ACTUAL_TYPE; a_converter: LIBERTY_TYPE_CONVERTER) is
191      require
192         target_type /= Void
193         converts_to(target_type)
194         a_converter /= Void
195      deferred
196      end
197
198feature {ANY} -- Representation
199   out_in_tagged_out_memory is
200      do
201         full_name_in(tagged_out_memory)
202      end
203
204feature {LIBERTY_KNOWN_TYPE}
205   common_parent (other: LIBERTY_KNOWN_TYPE): LIBERTY_KNOWN_TYPE is
206         -- To implement `common_conformant_parent_with'.
207         -- Conformant common parent lookup.
208      require
209         not_trivial: Current /= other and then not is_conform_to(other) and then not other.is_conform_to(Current)
210      deferred
211      end
212
213feature {LIBERTY_TYPE_BUILDER}
214   has_no_parents: BOOLEAN is
215      deferred
216      end
217
218feature {LIBERTY_UNIVERSE, LIBERTY_TYPE_BUILDER}
219   has_loaded_features: BOOLEAN is
220      deferred
221      end
222
223feature {LIBERTY_UNIVERSE}
224   set_reachable (mark: INTEGER) is
225      do
226         mark_reachable_code(mark)
227      end
228
229feature {}
230   full_name_memory: FIXED_STRING
231
232   full_name_pool: STRING_RECYCLING_POOL is
233      once
234         create Result.make
235      end
236
237invariant
238   file /= Void
239   parameters /= Void
240   result_entity /= Void
241   is_known
242
243end -- class LIBERTY_KNOWN_TYPE