Stuff about software development, agile and testing

Thursday, November 29, 2007

jruby closure decompiled

Its quite interesting to look into the compiled class file generated by JRuby. Following is the sample java code generated for a closure (1.times { puts 'in closure' }) .

private static ByteList __18 = ByteList.create("in closure");
.....
.....
public IRubyObject closure0(ThreadContext threadcontext, IRubyObject irubyobject, IRubyObject airubyobject[])
{
Ruby ruby;
IRubyObject irubyobject1 = (ruby = threadcontext.getRuntime()).getNil();
DynamicScope dynamicscope = threadcontext.getCurrentScope();
IRubyObject _tmp = irubyobject1;
do
{
try
{
threadcontext.setPosition(__15);
return _17.call(threadcontext, irubyobject, RuntimeHelpers.constructObjectArray(ruby.newStringShared(__18)));
}
catch(org.jruby.exceptions.JumpException.RedoJump _ex) { }
} while(true);
}

RedoJump exception is used to simulate ruby redo

Tuesday, November 27, 2007

inpsect gem file

Playing around with RubyGems source code. So first thing I wanted to know is the gemspec.

Here is a small script to inspect any gem file

require 'yaml'
require 'rubygems/source_info_cache'

Gem::SourceInfoCache.cache
spec = Gem::SourceInfoCache.search('#{gem}')
p spec.to_yaml

You could also use Gem::SourceIndex to spec out locally installed gems

Sunday, November 11, 2007

My new X


Finally I got Leopard installed in my Mac..... :)

Labels