After some time's work, now I finally got a working irb for mruby. I'm such a lazy guy so you may already seen the demo from this, this or this. Anyway, for those of you who didn't see it, the demo is at here.
With all the work in webruby, actually it is not so hard to implement this. However, there are still two things I want to write down here as notes.
For simplicity, the web irb uses mrb_load_string to parse and execute ruby source together. Now here comes the problem, the function signature is like following:
Luckily, we do not need the return value here. Hence we can simply create a wrapper:
If at later times we decide to add logic to check the return value of mrb_load_string, we can simply added it here. For this driver function, the generated js function would only requires two arguments: the mrb state and the string to load.
Emscripten has a built-in optimizer, but it wouldn't work with mruby:
Oops, maybe I need to turn to Alon for help here-_-
Anyway, I've already created the repository for this, let's see if I can make this work:)