RubyFlux: 一個Ruby轉Java的編譯器
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 
                     本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
                         轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
                         本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!