Sha256: 49e7dc945f9fda139faa01ff7f19582a3faa7dde4c5f395abf405073ae780480

Contents?: true

Size: 1.17 KB

Versions: 12

Compression:

Stored size: 1.17 KB

Contents

module Debugger
  class EvalCommand < Command # :nodoc:
    self.control = true

    def match(input)
      @input = input
      super
    end
    
    def regexp
      /^\s*(p|e(?:val)?)\s+/
    end

    def execute
      expr = @match ? @match.post_match : @input
      binding = @state.context ? get_binding : TOPLEVEL_BINDING
      print "%s\n", debug_eval(expr, binding).inspect
    end

    class << self
      def help_command
        %w|p eval|
      end

      def help(cmd)
        if cmd == 'p'
          %{
            p expression\tevaluate expression and print its value
          }
        else
          %{
            e[val] expression\tevaluate expression and print its value,
            \t\t\talias for p.
          }
        end
      end
    end
  end

  class PPCommand < Command # :nodoc:
    def regexp
      /^\s*pp\s+/
    end

    def execute
      out = StringIO.new
      PP.pp(debug_eval(@match.post_match), out) rescue out.puts $!.message
      print out.string
    end

    class << self
      def help_command
        'pp'
      end

      def help(cmd)
        %{
          pp expression\tevaluate expression and print its value
        }
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
ruby-debug-0.7.5-mswin32 lib/ruby-debug/commands/eval.rb
ruby-debug-0.7.4-mswin32 lib/ruby-debug/commands/eval.rb
ruby-debug-0.7.3-mswin32 lib/ruby-debug/commands/eval.rb
ruby-debug-0.7.2-mswin32 lib/ruby-debug/commands/eval.rb
ruby-debug-0.7.1-mswin32 lib/ruby-debug/commands/eval.rb
ruby-debug-0.7-mswin32 lib/ruby-debug/commands/eval.rb
ruby-debug-0.7.1 lib/ruby-debug/commands/eval.rb
ruby-debug-0.7.4 lib/ruby-debug/commands/eval.rb
ruby-debug-0.7.3 lib/ruby-debug/commands/eval.rb
ruby-debug-0.7.5 lib/ruby-debug/commands/eval.rb
ruby-debug-0.7.2 lib/ruby-debug/commands/eval.rb
ruby-debug-0.7 lib/ruby-debug/commands/eval.rb