Skip to content
Discussion options

You must be logged in to vote

Yes, that is possible, and saving the compiled code as a RProc is the right way to do it.

One thing to clear up first: mrb_parse_file only gives you the parse tree (AST), not bytecode. The compile step is a separate call. The pipeline is:

  1. mrb_parse_file(mrb, fp, c) returns a mrb_parser_state* (the AST).
  2. mrb_generate_code(mrb, parser) compiles that AST and returns a struct RProc*. This proc holds the bytecode (its irep).
  3. mrb_load_proc(mrb, proc) runs the proc at top level and returns the result. You can call it as many times as you like, with no reparsing and no recompiling.

mrb_load_irep is a different thing: it loads a serialized .mrb byte buffer (the format mrbc produces) and deserial…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@sojastar
Comment options

Answer selected by sojastar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants