lib/iseq_extra.rb in rb-threadframe-0.39 vs lib/iseq_extra.rb in rb-threadframe-0.40

- old
+ new

@@ -1,7 +1,7 @@ require 'digest/sha1' -require_relative '../ext/thread_frame' +require_relative '../ext/thread_frame' if '1.9.2' == RUBY_VERSION # Some additions to RubyVM::InstructionSequence class RubyVM::InstructionSequence # Turns a instruction sequence type field into a string name TYPE2STR = %w(top method block class rescue ensure eval main guard) @@ -139,20 +139,21 @@ end end if __FILE__ == $0 # Demo it. - iseq = RubyVM::ThreadFrame.current.iseq - puts iseq.format_args + iseq = RubyVM::Frame.current.iseq + ## FIXME + ## puts iseq.format_args puts iseq.disassemble puts iseq.lineoffsets puts iseq.sha1 p iseq.line2offsets(__LINE__) p iseq.line2offsets(__LINE__+100) def show_type # :nodoc: - tf = RubyVM::ThreadFrame.current + tf = RubyVM::Frame.current while tf do is = tf.iseq if is ist = tf.iseq.type isn = RubyVM::InstructionSequence::TYPE2STR[ist] @@ -164,15 +165,15 @@ show_type puts '-' * 40 line = __LINE__ def find_line(line) # :nodoc - tf = RubyVM::ThreadFrame.current + tf = RubyVM::Frame.current puts "find_line has lines: #{tf.iseq.lines}" p tf.iseq.find_iseq_with_line(line) end - tf = RubyVM::ThreadFrame.current + tf = RubyVM::Frame.current puts tf.iseq.disassemble puts("offset %d above should be at line %d" % [tf.iseq.locate_line(line), line]) find_line(line+2) find_line(line)