lib/ruby-debug/processor.rb in ruby-debug-ide-0.1.10 vs lib/ruby-debug/processor.rb in ruby-debug-ide-0.2.0
- old
+ new
@@ -13,57 +13,55 @@
@interface.print(*args)
end
def process_commands
@printer.print_debug("Starting command read loop")
- control_cmds = Command.commands.select{|cmd| cmd.control }
- state = ControlState.new(@interface, control_cmds)
- commands = control_cmds.map{|cmd| cmd.new(state, @printer) }
+ ctrl_cmd_classes = Command.commands.select{|cmd| cmd.control}
+ state = ControlState.new(@interface)
+ ctrl_cmds = ctrl_cmd_classes.map{|cmd| cmd.new(state, @printer)}
while input = @interface.read_command
# escape % since print_debug might use printf
@printer.print_debug "Processing: #{input.gsub('%', '%%')}"
catch(:debug_error) do
- if cmd = commands.find{|c| c.match(input) }
+ if cmd = ctrl_cmds.find{|c| c.match(input) }
cmd.execute
else
process_context_commands(input)
end
end
end
rescue IOError, Errno::EPIPE
rescue Exception
@printer.print_error "INTERNAL ERROR!!! #{$!}\n" rescue nil
- @printer.print_error $!.backtrace.map{|l| "\t#{l}"}.join("\n") rescue nil
+ @printer.print_error $!.backtrace.map{|l| "\t#{l}"}.join("\n") rescue nil
ensure
@interface.close
end
def process_context_commands(input)
unless Debugger.event_processor.at_line?
- @printer.print_error "There is no thread suspended at the time and therefore no context to execute '#{input.gsub('%', '%%')}'"
+ @printer.print_error "There is no thread suspended at the time and therefore no context to execute '#{input.gsub('%', '%%')}'"
return
end
context = Debugger.event_processor.context
file = Debugger.event_processor.file
- line = Debugger.event_processor.line
- event_cmds = Command.commands.select{|cmd| cmd.event }
+ line = Debugger.event_processor.line
+ event_cmds_classes = Command.commands.select{|cmd| cmd.event}
state = State.new do |s|
s.context = context
s.file = file
s.line = line
s.binding = context.frame_binding(0)
s.interface = @interface
- s.commands = event_cmds
end
- commands = event_cmds.map{|cmd| cmd.new(state, @printer) }
+ event_cmds = event_cmds_classes.map{|cmd| cmd.new(state, @printer) }
catch(:debug_error) do
-
splitter[input].each do |input|
# escape % since print_debug might use printf
@printer.print_debug "Processing context: #{input.gsub('%', '%%')}"
- if cmd = commands.find{ |c| c.match(input) }
+ if cmd = event_cmds.find{ |c| c.match(input) }
if context.dead? && cmd.class.need_context
@printer.print_msg "Command is unavailable\n"
else
cmd.execute
end
@@ -91,15 +89,17 @@
end
m
end
end
end
- end
+ end
+
class State # :nodoc:
+
attr_accessor :context, :file, :line, :binding
attr_accessor :frame_pos, :previous_line
- attr_accessor :interface, :commands
+ attr_accessor :interface
def initialize
@frame_pos = 0
@previous_line = nil
@proceed = false
@@ -118,13 +118,12 @@
@proceed = true
end
end
class ControlState # :nodoc:
- attr_reader :commands
- def initialize(interface, commands)
+
+ def initialize(interface)
@interface = interface
- @commands = commands
end
def proceed
end