An open API service indexing awesome lists of open source software.

https://github.com/zw963/pry-disasm

Pry plugin that displays YARV bytecode for a method or expression.
https://github.com/zw963/pry-disasm

Last synced: 10 months ago
JSON representation

Pry plugin that displays YARV bytecode for a method or expression.

Awesome Lists containing this project

README

          

# PryDisasm [![Gem Version](https://badge.fury.io/rb/pry-disasm.svg)](http://badge.fury.io/rb/pry-disasm)

A bunch of code was taken from [pry-internal](https://github.com/cout/pry-internal/tree/master/pry-disasm).

Pry plugin that take a `Method object` or `ruby code` string, and returns a String with the human readable instructions(YARV bytecode) for it.

## Getting Started

Install via Rubygems

$ gem install pry-disasm

then add `require 'pry-disasm'` in your ruby code.

OR ...

Add to your Gemfile

gem 'pry-disasm'

## Usage

See Instruction for a method

```rb
(pry):main(0)> def say_hello; puts 'hello'; end

=> :say_hello

(pry):main(0)> disasm method(:say_hello)

== disasm: # (catch: FALSE)
0000 putself ( 1)[LiCa]
0001 putstring "hello"
0003 opt_send_without_block ,
0006 leave [Re]
```

see Instruction of a expression

```rb
(pry):main(0)> disasm '1 + 1'

== disasm: #@:1 (1,0)-(1,5)> (catch: FALSE)
0000 putobject_INT2FIX_1_ ( 1)[Li]
0001 putobject_INT2FIX_1_
0002 opt_plus ,
0005 leave

```

## Support

* MRI 1.9.3+

## Contributing

* [Bug reports](https://github.com/zw963/pry-disasm/issues)
* [Source](https://github.com/zw963/pry-disasm)

## license

Released under the MIT license, See [LICENSE](https://github.com/zw963/pry-disasm/blob/master/LICENSE) for details.