Crate budvm

source ·
Expand description

A safe, dynamically-typed virtual machine

This crate provides a stack-based virtual machine that can be used to implement dynamically typed languages. Bud is the language that this crate was originally designed for.

Safety

This crate uses #[forbid(unsafe_code)] and has no external dependencies. The only unsafe code blocks are located within Rust’s standard library. Any panics encountered should be considered a bug and reported.

How to use

Bud can be used as a complete example of how to build a language and REPL with this crate. There are two simpler examples demonstrating a recursive fibonacci number function:

  • fib-vm: Implemented using virtual machine instructions.
  • fib-ir: Implemented using intermediate representation (IR) with conveniences like variable management and labels.

In all cases, the VirtualMachine type is used to execute instructions. Its documentation goes into detail how it operates.

Modules

  • A HashMap implementation that provides a defined iteration order.
  • An intermediate representation of virtual machine instructions.
  • Utilities shared between Bud Assembly and Bud.

Structs

Enums

Traits