Sha256: 036b0607e78151ccf63f422d88307beb93031bf28e62b118cb0a081b23f51d68

Contents?: true

Size: 761 Bytes

Versions: 4

Compression:

Stored size: 761 Bytes

Contents

require 'internal/vm'

if defined?(RubyVM::InstructionSequence) then
  require 'internal/vm/bytedecoder'

  class RubyVM
    class InstructionSequence
      def as_code(indent=0)
        env = Internal::ByteDecoder::Environment.new(local_table())
        opt_pc = self.opt_pc
        self.bytedecode(env, opt_pc)
        expressions = env.expressions + env.stack
        if expressions.length == 0 then
          return nil
        elsif expressions.length == 1 and
           expressions[0].is_a?(Internal::ByteDecoder::Expression::Literal) and
           expressions[0].value == nil then
          return nil
        else
          expressions.map! { |e| "#{'  '*indent}#{e}" }
          return expressions.join("\n")
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
ruby-decompiler-0.0.1 lib/decompiler/vm/iseq/as_code.rb
ruby-internal-0.8.2 lib/internal/vm/iseq/as_code.rb
ruby-internal-0.8.1 lib/internal/vm/iseq/as_code.rb
ruby-internal-0.8.0 lib/internal/vm/iseq/as_code.rb