/src/tools/interpreter/liberty_interpreter_to_external.e

http://github.com/tybor/Liberty · Specman e · 204 lines · 158 code · 32 blank · 14 comment · 0 complexity · 8b11097cb04ab29a402b64b3b9dc1697 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_TO_EXTERNAL
  16. inherit
  17. LIBERTY_TYPE_VISITOR
  18. create {LIBERTY_INTERPRETER_EXTERNAL_PLUGINS}
  19. make
  20. feature {LIBERTY_INTERPRETER_EXTERNAL_PLUGINS}
  21. item (a_object: LIBERTY_INTERPRETER_OBJECT): FOREIGN_OBJECT is
  22. require
  23. a_object /= Void
  24. do
  25. liberty_object := a_object
  26. a_object.result_type.known_type.accept(Current)
  27. Result := external_object
  28. end
  29. feature {}
  30. external_object: FOREIGN_OBJECT
  31. liberty_object: LIBERTY_INTERPRETER_OBJECT
  32. feature {LIBERTY_UNIVERSE}
  33. visit_type_any (a_type: LIBERTY_ACTUAL_TYPE) is
  34. do
  35. interpreter.fatal_error("The type " + a_type.full_name + " cannot be transmitted to a plugin", errors.unknown_position)
  36. end
  37. visit_type_arguments (a_type: LIBERTY_ACTUAL_TYPE) is
  38. do
  39. interpreter.fatal_error("The type " + a_type.full_name + " cannot be transmitted to a plugin", errors.unknown_position)
  40. end
  41. visit_type_platform (a_type: LIBERTY_ACTUAL_TYPE) is
  42. do
  43. interpreter.fatal_error("The type " + a_type.full_name + " cannot be transmitted to a plugin", errors.unknown_position)
  44. end
  45. visit_type_pointer (a_type: LIBERTY_ACTUAL_TYPE) is
  46. local
  47. p: LIBERTY_INTERPRETER_OBJECT_NATIVE[POINTER]
  48. do
  49. p ::= liberty_object
  50. external_object := foreign_types.create_pointer(p.item)
  51. end
  52. visit_type_integer_64 (a_type: LIBERTY_ACTUAL_TYPE) is
  53. local
  54. p: LIBERTY_INTERPRETER_OBJECT_NATIVE[INTEGER_64]
  55. do
  56. p ::= liberty_object
  57. external_object := foreign_types.create_sint64(p.item)
  58. end
  59. visit_type_integer_32 (a_type: LIBERTY_ACTUAL_TYPE) is
  60. local
  61. p: LIBERTY_INTERPRETER_OBJECT_NATIVE[INTEGER_64]
  62. do
  63. p ::= liberty_object
  64. external_object := foreign_types.create_sint32(p.item.to_integer_32)
  65. end
  66. visit_type_integer_16 (a_type: LIBERTY_ACTUAL_TYPE) is
  67. local
  68. p: LIBERTY_INTERPRETER_OBJECT_NATIVE[INTEGER_64]
  69. do
  70. p ::= liberty_object
  71. external_object := foreign_types.create_sint16(p.item.to_integer_16)
  72. end
  73. visit_type_integer_8 (a_type: LIBERTY_ACTUAL_TYPE) is
  74. local
  75. p: LIBERTY_INTERPRETER_OBJECT_NATIVE[INTEGER_64]
  76. do
  77. p ::= liberty_object
  78. external_object := foreign_types.create_sint8(p.item.to_integer_8)
  79. end
  80. visit_type_real_64 (a_type: LIBERTY_ACTUAL_TYPE) is
  81. local
  82. p: LIBERTY_INTERPRETER_OBJECT_NATIVE[REAL_128]
  83. do
  84. p ::= liberty_object
  85. external_object := foreign_types.create_double(p.item.force_to_real_64)
  86. end
  87. visit_type_real_32 (a_type: LIBERTY_ACTUAL_TYPE) is
  88. local
  89. p: LIBERTY_INTERPRETER_OBJECT_NATIVE[REAL_128]
  90. do
  91. p ::= liberty_object
  92. external_object := foreign_types.create_double(p.item.force_to_real_32)
  93. end
  94. visit_type_real_80 (a_type: LIBERTY_ACTUAL_TYPE) is
  95. do
  96. interpreter.fatal_error("The type " + a_type.full_name + " cannot be transmitted to a plugin", errors.unknown_position)
  97. end
  98. visit_type_real_128 (a_type: LIBERTY_ACTUAL_TYPE) is
  99. do
  100. interpreter.fatal_error("The type " + a_type.full_name + " cannot be transmitted to a plugin", errors.unknown_position)
  101. end
  102. visit_type_character (a_type: LIBERTY_ACTUAL_TYPE) is
  103. local
  104. p: LIBERTY_INTERPRETER_OBJECT_NATIVE[CHARACTER]
  105. do
  106. p ::= liberty_object
  107. external_object := foreign_types.create_schar(p.item)
  108. end
  109. visit_type_string (a_type: LIBERTY_ACTUAL_TYPE) is
  110. do
  111. interpreter.fatal_error("The type " + a_type.full_name + " cannot be transmitted to a plugin", errors.unknown_position)
  112. end
  113. visit_type_boolean (a_type: LIBERTY_ACTUAL_TYPE) is
  114. local
  115. p: LIBERTY_INTERPRETER_OBJECT_BOOLEAN
  116. do
  117. p ::= liberty_object
  118. external_object := foreign_types.create_sint32(p.item.to_integer)
  119. end
  120. visit_type_native_array (a_type: LIBERTY_ACTUAL_TYPE) is
  121. local
  122. p: LIBERTY_INTERPRETER_NATIVE_ARRAY
  123. do
  124. p ::= liberty_object
  125. external_object := foreign_types.create_pointer(p.to_external)
  126. end
  127. visit_type_tuple (a_type: LIBERTY_ACTUAL_TYPE) is
  128. do
  129. interpreter.fatal_error("The type " + a_type.full_name + " cannot be transmitted to a plugin", errors.unknown_position)
  130. end
  131. visit_type_routine (a_type: LIBERTY_ACTUAL_TYPE) is
  132. do
  133. interpreter.fatal_error("The type " + a_type.full_name + " cannot be transmitted to a plugin", errors.unknown_position)
  134. end
  135. visit_type_procedure (a_type: LIBERTY_ACTUAL_TYPE) is
  136. do
  137. interpreter.fatal_error("The type " + a_type.full_name + " cannot be transmitted to a plugin", errors.unknown_position)
  138. end
  139. visit_type_function (a_type: LIBERTY_ACTUAL_TYPE) is
  140. do
  141. interpreter.fatal_error("The type " + a_type.full_name + " cannot be transmitted to a plugin", errors.unknown_position)
  142. end
  143. visit_type_predicate (a_type: LIBERTY_ACTUAL_TYPE) is
  144. do
  145. interpreter.fatal_error("The type " + a_type.full_name + " cannot be transmitted to a plugin", errors.unknown_position)
  146. end
  147. visit_user_type (a_type: LIBERTY_ACTUAL_TYPE) is
  148. do
  149. interpreter.fatal_error("The type " + a_type.full_name + " cannot be transmitted to a plugin", errors.unknown_position)
  150. end
  151. feature {LIBERTY_VOID_TYPE}
  152. visit_void (a_type: LIBERTY_VOID_TYPE) is
  153. do
  154. interpreter.fatal_error("The type " + a_type.full_name + " cannot be transmitted to a plugin", errors.unknown_position)
  155. end
  156. feature {}
  157. make (a_interpreter: like interpreter) is
  158. require
  159. a_interpreter /= Void
  160. do
  161. interpreter := a_interpreter
  162. ensure
  163. interpreter = a_interpreter
  164. end
  165. interpreter: LIBERTY_INTERPRETER
  166. foreign_types: FOREIGN_TYPES
  167. storage_attribute: FIXED_STRING is
  168. once
  169. Result := "storage".intern
  170. end
  171. errors: LIBERTY_ERRORS
  172. end -- LIBERTY_INTERPRETER_TO_EXTERNAL