mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
b07518e85c
`&nil` is recently introduced in CRuby to explicitly declare that a method does not accept a block. When a block is passed, ArgumentError "no block accepted" is raised. This is analogous to `**nil` for keyword arguments. The noblock flag is encoded in bit 23 of OP_ENTER's aspec operand (24=n1:m5:o5:r1:m5:k5:d1:b1), avoiding the need for a new opcode. 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