PageRenderTime 24ms CodeModel.GetById 16ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/src/tools/interpreter/liberty_interpreter_object_converter.e

http://github.com/tybor/Liberty
Specman e | 263 lines | 216 code | 33 blank | 14 comment | 0 complexity | cb936811763c6de16155b84c9bfcbded 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_OBJECT_CONVERTER
 16
 17inherit
 18   LIBERTY_TYPE_CONVERTER
 19
 20insert
 21   LOGGING
 22
 23creation {LIBERTY_INTERPRETER}
 24   make
 25
 26feature {ANY}
 27   convert_object (a_source: like source; a_target_type: LIBERTY_ACTUAL_TYPE): LIBERTY_INTERPRETER_OBJECT is
 28      require
 29         a_source.type.converts_to(a_target_type)
 30      do
 31         debug ("interpreter.convert")
 32            log.trace.put_string(once "Converting from ")
 33            log.trace.put_string(a_source.result_type.known_type.full_name)
 34            log.trace.put_string(once " to ")
 35            log.trace.put_line(a_target_type.full_name)
 36         end
 37         interpreter.ensure_built(a_target_type)
 38         source := a_source
 39         a_source.type.do_convert(a_target_type, Current)
 40         Result := converted
 41         converted := Void
 42      ensure
 43         Result.type = a_target_type
 44      end
 45
 46feature {}
 47   source: LIBERTY_INTERPRETER_OBJECT
 48   converted: LIBERTY_INTERPRETER_OBJECT
 49
 50feature {LIBERTY_UNIVERSE} -- Legacy conversion rules
 51   convert_integer_8_16 is
 52      local
 53         int: LIBERTY_INTERPRETER_OBJECT_NATIVE[INTEGER_64]
 54      do
 55         int ::= source
 56         converted := interpreter.new_integer_16(int.item.to_integer_16, int.position)
 57      end
 58
 59   convert_integer_8_32 is
 60      local
 61         int: LIBERTY_INTERPRETER_OBJECT_NATIVE[INTEGER_64]
 62      do
 63         int ::= source
 64         converted := interpreter.new_integer_32(int.item.to_integer_32, int.position)
 65      end
 66
 67   convert_integer_8_64 is
 68      local
 69         int: LIBERTY_INTERPRETER_OBJECT_NATIVE[INTEGER_64]
 70      do
 71         int ::= source
 72         converted := interpreter.new_integer_64(int.item, int.position)
 73      end
 74
 75   convert_integer_16_32 is
 76      local
 77         int: LIBERTY_INTERPRETER_OBJECT_NATIVE[INTEGER_64]
 78      do
 79         int ::= source
 80         converted := interpreter.new_integer_32(int.item.to_integer_32, int.position)
 81      end
 82
 83   convert_integer_16_64 is
 84      local
 85         int: LIBERTY_INTERPRETER_OBJECT_NATIVE[INTEGER_64]
 86      do
 87         int ::= source
 88         converted := interpreter.new_integer_64(int.item, int.position)
 89      end
 90
 91   convert_integer_32_64 is
 92      local
 93         int: LIBERTY_INTERPRETER_OBJECT_NATIVE[INTEGER_64]
 94      do
 95         int ::= source
 96         converted := interpreter.new_integer_64(int.item, int.position)
 97      end
 98
 99   convert_real_32_64 is
100      local
101         flt: LIBERTY_INTERPRETER_OBJECT_NATIVE[REAL_128]
102      do
103         flt ::= source
104         converted := interpreter.new_real_64(flt.item.force_to_real_64, flt.position)
105      end
106
107   convert_real_32_80 is
108      local
109         flt: LIBERTY_INTERPRETER_OBJECT_NATIVE[REAL_128]
110      do
111         flt ::= source
112         converted := interpreter.new_real_80(flt.item.force_to_real_64, flt.position)
113      end
114
115   convert_real_32_128 is
116      local
117         flt: LIBERTY_INTERPRETER_OBJECT_NATIVE[REAL_128]
118      do
119         flt ::= source
120         converted := interpreter.new_real_128(flt.item, flt.position)
121      end
122
123   convert_real_64_80 is
124      local
125         flt: LIBERTY_INTERPRETER_OBJECT_NATIVE[REAL_128]
126      do
127         flt ::= source
128         converted := interpreter.new_real_80(flt.item, flt.position)
129      end
130
131   convert_real_64_128 is
132      local
133         flt: LIBERTY_INTERPRETER_OBJECT_NATIVE[REAL_128]
134      do
135         flt ::= source
136         converted := interpreter.new_real_128(flt.item, flt.position)
137      end
138
139   convert_real_80_128 is
140      local
141         flt: LIBERTY_INTERPRETER_OBJECT_NATIVE[REAL_128]
142      do
143         flt ::= source
144         converted := interpreter.new_real_128(flt.item, flt.position)
145      end
146
147   convert_integer_64_real_128 is
148      local
149         flt: LIBERTY_INTERPRETER_OBJECT_NATIVE[INTEGER_64]
150      do
151         flt ::= source
152         converted := interpreter.new_real_128(flt.item, flt.position)
153      end
154
155   convert_integer_64_real_80 is
156      local
157         flt: LIBERTY_INTERPRETER_OBJECT_NATIVE[INTEGER_64]
158      do
159         flt ::= source
160         converted := interpreter.new_real_80(flt.item, flt.position)
161      end
162
163   convert_integer_32_real_128 is
164      local
165         flt: LIBERTY_INTERPRETER_OBJECT_NATIVE[INTEGER_64]
166      do
167         flt ::= source
168         converted := interpreter.new_real_128(flt.item.to_integer_32, flt.position)
169      end
170
171   convert_integer_32_real_80 is
172      local
173         flt: LIBERTY_INTERPRETER_OBJECT_NATIVE[INTEGER_64]
174      do
175         flt ::= source
176         converted := interpreter.new_real_80(flt.item.to_integer_32, flt.position)
177      end
178
179   convert_integer_32_real_64 is
180      local
181         flt: LIBERTY_INTERPRETER_OBJECT_NATIVE[INTEGER_64]
182      do
183         flt ::= source
184         converted := interpreter.new_real_64(flt.item.to_integer_32, flt.position)
185      end
186
187   convert_integer_16_real_128 is
188      local
189         flt: LIBERTY_INTERPRETER_OBJECT_NATIVE[INTEGER_64]
190      do
191         flt ::= source
192         converted := interpreter.new_real_128(flt.item.to_integer_16, flt.position)
193      end
194
195   convert_integer_16_real_80 is
196      local
197         flt: LIBERTY_INTERPRETER_OBJECT_NATIVE[INTEGER_64]
198      do
199         flt ::= source
200         converted := interpreter.new_real_80(flt.item.to_integer_16, flt.position)
201      end
202
203   convert_integer_16_real_64 is
204      local
205         flt: LIBERTY_INTERPRETER_OBJECT_NATIVE[INTEGER_64]
206      do
207         flt ::= source
208         converted := interpreter.new_real_64(flt.item.to_integer_16, flt.position)
209      end
210
211   convert_integer_16_real_32 is
212      local
213         flt: LIBERTY_INTERPRETER_OBJECT_NATIVE[INTEGER_64]
214      do
215         flt ::= source
216         converted := interpreter.new_real_32(flt.item.to_integer_16, flt.position)
217      end
218
219   convert_integer_8_real_128 is
220      local
221         flt: LIBERTY_INTERPRETER_OBJECT_NATIVE[INTEGER_64]
222      do
223         flt ::= source
224         converted := interpreter.new_real_128(flt.item.to_integer_8, flt.position)
225      end
226
227   convert_integer_8_real_80 is
228      local
229         flt: LIBERTY_INTERPRETER_OBJECT_NATIVE[INTEGER_64]
230      do
231         flt ::= source
232         converted := interpreter.new_real_80(flt.item.to_integer_8, flt.position)
233      end
234
235   convert_integer_8_real_64 is
236      local
237         flt: LIBERTY_INTERPRETER_OBJECT_NATIVE[INTEGER_64]
238      do
239         flt ::= source
240         converted := interpreter.new_real_64(flt.item.to_integer_8, flt.position)
241      end
242
243   convert_integer_8_real_32 is
244      local
245         flt: LIBERTY_INTERPRETER_OBJECT_NATIVE[INTEGER_64]
246      do
247         flt ::= source
248         converted := interpreter.new_real_32(flt.item.to_integer_8, flt.position)
249      end
250
251feature {}
252   make (a_interpreter: like interpreter) is
253      require
254         a_interpreter /= Void
255      do
256         interpreter := a_interpreter
257      ensure
258         interpreter = a_interpreter
259      end
260
261   interpreter: LIBERTY_INTERPRETER
262
263end -- class LIBERTY_INTERPRETER_OBJECT_CONVERTER