/src/tools/interpreter/liberty_interpreter_native_array_creator.e

http://github.com/tybor/Liberty · Specman e · 193 lines · 146 code · 33 blank · 14 comment · 0 complexity · 20fdd003a8f478747398a1d6242f264a 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_NATIVE_ARRAY_CREATOR
  16. inherit
  17. LIBERTY_TYPE_VISITOR
  18. creation {LIBERTY_INTERPRETER}
  19. make
  20. feature {LIBERTY_INTERPRETER}
  21. new_array (type: like array_type; a_capacity: INTEGER; a_position: like position): LIBERTY_INTERPRETER_NATIVE_ARRAY is
  22. do
  23. array_type := type
  24. capacity := a_capacity
  25. position := a_position
  26. elements := default_pointer
  27. check
  28. type.parameters.count = 1
  29. end
  30. type.parameters.first.known_type.accept(Current)
  31. Result := last_created
  32. ensure
  33. Result.type = type
  34. end
  35. from_external (type: like array_type; a_capacity: INTEGER; a_elements: POINTER; a_position: like position): LIBERTY_INTERPRETER_NATIVE_ARRAY is
  36. do
  37. array_type := type
  38. capacity := a_capacity
  39. position := a_position
  40. elements := a_elements
  41. check
  42. type.parameters.count = 1
  43. end
  44. type.parameters.first.known_type.accept(Current)
  45. Result := last_created
  46. end
  47. feature {LIBERTY_UNIVERSE}
  48. visit_type_any (type: LIBERTY_ACTUAL_TYPE) is
  49. do
  50. check False end
  51. end
  52. visit_type_arguments (type: LIBERTY_ACTUAL_TYPE) is
  53. do
  54. create {LIBERTY_INTERPRETER_NATIVE_ARRAY_TYPED[LIBERTY_INTERPRETER_OBJECT]} last_created.make(interpreter, array_type, type, elements, capacity, position)
  55. end
  56. visit_type_platform (type: LIBERTY_ACTUAL_TYPE) is
  57. do
  58. check False end
  59. end
  60. visit_type_pointer (type: LIBERTY_ACTUAL_TYPE) is
  61. do
  62. create {LIBERTY_INTERPRETER_NATIVE_ARRAY_TYPED[POINTER]} last_created.make(interpreter, array_type, type, elements, capacity, position)
  63. end
  64. visit_type_integer_64 (type: LIBERTY_ACTUAL_TYPE) is
  65. do
  66. create {LIBERTY_INTERPRETER_NATIVE_ARRAY_TYPED[INTEGER_64]} last_created.make(interpreter, array_type, type, elements, capacity, position)
  67. end
  68. visit_type_integer_32 (type: LIBERTY_ACTUAL_TYPE) is
  69. do
  70. create {LIBERTY_INTERPRETER_NATIVE_ARRAY_TYPED[INTEGER_64]} last_created.make(interpreter, array_type, type, elements, capacity, position)
  71. end
  72. visit_type_integer_16 (type: LIBERTY_ACTUAL_TYPE) is
  73. do
  74. create {LIBERTY_INTERPRETER_NATIVE_ARRAY_TYPED[INTEGER_64]} last_created.make(interpreter, array_type, type, elements, capacity, position)
  75. end
  76. visit_type_integer_8 (type: LIBERTY_ACTUAL_TYPE) is
  77. do
  78. create {LIBERTY_INTERPRETER_NATIVE_ARRAY_TYPED[INTEGER_64]} last_created.make(interpreter, array_type, type, elements, capacity, position)
  79. end
  80. visit_type_real_64 (type: LIBERTY_ACTUAL_TYPE) is
  81. do
  82. create {LIBERTY_INTERPRETER_NATIVE_ARRAY_TYPED[REAL_128]} last_created.make(interpreter, array_type, type, elements, capacity, position)
  83. end
  84. visit_type_real_32 (type: LIBERTY_ACTUAL_TYPE) is
  85. do
  86. create {LIBERTY_INTERPRETER_NATIVE_ARRAY_TYPED[REAL_128]} last_created.make(interpreter, array_type, type, elements, capacity, position)
  87. end
  88. visit_type_real_80 (type: LIBERTY_ACTUAL_TYPE) is
  89. do
  90. create {LIBERTY_INTERPRETER_NATIVE_ARRAY_TYPED[REAL_128]} last_created.make(interpreter, array_type, type, elements, capacity, position)
  91. end
  92. visit_type_real_128 (type: LIBERTY_ACTUAL_TYPE) is
  93. do
  94. create {LIBERTY_INTERPRETER_NATIVE_ARRAY_TYPED[REAL_128]} last_created.make(interpreter, array_type, type, elements, capacity, position)
  95. end
  96. visit_type_character (type: LIBERTY_ACTUAL_TYPE) is
  97. do
  98. create {LIBERTY_INTERPRETER_NATIVE_ARRAY_TYPED[CHARACTER]} last_created.make(interpreter, array_type, type, elements, capacity, position)
  99. end
  100. visit_type_string (type: LIBERTY_ACTUAL_TYPE) is
  101. do
  102. create {LIBERTY_INTERPRETER_NATIVE_ARRAY_TYPED[LIBERTY_INTERPRETER_OBJECT]} last_created.make(interpreter, array_type, type, elements, capacity, position)
  103. end
  104. visit_type_boolean (type: LIBERTY_ACTUAL_TYPE) is
  105. do
  106. create {LIBERTY_INTERPRETER_NATIVE_ARRAY_TYPED[BOOLEAN]} last_created.make(interpreter, array_type, type, elements, capacity, position)
  107. end
  108. visit_type_native_array (type: LIBERTY_ACTUAL_TYPE) is
  109. do
  110. interpreter.fatal_error("Don't try to make NATIVE_ARRAY[NATIVE_ARRAY]!!!", position)
  111. end
  112. visit_type_tuple (type: LIBERTY_ACTUAL_TYPE) is
  113. do
  114. create {LIBERTY_INTERPRETER_NATIVE_ARRAY_TYPED[TUPLE]} last_created.make(interpreter, array_type, type, elements, capacity, position)
  115. end
  116. visit_type_routine (type: LIBERTY_ACTUAL_TYPE) is
  117. do
  118. create {LIBERTY_INTERPRETER_NATIVE_ARRAY_TYPED[LIBERTY_INTERPRETER_AGENT]} last_created.make(interpreter, array_type, type, elements, capacity, position)
  119. end
  120. visit_type_procedure (type: LIBERTY_ACTUAL_TYPE) is
  121. do
  122. create {LIBERTY_INTERPRETER_NATIVE_ARRAY_TYPED[LIBERTY_INTERPRETER_AGENT]} last_created.make(interpreter, array_type, type, elements, capacity, position)
  123. end
  124. visit_type_function (type: LIBERTY_ACTUAL_TYPE) is
  125. do
  126. create {LIBERTY_INTERPRETER_NATIVE_ARRAY_TYPED[LIBERTY_INTERPRETER_AGENT]} last_created.make(interpreter, array_type, type, elements, capacity, position)
  127. end
  128. visit_type_predicate (type: LIBERTY_ACTUAL_TYPE) is
  129. do
  130. create {LIBERTY_INTERPRETER_NATIVE_ARRAY_TYPED[LIBERTY_INTERPRETER_AGENT]} last_created.make(interpreter, array_type, type, elements, capacity, position)
  131. end
  132. visit_user_type (type: LIBERTY_ACTUAL_TYPE) is
  133. do
  134. create {LIBERTY_INTERPRETER_NATIVE_ARRAY_TYPED[LIBERTY_INTERPRETER_OBJECT]} last_created.make(interpreter, array_type, type, elements, capacity, position)
  135. end
  136. feature {LIBERTY_VOID_TYPE}
  137. visit_void (type: LIBERTY_VOID_TYPE) is
  138. do
  139. check False end
  140. end
  141. feature {}
  142. make (a_interpreter: like interpreter) is
  143. require
  144. a_interpreter /= Void
  145. do
  146. interpreter := a_interpreter
  147. ensure
  148. interpreter = a_interpreter
  149. end
  150. last_created: LIBERTY_INTERPRETER_NATIVE_ARRAY
  151. interpreter: LIBERTY_INTERPRETER
  152. position: LIBERTY_POSITION
  153. array_type: LIBERTY_ACTUAL_TYPE
  154. capacity: INTEGER
  155. elements: POINTER
  156. native_array_creator: LIBERTY_INTERPRETER_NATIVE_ARRAY_CREATOR
  157. invariant
  158. interpreter /= Void
  159. native_array_creator /= Void
  160. end -- class LIBERTY_INTERPRETER_NATIVE_ARRAY_CREATOR