PageRenderTime 18ms CodeModel.GetById 12ms app.highlight 2ms RepoModel.GetById 2ms app.codeStats 0ms

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