xxuejie/webruby — pull request #15 by sadasant (2014-05-13 22:45:19+00:00)
Title: Adding the function compile_to_file and the internal webruby_internal_compile

Hello @xxuejie

I've been needing to compile mruby code in the browser to generate valid bytecode, the best approach I could find is to add a new javascript function, I called it `compile_to_file(src, file_name)`, and it needs a new function in `driver.c` called `webruby_internal_compile`. I've been working with it in an old fork of webruby, this is an adaptation for the last available webruby, it might need some polishes, but please let me know your opinion and any change you wish to make in order to merge this. Feel free to discard this pull request too.

I had some help of @scalone to make this happen :)

As a side note, I saw that the other javascript functions (`run_bytecode`, `run_source`) are available depending on the variable `mode`. I'm proposing here to use `if mode > 2` for `compile_to_file`, if you agree, please tell me so I can add the commits changing the template's Rakefile and the other places where the `mode` is set.

Thanks for your time!