Ruby2c 1.0.0.7 Released

ruby2c version 1.0.0.7 has been released!

ruby_to_c translates a static ruby subset to C. Hopefully it works.

NOTE ! NOTE ! NOTE ! NOTE ! NOTE ! NOTE ! NOTE ! NOTE ! NOTE

                 THIS IS BETA SOFTWARE!

NOTE ! NOTE ! NOTE ! NOTE ! NOTE ! NOTE ! NOTE ! NOTE ! NOTE

RubyToC has the following modules:

  • Rewriter - massages the sexp into a more consistent form.
  • TypeChecker - type inferencer for the above sexps.
  • RubyToRubyC - converts a ruby (subset) sexp to ruby interals C.
  • RubyToAnsiC - converts a ruby (subset) sexp to ANSI C.

and the following tools:

  • translate.rb - Translates a given file to C.

Changes:

1.0.0.7 / 2009-08-18

  • 1 bug fix:

    • Removed unnecessary require on unified_ruby
  • translate.rb - Translates a given file to C.

Unable to find file.

If anyone’s looking for an example of how to use it, here’s one.
http://betterlogic.com/roger/?p=1849

Cheers.
-r

Roger P. wrote:

  • translate.rb - Translates a given file to C.

Unable to find file.

If anyone’s looking for an example of how to use it, here’s one.
http://betterlogic.com/roger/?p=1849

Cheers.
-r

$ irb
irb(main):001:0> require ‘ruby_parser’
=> true
irb(main):002:0> require ‘ruby_to_ruby_c’
=> true
irb(main):003:0> all = RubyParser.new.parse(File.read ‘hello.rb’)
NoMethodError: undefined method clear' for nil:NilClass from /usr/lib/ruby/gems/1.8/gems/ruby_parser-2.0.4/lib/ruby_parser_extras.rb:938:in reset’
from
/usr/lib/ruby/gems/1.8/gems/ruby_parser-2.0.4/lib/ruby_parser_extras.rb:766:in
reset' from /usr/lib/ruby/gems/1.8/gems/ruby_parser-2.0.4/lib/ruby_parser_extras.rb:345:in initialize’
from (irb):3:in `new’
from (irb):3
irb(main):004:0>

On Aug 19, 2009, at 09:42 , Reid T. wrote:

irb(main):002:0> require ‘ruby_to_ruby_c’
from (irb):3
irb(main):004:0>

Don’t bring it up here. File a bug.

On Aug 19, 2009, at 10:31 , Ryan D. wrote:

$ irb
from /usr/lib/ruby/gems/1.8/gems/ruby_parser-2.0.4/lib/
ruby_parser_extras.rb:345:in initialize' from (irb):3:innew’
from (irb):3
irb(main):004:0>

Don’t bring it up here. File a bug.

But you’ll have to provide better information. This works fine for me:

% ruby -v -I…/lib -rubygems -e ‘require “ruby_parser”; require
“ruby_to_ruby_c”; p RubyParser.new.parse(File.read(“hello.rb”))’
ruby 1.8.6 (2008-08-11 patchlevel 287) [universal-darwin9.0]
s(:class, :Hello, nil, s(:scope, s(:block, s(:defn, :hello, s(:args),
s(:scope, s(:block, s(:call, nil, :puts, s(:arglist, s(:str, “hello
world”)))))), s(:defn, :main, s(:args), s(:scope, s(:block, s(:call,
nil, :hello, s(:arglist)), s(:return, s(:lit, 0))))))))

Ryan D. wrote:

world")))))), s(:defn, :main, s(:args), s(:scope, s(:block, s(:call,
nil, :hello, s(:arglist)), s(:return, s(:lit, 0))))))))

hmm – looks like it’s only an issue in irb…

rthompso@raker>/usr/lib/ruby/gems/1.8/gems/ruby2c-1.0.0.7/demo
$ ruby -v -I…/lib -rubygems -e ‘require “ruby_parser”; require
“ruby_to_ruby_c”; p RubyParser.new.parse(File.read(“hello.rb”))’
ruby 1.8.7 (2009-06-12 patchlevel 174) [i686-linux]
s(:class, :Hello, nil, s(:scope, s(:block, s(:defn, :hello, s(:args),
s(:scope,
s(:block, s(:call, nil, :puts, s(:arglist, s(:str, “hello world”)))))),
s(:defn,
:main, s(:args), s(:scope, s(:block, s(:call, nil, :hello, s(:arglist)),
s(:return, s(:lit, 0))))))))
rthompso@raker>/usr/lib/ruby/gems/1.8/gems/ruby2c-1.0.0.7/demo

$ irb
irb(main):001:0> require “ruby_parser”
=> true
irb(main):002:0> require “ruby_to_ruby_c”
=> true
irb(main):003:0> p RubyParser.new.parse(File.read(“hello.rb”))
NoMethodError: undefined method clear' for nil:NilClass from /usr/lib/ruby/gems/1.8/gems/ruby_parser-2.0.4/lib/ruby_parser_extras.rb:938:inreset’
from
/usr/lib/ruby/gems/1.8/gems/ruby_parser-2.0.4/lib/ruby_parser_extras.rb:766:in
reset' from /usr/lib/ruby/gems/1.8/gems/ruby_parser-2.0.4/lib/ruby_parser_extras.rb:345:ininitialize’
from (irb):3:in `new’
from (irb):3

On Aug 19, 2009, at 12:22 , Reid T. wrote:

s(:block, s(:call, nil, :hello, s(:arglist)), s(:return, s(:lit,
0))))))))

hmm – looks like it’s only an issue in irb…

cool. that’s enough info. please file a bug.