mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
3e7078cef3
replaced unnecessary macro usage with direct struct member access when struct pointers are already available: - return_n->args instead of RETURN_NODE_ARGS(return_n) - yield_n->args instead of YIELD_NODE_ARGS(yield_n) - for_n->var/iterable/body instead of FOR_NODE_VAR/ITERABLE/BODY(for_n) - class_n->name/superclass/body instead of CLASS_NODE_* macros - module_n->name/body instead of MODULE_NODE_NAME/BODY(module_n) - sclass_n->obj/body instead of SCLASS_NODE_OBJ/BODY(sclass_n) - hash->pairs instead of HASH_NODE_PAIRS(hash) - call->method_name/safe_call instead of CALL_NODE_METHOD/SAFE(call) - array->elements and an->elements instead of ARRAY_NODE_ELEMENTS macro - splat->value instead of SPLAT_NODE_VALUE macro improves code readability by removing unnecessary indirection. 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