/src/tools/interpreter/liberty_interpreter_object_native.e

http://github.com/tybor/Liberty · Specman e · 162 lines · 129 code · 18 blank · 15 comment · 6 complexity · 6f1f5451a1c70f52395565a2dfac847e 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. deferred class LIBERTY_INTERPRETER_OBJECT_NATIVE[E_]
  16. inherit
  17. LIBERTY_INTERPRETER_OBJECT
  18. feature {ANY}
  19. type: LIBERTY_ACTUAL_TYPE
  20. is_equal (other: LIBERTY_INTERPRETER_OBJECT): BOOLEAN is
  21. local
  22. o: like Current
  23. do
  24. if other.is_void then
  25. -- Obviously this object is not Void.
  26. else
  27. o ::= other
  28. Result := item = o.item
  29. end
  30. end
  31. item: E_
  32. set_item (a_item: like item) is
  33. do
  34. item := a_item
  35. ensure
  36. item = a_item
  37. end
  38. feature {LIBERTY_INTERPRETER_EXTERNAL_TYPE_ANY_BUILTINS} -- Standard builtings
  39. builtin_is_equal (other: LIBERTY_INTERPRETER_OBJECT; a_position: LIBERTY_POSITION): BOOLEAN is
  40. local
  41. o: like Current
  42. do
  43. if type = other.type then
  44. o ::= other
  45. Result := item.is_equal(o.item)
  46. else
  47. interpreter.fatal_error("Type mismatch: expected " + type.full_name + ", but got " + other.type.full_name, a_position)
  48. end
  49. end
  50. builtin_standard_is_equal (other: LIBERTY_INTERPRETER_OBJECT; a_position: LIBERTY_POSITION): BOOLEAN is
  51. local
  52. o: like Current
  53. do
  54. if type = other.type then
  55. o ::= other
  56. Result := item.is_equal(o.item)
  57. else
  58. interpreter.fatal_error("Type mismatch: expected " + type.full_name + ", but got " + other.type.full_name, a_position)
  59. end
  60. end
  61. builtin_copy (other: LIBERTY_INTERPRETER_OBJECT; a_position: LIBERTY_POSITION) is
  62. local
  63. o: like Current
  64. do
  65. if type = other.type then
  66. o ::= other
  67. item := o.item
  68. else
  69. interpreter.fatal_error("Type mismatch: expected " + type.full_name + ", but got " + other.type.full_name, a_position)
  70. end
  71. end
  72. builtin_twin (a_position: LIBERTY_POSITION): like Current is
  73. do
  74. Result := as_right_value
  75. end
  76. builtin_standard_copy (other: LIBERTY_INTERPRETER_OBJECT; a_position: LIBERTY_POSITION) is
  77. local
  78. o: like Current
  79. do
  80. if type = other.type then
  81. o ::= other
  82. item := o.item
  83. else
  84. interpreter.fatal_error("Type mismatch: expected " + type.full_name + ", but got " + other.type.full_name, a_position)
  85. end
  86. end
  87. builtin_standard_twin (a_position: LIBERTY_POSITION): like Current is
  88. do
  89. Result := as_right_value
  90. end
  91. feature {LIBERTY_INTERPRETER_OBJECT}
  92. do_deep_twin (deep_twin_memory: DICTIONARY[LIBERTY_INTERPRETER_OBJECT, LIBERTY_INTERPRETER_OBJECT]; a_position: LIBERTY_POSITION): LIBERTY_INTERPRETER_OBJECT is
  93. do
  94. Result := as_right_value
  95. end
  96. do_deep_equal (other: LIBERTY_INTERPRETER_OBJECT; deep_equal_memory: SET[LIBERTY_INTERPRETER_OBJECT]; a_position: LIBERTY_POSITION): BOOLEAN is
  97. local
  98. o: like Current
  99. do
  100. if type = other.type then
  101. o ::= other
  102. Result := item.is_equal(o.item)
  103. else
  104. interpreter.fatal_error("Type mismatch: expected " + type.full_name + ", but got " + other.type.full_name, a_position)
  105. end
  106. end
  107. feature {LIBERTY_INTERPRETER_OBJECT_PRINTER, LIBERTY_INTERPRETER_FEATURE_CALL}
  108. show_stack (o: OUTPUT_STREAM; indent: INTEGER) is
  109. do
  110. item.print_on(o)
  111. o.put_new_line
  112. end
  113. feature {}
  114. make (a_interpreter: like interpreter; a_type: like type; a_position: like position) is
  115. require
  116. a_interpreter /= Void
  117. a_type /= Void
  118. a_position /= Void
  119. do
  120. interpreter := a_interpreter
  121. type := a_type
  122. position := a_position
  123. ensure
  124. interpreter = a_interpreter
  125. type = a_type
  126. position = a_position
  127. end
  128. with_item (a_interpreter: like interpreter; a_type: like type; a_item: like item; a_position: like position) is
  129. require
  130. a_interpreter /= Void
  131. a_type /= Void
  132. a_position /= Void
  133. do
  134. make(a_interpreter, a_type, a_position)
  135. item := a_item
  136. ensure
  137. interpreter = a_interpreter
  138. type = a_type
  139. item = a_item
  140. position = a_position
  141. end
  142. invariant
  143. item_is_expanded: item /= Void
  144. end -- class LIBERTY_INTERPRETER_OBJECT_NATIVE