Disassemble Some Codes
The RubyVM::InstructionSequence
class makes it easy to compile, disassemble, and inspect bits of Ruby code. We can quickly take a peek under the hood at a simple ruby statement, such as a = 1 + 2
, like so:
It is a bit archaic, but when we get to the line starting with 0002
, we see values (1
and then 2
) pushed onto the stack, then operated on, and finally set on the local variable a
. Fun!
Last updated