You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 2, 2019. It is now read-only.
ColdRuby is a compiler of Ruby 1.9 MRI bytecode, and a runtime written in JavaScript to aid in execution of Ruby code. It also includes a C++ executable using very fast V8 scripting engine and native extensions for regular expressions, fibers and more.
ColdRuby consists mainly of two distinctive parts: the bytecodecompiler, which produces JavaScript code from YARV bytecode and runs onYARV itself, and the Ruby runtime library implemented in plainJavaScript. There is no direct link between parts; it is perfectlypossible to pre-compile a bunch of source files and then load them inany ECMAScript capable agent, like Web browser, Flash applet or astandalone runner.
There is also an executable, which incorporates V8 JavaScript engineand allows standalone execution of Ruby scripts. It has its ownextension interface, which is used to provide native-dependingfunctionality to the runtime: regular expressions, fibers and more.
API
The API provided is, by an interesting coincidence, very similar to theRuby C API (I, the author of ColdRuby, personally think that it is oneof the best C APIs ever). It still may undergo major changes, so itwon't be documented now; you can look in a generic runtime classimplementation (likeruntime/05_hash.js) or in the Ruby runtimeitself (runtime/01_ruby.js).
Usage
Currently there are two modes of operation: standalone and pureJavaScript. Both require the Ruby 1.9 installation. As there may besome differences in internal format of bytecode, which is parsed inColdRuby, I should note that everything is currently tested on1.9.2-p136. The bytecode version used is[1, 2, 1].
Using standalone interpreter
Standalone interpreter is based on V8 engine; as such, you will needthe developer files for that library. They are contained in packagelibv8-dev on Debian.
The build process is based on standard autoconf utilites.
If you've checked out the git version, you will need to runautoreconf -iin the root of repository; if you do not want to install it to your system,but rather use from the build directory, you should pass--enable-developer-mode flag to configure script.
To build, just run./configure && make.
After the build has finished, you can execute scripts with the binary locatedat./coldruby/coldruby.
Compiling to pure JavaScript
You can use the executable to generate the code for Chrome browser or NodeJS.To do that, you'll need to pass the-s option. If you'll specify a filename(note that getopt expects it to be joined with the option, i.e.-sfilename.js), the compiled code will be written to that file. Then, youcan run it in your favorite JavaScript interpreter.
Some examples of code runnable in browser and NodeJS will be provided oncethe extension API will mature.
About
ColdRuby is a compiler of Ruby 1.9 MRI bytecode, and a runtime written in JavaScript to aid in execution of Ruby code. It also includes a C++ executable using very fast V8 scripting engine and native extensions for regular expressions, fibers and more.