mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
f50936e8bd
Replace complex flat array packing with simple cons-list storage to reduce memory overhead and code complexity. This continues the compiler simplification work by reverting array nodes to the original memory-efficient approach. - Remove len/flags fields from mrb_ast_array_node structure - Eliminate complex two-pass processing (count + copy) in new_array() - Replace array indexing with cons-list iteration in gen_array_var() - Reduce parser code from 30+ lines to 4 lines for array creation - Maintain full functionality with zero test regressions Following the same successful pattern used for mrb_ast_case_node upgrade, this change proves that flat array packing provides no memory benefit since cons lists aren't recycled, while adding unnecessary complexity. 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