bytevm

Crates.iobytevm
lib.rsbytevm
version
sourcesrc
created_at2025-03-10 21:25:00.848955+00
updated_at2025-04-19 19:39:23.501298+00
descriptionA tiny bytecode virtual machine
homepage
repositoryhttps://github.com/burdockcascade/bytevm
max_upload_size
id1587243
Cargo.toml error:TOML parse error at line 17, column 1 | 17 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include`
size0
Peter Richmond (burdockcascade)

documentation

README

Project Status: Beta License: MIT crates.io tests docs crates

ByteVM

ByteVM is a bytecode virtual machine written in Rust. It is designed to execute programs written in a custom bytecode format. The VM is designed to be fast, efficient, and easy to use. It is intended to be used as a platform for implementing programming languages, interpreters, and compilers.

Status

ByteVM is currently in the early stages of development. The VM is not yet feature complete, and the API is subject to change. The VM is not yet suitable for production use.

Examples


let mut program  = ProgramBuilder::default();

program.add_function(FunctionBuilder::default()
    .name("main")
    .arity(0)
    .body(BlockEncoder::default()
        // Declare a local variable to hold the input
        .declare_local("n")
        .push_integer(input)
        .set_local("n")
        
        // Call the fib function
        .get_local("n")
        .call_function_by_name("fib")
        
        // Return the result
        .return_value()
    )
    .build()
);

program.add_function(FunctionBuilder::default()
    .name("fib")
    .arity(1)
    .body(BlockEncoder::default()
        // Declare local variables for the Fibonacci function
        .declare_local("n")
        
        // if n <= 1 then return n
        .get_local("n")
        .push_integer(1)
        .less_than_or_equal()
        .jump_if_false("end")
        .get_local("n")
        .return_value()
        .add_label("end")
        
        // fib(n - 1)
        .get_local("n")
        .push_integer(1)
        .sub()
        .call_function_by_name("fib")
        
        // fib(n - 2)
        .get_local("n")
        .push_integer(2)
        .sub()
        .call_function_by_name("fib")
        
        // add the results of fib(n-1) and fib(n-2)
        .add()
        
        // return the result
        .return_value())
    .build()
);

let mut vm = Vm::default();
vm.load_program(program.build());
vm.run(None);

Use of AI

Parts of this project were generated using AI tools.

License

ByteVM is distributed under the terms of the MIT license. See LICENSE for details.

Commit count: 0

cargo fmt