PageRenderTime 18ms CodeModel.GetById 9ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 1ms

/src/tools/interpreter/builtins/liberty_interpreter_external_builtin_call.e

http://github.com/tybor/Liberty
Specman e | 371 lines | 326 code | 31 blank | 14 comment | 23 complexity | bed166e33b9d0db179185dbf8c5ada68 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--
 15class LIBERTY_INTERPRETER_EXTERNAL_BUILTIN_CALL
 16
 17inherit
 18   LIBERTY_TYPE_VISITOR
 19
 20create {LIBERTY_INTERPRETER_EXTERNAL_BUILTINS}
 21   make
 22
 23feature {LIBERTY_INTERPRETER_EXTERNAL_BUILTINS}
 24   last_call_failed: BOOLEAN
 25
 26   call is
 27      do
 28         last_call_failed := False
 29         builtin_call.definition_type.accept(Current)
 30         if last_call_failed then
 31            last_call_failed := False
 32            builtin_call.target.type.accept(Current)
 33         end
 34      end
 35
 36feature {}
 37   make (a_interpreter: like interpreter; a_builtin_call: like builtin_call) is
 38      require
 39         a_interpreter /= Void
 40         a_builtin_call /= Void
 41      do
 42         interpreter := a_interpreter
 43         builtin_call := a_builtin_call
 44      ensure
 45         interpreter = a_interpreter
 46         builtin_call = a_builtin_call
 47      end
 48
 49   interpreter: LIBERTY_INTERPRETER
 50   builtin_call: LIBERTY_INTERPRETER_FEATURE_CALL
 51
 52feature {LIBERTY_UNIVERSE}
 53   visit_type_any (type: LIBERTY_ACTUAL_TYPE) is
 54      local
 55         ret: LIBERTY_INTERPRETER_OBJECT
 56         type_any_builtins: LIBERTY_INTERPRETER_EXTERNAL_TYPE_ANY_BUILTINS
 57      do
 58         create type_any_builtins.make(interpreter)
 59         ret := type_any_builtins.call(builtin_call)
 60         if type_any_builtins.last_call_failed then
 61            last_call_failed := True
 62         else
 63            builtin_call.set_returned_object(ret)
 64         end
 65      end
 66
 67   visit_type_arguments (type: LIBERTY_ACTUAL_TYPE) is
 68      local
 69         ret: LIBERTY_INTERPRETER_OBJECT
 70         type_arguments_builtins: LIBERTY_INTERPRETER_EXTERNAL_TYPE_ARGUMENTS_BUILTINS
 71      do
 72         create type_arguments_builtins.make(interpreter)
 73         ret := type_arguments_builtins.call(builtin_call)
 74         if type_arguments_builtins.last_call_failed then
 75            last_call_failed := True
 76         else
 77            builtin_call.set_returned_object(ret)
 78         end
 79      end
 80
 81   visit_type_platform (type: LIBERTY_ACTUAL_TYPE) is
 82      local
 83         ret: LIBERTY_INTERPRETER_OBJECT
 84         type_platform_builtins: LIBERTY_INTERPRETER_EXTERNAL_TYPE_PLATFORM_BUILTINS
 85      do
 86         create type_platform_builtins.make(interpreter)
 87         ret := type_platform_builtins.call(builtin_call)
 88         if type_platform_builtins.last_call_failed then
 89            last_call_failed := True
 90         else
 91            builtin_call.set_returned_object(ret)
 92         end
 93      end
 94
 95   visit_type_pointer (type: LIBERTY_ACTUAL_TYPE) is
 96      local
 97         ret: LIBERTY_INTERPRETER_OBJECT
 98         type_pointer_builtins: LIBERTY_INTERPRETER_EXTERNAL_TYPE_POINTER_BUILTINS
 99      do
100         create type_pointer_builtins.make(interpreter)
101         ret := type_pointer_builtins.call(builtin_call)
102         if type_pointer_builtins.last_call_failed then
103            last_call_failed := True
104         else
105            builtin_call.set_returned_object(ret)
106         end
107      end
108
109   visit_type_integer_64 (type: LIBERTY_ACTUAL_TYPE) is
110      local
111         ret: LIBERTY_INTERPRETER_OBJECT
112         type_integer_64_builtins: LIBERTY_INTERPRETER_EXTERNAL_TYPE_INTEGER_64_BUILTINS
113      do
114         create type_integer_64_builtins.make(interpreter)
115         ret := type_integer_64_builtins.call(builtin_call)
116         if type_integer_64_builtins.last_call_failed then
117            last_call_failed := True
118         else
119            builtin_call.set_returned_object(ret)
120         end
121      end
122
123   visit_type_integer_32 (type: LIBERTY_ACTUAL_TYPE) is
124      local
125         ret: LIBERTY_INTERPRETER_OBJECT
126         type_integer_32_builtins: LIBERTY_INTERPRETER_EXTERNAL_TYPE_INTEGER_32_BUILTINS
127      do
128         create type_integer_32_builtins.make(interpreter)
129         ret := type_integer_32_builtins.call(builtin_call)
130         if type_integer_32_builtins.last_call_failed then
131            last_call_failed := True
132         else
133            builtin_call.set_returned_object(ret)
134         end
135      end
136
137   visit_type_integer_16 (type: LIBERTY_ACTUAL_TYPE) is
138      local
139         ret: LIBERTY_INTERPRETER_OBJECT
140         type_integer_16_builtins: LIBERTY_INTERPRETER_EXTERNAL_TYPE_INTEGER_16_BUILTINS
141      do
142         create type_integer_16_builtins.make(interpreter)
143         ret := type_integer_16_builtins.call(builtin_call)
144         if type_integer_16_builtins.last_call_failed then
145            last_call_failed := True
146         else
147            builtin_call.set_returned_object(ret)
148         end
149      end
150
151   visit_type_integer_8 (type: LIBERTY_ACTUAL_TYPE) is
152      local
153         ret: LIBERTY_INTERPRETER_OBJECT
154         type_integer_8_builtins: LIBERTY_INTERPRETER_EXTERNAL_TYPE_INTEGER_8_BUILTINS
155      do
156         create type_integer_8_builtins.make(interpreter)
157         ret := type_integer_8_builtins.call(builtin_call)
158         if type_integer_8_builtins.last_call_failed then
159            last_call_failed := True
160         else
161            builtin_call.set_returned_object(ret)
162         end
163      end
164
165   visit_type_real_64 (type: LIBERTY_ACTUAL_TYPE) is
166      local
167         ret: LIBERTY_INTERPRETER_OBJECT
168         type_real_64_builtins: LIBERTY_INTERPRETER_EXTERNAL_TYPE_REAL_64_BUILTINS
169      do
170         create type_real_64_builtins.make(interpreter)
171         ret := type_real_64_builtins.call(builtin_call)
172         if type_real_64_builtins.last_call_failed then
173            last_call_failed := True
174         else
175            builtin_call.set_returned_object(ret)
176         end
177      end
178
179   visit_type_real_32 (type: LIBERTY_ACTUAL_TYPE) is
180      local
181         ret: LIBERTY_INTERPRETER_OBJECT
182         type_real_32_builtins: LIBERTY_INTERPRETER_EXTERNAL_TYPE_REAL_32_BUILTINS
183      do
184         create type_real_32_builtins.make(interpreter)
185         ret := type_real_32_builtins.call(builtin_call)
186         if type_real_32_builtins.last_call_failed then
187            last_call_failed := True
188         else
189            builtin_call.set_returned_object(ret)
190         end
191      end
192
193   visit_type_real_80 (type: LIBERTY_ACTUAL_TYPE) is
194      local
195         ret: LIBERTY_INTERPRETER_OBJECT
196         type_real_80_builtins: LIBERTY_INTERPRETER_EXTERNAL_TYPE_REAL_80_BUILTINS
197      do
198         create type_real_80_builtins.make(interpreter)
199         ret := type_real_80_builtins.call(builtin_call)
200         if type_real_80_builtins.last_call_failed then
201            last_call_failed := True
202         else
203            builtin_call.set_returned_object(ret)
204         end
205      end
206
207   visit_type_real_128 (type: LIBERTY_ACTUAL_TYPE) is
208      local
209         ret: LIBERTY_INTERPRETER_OBJECT
210         type_real_128_builtins: LIBERTY_INTERPRETER_EXTERNAL_TYPE_REAL_128_BUILTINS
211      do
212         create type_real_128_builtins.make(interpreter)
213         ret := type_real_128_builtins.call(builtin_call)
214         if type_real_128_builtins.last_call_failed then
215            last_call_failed := True
216         else
217            builtin_call.set_returned_object(ret)
218         end
219      end
220
221   visit_type_character (type: LIBERTY_ACTUAL_TYPE) is
222      local
223         ret: LIBERTY_INTERPRETER_OBJECT
224         type_character_builtins: LIBERTY_INTERPRETER_EXTERNAL_TYPE_CHARACTER_BUILTINS
225      do
226         create type_character_builtins.make(interpreter)
227         ret := type_character_builtins.call(builtin_call)
228         if type_character_builtins.last_call_failed then
229            last_call_failed := True
230         else
231            builtin_call.set_returned_object(ret)
232         end
233      end
234
235   visit_type_string (type: LIBERTY_ACTUAL_TYPE) is
236      local
237         ret: LIBERTY_INTERPRETER_OBJECT
238         type_string_builtins: LIBERTY_INTERPRETER_EXTERNAL_TYPE_STRING_BUILTINS
239      do
240         create type_string_builtins.make(interpreter)
241         ret := type_string_builtins.call(builtin_call)
242         if type_string_builtins.last_call_failed then
243            last_call_failed := True
244         else
245            builtin_call.set_returned_object(ret)
246         end
247      end
248
249   visit_type_boolean (type: LIBERTY_ACTUAL_TYPE) is
250      local
251         ret: LIBERTY_INTERPRETER_OBJECT
252         type_boolean_builtins: LIBERTY_INTERPRETER_EXTERNAL_TYPE_BOOLEAN_BUILTINS
253      do
254         create type_boolean_builtins.make(interpreter)
255         ret := type_boolean_builtins.call(builtin_call)
256         if type_boolean_builtins.last_call_failed then
257            last_call_failed := True
258         else
259            builtin_call.set_returned_object(ret)
260         end
261      end
262
263   visit_type_native_array (type: LIBERTY_ACTUAL_TYPE) is
264      local
265         ret: LIBERTY_INTERPRETER_OBJECT
266         type_native_array_builtins: LIBERTY_INTERPRETER_EXTERNAL_TYPE_NATIVE_ARRAY_BUILTINS
267      do
268         create type_native_array_builtins.make(interpreter)
269         ret := type_native_array_builtins.call(builtin_call)
270         if type_native_array_builtins.last_call_failed then
271            last_call_failed := True
272         else
273            builtin_call.set_returned_object(ret)
274         end
275      end
276
277   visit_type_tuple (type: LIBERTY_ACTUAL_TYPE) is
278      local
279         ret: LIBERTY_INTERPRETER_OBJECT
280         type_tuple_builtins: LIBERTY_INTERPRETER_EXTERNAL_TYPE_TUPLE_BUILTINS
281      do
282         create type_tuple_builtins.make(interpreter)
283         ret := type_tuple_builtins.call(builtin_call)
284         if type_tuple_builtins.last_call_failed then
285            last_call_failed := True
286         else
287            builtin_call.set_returned_object(ret)
288         end
289      end
290
291   visit_type_routine (type: LIBERTY_ACTUAL_TYPE) is
292      local
293         ret: LIBERTY_INTERPRETER_OBJECT
294         type_routine_builtins: LIBERTY_INTERPRETER_EXTERNAL_TYPE_ROUTINE_BUILTINS
295      do
296         create type_routine_builtins.make(interpreter)
297         ret := type_routine_builtins.call(builtin_call)
298         if type_routine_builtins.last_call_failed then
299            last_call_failed := True
300         else
301            builtin_call.set_returned_object(ret)
302         end
303      end
304
305   visit_type_procedure (type: LIBERTY_ACTUAL_TYPE) is
306      local
307         ret: LIBERTY_INTERPRETER_OBJECT
308         type_procedure_builtins: LIBERTY_INTERPRETER_EXTERNAL_TYPE_PROCEDURE_BUILTINS
309      do
310         create type_procedure_builtins.make(interpreter)
311         ret := type_procedure_builtins.call(builtin_call)
312         if type_procedure_builtins.last_call_failed then
313            last_call_failed := True
314         else
315            builtin_call.set_returned_object(ret)
316         end
317      end
318
319   visit_type_function (type: LIBERTY_ACTUAL_TYPE) is
320      local
321         ret: LIBERTY_INTERPRETER_OBJECT
322         type_function_builtins: LIBERTY_INTERPRETER_EXTERNAL_TYPE_FUNCTION_BUILTINS
323      do
324         create type_function_builtins.make(interpreter)
325         ret := type_function_builtins.call(builtin_call)
326         if type_function_builtins.last_call_failed then
327            last_call_failed := True
328         else
329            builtin_call.set_returned_object(ret)
330         end
331      end
332
333   visit_type_predicate (type: LIBERTY_ACTUAL_TYPE) is
334      local
335         ret: LIBERTY_INTERPRETER_OBJECT
336         type_predicate_builtins: LIBERTY_INTERPRETER_EXTERNAL_TYPE_PREDICATE_BUILTINS
337      do
338         create type_predicate_builtins.make(interpreter)
339         ret := type_predicate_builtins.call(builtin_call)
340         if type_predicate_builtins.last_call_failed then
341            last_call_failed := True
342         else
343            builtin_call.set_returned_object(ret)
344         end
345      end
346
347   visit_user_type (type: LIBERTY_ACTUAL_TYPE) is
348      local
349         ret: LIBERTY_INTERPRETER_OBJECT
350         user_type_builtins: LIBERTY_INTERPRETER_EXTERNAL_USER_TYPE_BUILTINS
351      do
352         create user_type_builtins.make(interpreter)
353         ret := user_type_builtins.call(builtin_call)
354         if user_type_builtins.last_call_failed then
355            last_call_failed := True
356         else
357            builtin_call.set_returned_object(ret)
358         end
359      end
360
361feature {LIBERTY_VOID_TYPE}
362   visit_void (type: LIBERTY_VOID_TYPE) is
363      do
364         check False end
365      end
366
367invariant
368   interpreter /= Void
369   builtin_call /= Void
370
371end -- class LIBERTY_INTERPRETER_EXTERNAL_BUILTIN_CALL