Sha256: 50855fe028aa37bf582d3fb0ff68d43885e2ea916d1ec30e3fe0e16461fc5319

Contents?: true

Size: 763 Bytes

Versions: 2

Compression:

Stored size: 763 Bytes

Contents

require 'internal/vm'

if defined?(RubyVM::InstructionSequence) then
  require 'decompiler/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

2 entries across 2 versions & 1 rubygems

Version Path
ruby-decompiler-0.0.3 lib/decompiler/vm/iseq/as_code.rb
ruby-decompiler-0.0.2 lib/decompiler/vm/iseq/as_code.rb