I did a pretty major refactoring against the code that I shipped last night and streamlined the way data types were marshaled between Ruby and the CLR. Here’s a more concrete example of an add method implemented entirely in CIL that is attached to a Ruby Calc class:

class MarshalParametersToRubyTests < Test::Unit::TestCase
include RbDynamicMethod
class Calc
end
def test_add
create_ruby_instance_method(Calc, 'add') do
declare  'Int32', 'x'
declare  'Int32', 'y'
ldarg_1
ldind_i4
call     'static Marshal.ToInt32(UInt32)'
stloc_s  'x'
ldarg_1
ldc_i4_4
add
ldind_i4
call     'static Marshal.ToInt32(UInt32)'
stloc_s  'y'
ldloc_s  'x'
ldloc_s  'y'
add
call     'static Marshal.ToRubyFixnum(Int32)'
ret
end
assert_equal 7, Calc.new.add(3, 4)
end
end