Skip to main content

Module runner

Module runner 

Source
Expand description

Shared execution path for the monkey-gc CLI (design doc §7).

Both CLI inputs — .monkey source and .mbc snapshots — funnel into run_bytecode once a Bytecode is in hand, so results and runtime errors render identically on both paths. This deliberately bypasses gc::eval_source: exporting the final value back to an object::Object fails for class instances and drops the runtime-error Span.

Functions§

compile_source
Parse and compile Monkey source, reporting the first error as a string.
run_bytecode
Execute bytecode on a fresh VM and render the final popped value the way the REPL does. instruction_budget is usize::MAX for normal runs; the CLI’s --max-instructions threads a finite budget through here.
run_bytecode_with_output
Execute bytecode on a fresh VM while capturing all puts/print output. The output is returned even when execution fails after producing it.