#![warn(rust_2018_idioms)]
mod compiler;
mod instruction;
mod value;
mod vm;
pub use compiler::Compiler;
pub use instruction::Instruction;
use instruction::Program;
use rush_analyzer::ast::AnalyzedProgram;
pub use rush_analyzer::Diagnostic;
pub use value::Value;
pub use vm::{RuntimeError, RuntimeErrorKind, Vm};
pub fn compile(ast: AnalyzedProgram<'_>) -> Program {
Compiler::new().compile(ast)
}
pub fn run(ast: AnalyzedProgram<'_>) -> Result<i64, RuntimeError> {
let program = Compiler::new().compile(ast);
let mut vm = Vm::new();
let exit_code = vm.run(program)?;
Ok(exit_code)
}
pub fn debug_run(ast: AnalyzedProgram<'_>, clock_hz: u64) -> Result<i64, RuntimeError> {
let program = Compiler::new().compile(ast);
let mut vm = Vm::new();
let exit_code = vm.debug_run(program, clock_hz)?;
Ok(exit_code)
}