mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
01b2a7bd22
Remove conditional logic and consolidate NODE_IF implementation to use variable-sized nodes exclusively. This eliminates dual code paths and completes the NODE_IF migration started in previous commits. Changes: - inline new_if_var into new_if, remove p->var_nodes_enabled condition - remove new_unless function, replace calls with new_if (swap then/else) - remove codegen_if function, merge nil? optimization into gen_if_var - remove NODE_IF case from main codegen switch (always wrapped in NODE_VARIABLE) - fix nil? optimization to handle both traditional and variable-sized nodes - update gen_if_var to use direct struct field access instead of macros The nil? optimization now works with both node representations: - Traditional: NODE_TYPE(condition) == NODE_CALL (preserved) - Variable-sized: NODE_VARIABLE wrapper containing NODE_CALL struct This ensures obj.nil? patterns generate optimized OP_JMPNIL bytecode regardless of AST node representation. 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