mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
272c325881
Consolidate NODE_WHILE/NODE_UNTIL with MOD variants by sharing structures and implementations, eliminating redundant code and improving maintainability. Changes: - remove separate mrb_ast_while_mod_node and mrb_ast_until_mod_node structures - share mrb_ast_while_node between NODE_WHILE and NODE_WHILE_MOD variants - share mrb_ast_until_node between NODE_UNTIL and NODE_UNTIL_MOD variants - simplify new_while_mod to call new_while and update node_type - simplify new_until_mod to call new_until and update node_type - update gen_while_mod_var and gen_until_mod_var to use shared structures The MOD variants now reuse core allocation logic from regular variants, differing only in node_type. This eliminates code duplication while preserving identical functionality for both pre-tested and post-tested loops. Co-authored-by: Claude <noreply@anthropic.com>
mruby-compiler
This mrbgem provides the mruby compiler, which is responsible for parsing Ruby code and generating mruby bytecode.
Functionality
The mruby-compiler gem includes the following components:
- Parser: Translates Ruby source code into an abstract syntax tree (AST).
- Code Generator: Traverses the AST to produce executable mruby bytecode.
mrbcexecutable: A command-line tool for compiling.rbfiles into.mrbbytecode files.
Usage
The mrbc (mruby-bin-mrbc) executable will generate compiled binary from Ruby
programs via this gem.
Example of using mrbc:
# Compile a Ruby script to bytecode
bin/mrbc my_script.rb
# Run the compiled script
bin/mruby my_script.mrb