mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
21037456df
Add variable-sized node structures for all control flow statements: - IF/ELSIF/ELSE statements with optimized condition handling - WHILE and UNTIL loops with proper jump generation - FOR loops with iterator support - CASE/WHEN statements with multiple condition matching Key changes: - Added variable-sized node structures (mrb_ast_if_node, mrb_ast_while_node, mrb_ast_until_node, mrb_ast_case_node, mrb_ast_for_node) to node.h - Implemented parser functions with size class allocation in parse.y - Added comprehensive codegen support with proper jump handling and stack management in codegen.c - All control flow nodes now use NODE_VARIABLE wrapper for consistency - Variable-sized nodes enabled by default for improved memory efficiency This provides memory-efficient storage for control flow constructs while maintaining full compatibility with existing functionality. 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