2 releases
0.1.1 | Nov 16, 2020 |
---|---|
0.1.0 | Nov 1, 2020 |
#1097 in Programming languages
Used in lovm2_internals
14KB
114 lines
lovm2
lovm2
is a library for building your own programming language in the blink of an eye. It offers you easy to use constructs to generate bytecode for its virtual machine.
⚠️ lovm2 is not actively maintained and might be subject to vulnerabilities.
Features
- Dynamic typing
- Generate bytecode using a High-Level Intermediate Representation
- Define own instructions as
Interrupt
s - Extend your programs with Rust: lovm2 extend
- Standard library included: lovm2_std
- Python bindings: pylovm2
Examples
Add this line to your Cargo.toml
:
lovm2 = { git = "https://github.com/lausek/lovm2", rev = "d454b21" }
Resources
Projects
Generating Bytecode
use lovm2::prelude::*;
let mut module = LV2ModuleBuilder::new();
// declare the variables our code will use
let n = &lv2_var!(n);
// a module needs a code object called `main`
// if you want to make it runnable
let main_hir = module.entry();
// set the local variable n to 10
main_hir.assign(n, 10);
// `print` is a builtin function
main_hir.step(LV2Call::new("print").arg(n).arg("Hello World"));
// creates a `Module` from the `ModuleBuilder`
let module = module.build().unwrap();
println!("{}", module);
// load the module and run it
let mut vm = lovm2::create_vm_with_std();
vm.add_main_module(module).expect("load error");
vm.run().expect("run error");
Internal Source Code References
Customer Reviews
This Thing Fast - Sonic
And I thought I was simple... - Pythagorean Theorem
Dependencies
~2.4–3.5MB
~72K SLoC