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