RubyFlux: 一个Ruby转Java的编译器

jopen 11年前

RubyFlux 是一个编译器,用来将 Ruby 代码转成对应的 Java 代码,并可在 JVM 中运行,而无需其他运行环境的要求。

每个 Ruby 类生成一个对应的 Java 文件。

使用示例:

# The file we want to compile    $ cat fib.rb  def fib(a)    if a < 2      a    else      fib(a - 1) + fib(a - 2)    end  end    puts fib(40)    # First need to build the compiler's jar    $ mvn package  <maven noise>    # Provide the target file to 'rake run'.  #  # The Ruby sources are translated to .java and all support code is copied out  # of RubyFlux for the compilation step. That source is then compiled and run.  # to compile    $ rake run[fib.rb]  jruby -I target:src/main/ruby src/main/ruby/ruby_flux.rb fib.rb  javac fib.java  java fib  102334155

项目主页:http://www.open-open.com/lib/view/home/1356773764135