mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
6e68e9f5e2
- Implement complete variable-sized node generation for all class/module types - gen_class_var(): full class definition with namespace and superclass support - gen_module_var(): complete module definition with proper scope handling - gen_sclass_var(): singleton class with object evaluation and OP_SCLASS - All use scope_body() for proper locals and body management - Update parser to always create variable-sized nodes - Inline helper function logic directly into new_class(), new_module(), new_sclass() - Remove conditional var_nodes_enabled checks for consistency - Eliminate separate _var helper functions - Remove obsolete traditional node handling - Delete codegen_class(), codegen_module(), codegen_sclass() functions - Remove NODE_CLASS, NODE_MODULE, NODE_SCLASS cases from main codegen() switch - Clean up unused function declarations - All 1730 tests pass, class/module/singleton functionality verified 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