Sha256: 9f4487984bc5937e09cc8ead6f7aa19538eda73c2fe7decd44315bb5705bf9d3

Contents?: true

Size: 1.4 KB

Versions: 15

Compression:

Stored size: 1.4 KB

Contents

module Debugger
  class EvalCommand < Command # :nodoc:
    def match(input)
      @input = input
      super
    end
    
    def regexp
      /^\s*(p|e(?:val)?)(?:\s+(on|off)$|\s+)/
    end

    def execute
      if @match && @match[1] != 'p' && %w[on off].include?(@match[2])
        self.class.unknown = @match[2] == 'on'
        print "Evaluation of unknown command is #{self.class.unknown ? 'on': 'off'}.\n"
        return
      end
      expr = @match ? @match.post_match : @input
      print "%s\n", debug_eval(expr).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.
            e[val] on/off\t\twhen 'on', debugger will evaluate every unknown command.
          }
        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

15 entries across 15 versions & 1 rubygems

Version Path
ruby-debug-0.4.5-mswin32 lib/ruby-debug/commands/eval.rb
ruby-debug-0.6.2-mswin32 lib/ruby-debug/commands/eval.rb
ruby-debug-0.6.1-mswin32 lib/ruby-debug/commands/eval.rb
ruby-debug-0.6-mswin32 lib/ruby-debug/commands/eval.rb
ruby-debug-0.5.2-mswin32 lib/ruby-debug/commands/eval.rb
ruby-debug-0.5.1-mswin32 lib/ruby-debug/commands/eval.rb
ruby-debug-0.5-mswin32 lib/ruby-debug/commands/eval.rb
ruby-debug-0.6 lib/ruby-debug/commands/eval.rb
ruby-debug-0.6.2 lib/ruby-debug/commands/eval.rb
ruby-debug-0.4.5 lib/ruby-debug/commands/eval.rb
ruby-debug-0.5.1 lib/ruby-debug/commands/eval.rb
ruby-debug-0.6.1 lib/ruby-debug/commands/eval.rb
ruby-debug-0.5.2 lib/ruby-debug/commands/eval.rb
ruby-debug-0.5 lib/ruby-debug/commands/eval.rb
ruby-debug-0.5.3 lib/ruby-debug/commands/eval.rb