Sirb: The Rubinius Loupe
If my previous post about sirb got you drooling a bit, read on. I’ve added some simple command line arguments to sirb that enable you to request that s-expressions, assembly, or bytecodes (or all of them) are printed each time through the RCEPL loop. You can get a hint at all the goodness by passing the -h switch.
$ ./shotgun/rubinius apps/irb/sirb.rb -h -p -x -s -b
Usage: sirb [options]
sirb is a RCEPL (read, compile, execute, print, loop) program for rubinius
Options:
-p Print the parsed s-expression
-x Print the normalized s-expression.
-s Print assembly instructions.
-b Print bytecode encoding.
sirb(eval):0> puts "Hello, Rubinius. You rock my world!"
S-exp:
[:newline, 1, "(eval)", [:fcall, :puts, [:array, [:str, "Hello, Rubinius. You rock my world!", 0]]]]
Normalized S-exp:
[:newline, 1, "(eval)", [:call, [:self], :puts, [:array, [:str, "Hello, Rubinius. You rock my world!", 0]]]]
Asm:
#line 1
push_literal 0
string_dup
push self
send puts 1
ret
Bytecodes:
"\v\000\000\000\000:\f)\000\000\000\001\000\000\000\001'\000\000\000"
Hello, Rubinius. You rock my world!
=> nil
sirb(eval):1>
As I mentioned, sirb is rudimentary at the moment. But it shows you how much can be done with Rubinius right now. Swell! And, a big thanks to mae for fixing up how the output of the execution prints (no more ["foo"]).
3 Responses to “Sirb: The Rubinius Loupe”
Sorry, comments are closed for this article.
February 11th, 2007 at 03:14 PM
Hawt!
February 11th, 2007 at 04:17 PM
The Ruby Grail. I’ve been clamoring for Rubinius loving, and this is looking fantastic. Keep kicking ass.
February 20th, 2007 at 12:58 PM
Very cool stuff Brian, looks like you’re staying busy.