mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
3e10aaf6c1
added stmts_push(p, stmts, stmt) helper function to properly push statements to NODE_STMTS nodes by accessing the internal stmts field (a cons list). this avoids ugly casts and prevents bugs. fixed incorrect usage in: - top_stmts rule (line 2081): was calling push($1, ...) directly on NODE_STMTS instead of pushing to $1->stmts - bodystmt rule (line 2114): same issue when handling else without rescue - stmts rule (line 2146): simplified to use new helper for consistency the push macro works on cons lists, not NODE_STMTS variable nodes. the new helper encapsulates the cast and provides type-safe access. 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