Class: Debugger::Xml::IdeControlCommandProcessor

Inherits:
Processor
  • Object
show all
Defined in:
lib/debugger/xml/ide_processor.rb

Instance Method Summary collapse

Constructor Details

#initialize(interface) ⇒ IdeControlCommandProcessor

Returns a new instance of IdeControlCommandProcessor.



88
89
90
# File 'lib/debugger/xml/ide_processor.rb', line 88

def initialize(interface)
  @interface = interface
end

Instance Method Details

#process_commandsObject



92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/debugger/xml/ide_processor.rb', line 92

def process_commands
  control_command_classes = Command.commands.select(&:allow_in_control)
  state = ControlCommandProcessor::State.new(@interface, control_command_classes)
  control_commands = control_command_classes.map { |cmd| cmd.new(state) }

  while input = @interface.read_command
    split_commands(input).each do |cmd|
      catch(:debug_error) do
        if matched_cmd = control_commands.find { |c| c.match(cmd) }
          matched_cmd.execute
        else
          process_context_commands(cmd)
        end
      end
    end
  end
rescue IOError, Errno::EPIPE
rescue Exception
  print "INTERNAL ERROR!!! #{$!}\n" rescue nil
  print $!.backtrace.map{|l| "\t#{l}"}.join("\n") rescue nil
ensure
  @interface.close
end