/src/tools/interpreter/debugger/liberty_interpreter_debugger_visitor_impl.e

http://github.com/tybor/Liberty · Specman e · 171 lines · 145 code · 12 blank · 14 comment · 5 complexity · fa01ace63542d9fc4757da9a4c649dc1 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_DEBUGGER_VISITOR_IMPL
  16. inherit
  17. LIBERTY_INTERPRETER_DEBUGGER_VISITOR
  18. create {LIBERTY_INTERPRETER_DEBUGGER}
  19. make
  20. feature {LIBERTY_INTERPRETER_DEBUGGER}
  21. should_continue: BOOLEAN
  22. feature {LIBERTY_INTERPRETER_DEBUGGER_FACTORY}
  23. visit_entry (a_entry: LIBERTY_INTERPRETER_DEBUGGER_NON_TERMINAL_NODE) is
  24. do
  25. should_continue := False
  26. check
  27. a_entry.lower = 0
  28. a_entry.name_at(a_entry.upper).is_equal(once "KW end of line")
  29. a_entry.count.in_range(2, 3)
  30. end
  31. inspect
  32. a_entry.name_at(0)
  33. when "KW show" then
  34. check
  35. a_entry.name_at(1).is_equal(once "Show")
  36. end
  37. a_entry.node_at(1).accept(Current)
  38. when "KW up" then
  39. check
  40. a_entry.name_at(1).is_equal(once "Up")
  41. end
  42. a_entry.node_at(1).accept(Current)
  43. when "KW down" then
  44. check
  45. a_entry.name_at(1).is_equal(once "Down")
  46. end
  47. a_entry.node_at(1).accept(Current)
  48. when "KW continue" then
  49. should_continue := True
  50. when "KW step" then
  51. check
  52. a_entry.name_at(1).is_equal(once "Step")
  53. end
  54. a_entry.node_at(1).accept(Current)
  55. should_continue := True
  56. when "KW quit" then
  57. die_with_code(0)
  58. end
  59. end
  60. visit_show (a_show: LIBERTY_INTERPRETER_DEBUGGER_NON_TERMINAL_NODE) is
  61. do
  62. check
  63. a_show.lower = 0
  64. end
  65. inspect
  66. a_show.name_at(0)
  67. when "KW stack" then
  68. interpreter.show_stack(std_output)
  69. when "KW frame" then
  70. interpreter.show_current_frame(std_output)
  71. end
  72. end
  73. visit_step (a_step: LIBERTY_INTERPRETER_DEBUGGER_NON_TERMINAL_NODE) is
  74. local
  75. step_count_node: EIFFEL_TERMINAL_NODE_IMPL
  76. step_count: TYPED_EIFFEL_IMAGE[INTEGER_64]
  77. do
  78. if a_step.is_empty then
  79. interpreter.debug_step(1)
  80. else
  81. check
  82. a_step.lower = 0
  83. end
  84. inspect
  85. a_step.name_at(0)
  86. when "KW in" then
  87. interpreter.debug_step_in
  88. when "KW out" then
  89. interpreter.debug_step_out
  90. when "KW number" then
  91. step_count_node ::= a_step.node_at(0)
  92. step_count ::= step_count_node.image
  93. if step_count.decoded <= 0 then
  94. std_error.put_line(once "Cannot step zero or less times :-)")
  95. else
  96. interpreter.debug_step(step_count.decoded.to_integer_32)
  97. end
  98. end
  99. end
  100. end
  101. visit_up (a_up: LIBERTY_INTERPRETER_DEBUGGER_NON_TERMINAL_NODE) is
  102. local
  103. up_node: EIFFEL_TERMINAL_NODE_IMPL
  104. up: TYPED_EIFFEL_IMAGE[INTEGER_64]
  105. do
  106. if a_up.is_empty then
  107. set_frame(1)
  108. else
  109. check
  110. a_up.lower = 0
  111. a_up.name_at(0).is_equal(once "KW number")
  112. end
  113. up_node ::= a_up.node_at(0)
  114. up ::= up_node.image
  115. set_frame(up.decoded)
  116. end
  117. end
  118. visit_down (a_down: LIBERTY_INTERPRETER_DEBUGGER_NON_TERMINAL_NODE) is
  119. local
  120. down_node: EIFFEL_TERMINAL_NODE_IMPL
  121. down: TYPED_EIFFEL_IMAGE[INTEGER_64]
  122. do
  123. if a_down.is_empty then
  124. set_frame(-1)
  125. else
  126. check
  127. a_down.lower = 0
  128. a_down.name_at(0).is_equal(once "KW number")
  129. end
  130. down_node ::= a_down.node_at(0)
  131. down ::= down_node.image
  132. set_frame(-(down.decoded))
  133. end
  134. end
  135. feature {}
  136. set_frame (delta: INTEGER_64) is
  137. local
  138. new_frame: INTEGER
  139. do
  140. new_frame := interpreter.current_frame + delta.to_integer_32
  141. if new_frame <= interpreter.frame_lower then
  142. std_error.put_line(once "Bottom reached.")
  143. new_frame := interpreter.frame_lower
  144. elseif new_frame >= interpreter.frame_upper then
  145. std_error.put_line(once "Top reached.")
  146. new_frame := interpreter.frame_upper
  147. end
  148. interpreter.set_current_frame(new_frame)
  149. end
  150. make (a_interpreter: like interpreter) is
  151. require
  152. a_interpreter /= Void
  153. do
  154. interpreter := a_interpreter
  155. ensure
  156. interpreter = a_interpreter
  157. end
  158. interpreter: LIBERTY_INTERPRETER
  159. end -- class LIBERTY_INTERPRETER_DEBUGGER_VISITOR_IMPL