mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
f0395a1cf7
Following the same pattern as the case node upgrade (e0f07c9), this change eliminates the complex flat array packing approach for hash nodes in favor of simple cons-list storage. The flat array packing provided no memory benefit since cons lists aren't recycled, while adding unnecessary complexity to both allocation and traversal logic. Changes: - Simplified mrb_ast_hash_node structure from variable-sized flexible array to fixed-size structure with cons-list pointer - Reduced new_hash() from complex 30+ line allocation to simple 4-line pattern matching array node implementation - Updated gen_hash_var() to use cons-list iteration instead of interleaved array access (pairs[i*2] for key, pairs[i*2+1] for value) - Removed HASH_NODE_LEN macro as length tracking is no longer needed - Maintains identical functionality while reducing code 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