Expand description
STK, a simple stack-based virtual machine.
§Contributing
If you want to help out, there’s a number of optimization tasks available in Future Optimizations.
Create an issue about the optimization you want to work on and communicate that you are working on it.
§Features of stk
- Clean Rust FFI.
- Stack-based C FFI like with Lua (TBD).
- Stack frames, allowing for isolation across function calls.
- A rust-like reference language called Rune.
§Rune Scripts
stk comes with a simple scripting language called Rune.
You can run example scripts through rune-cli:
cargo run -- ./scripts/hello_world.rn
If you want to see diagnostics of your unit, you can do:
cargo run -- ./scripts/hello_world.rn --dump-unit --trace
Re-exports§
pub use crate::unit::CompilationUnit;
pub use crate::unit::CompilationUnitError;
Modules§
- packages
- Public packages that can be used to provide functionality to virtual machines.
- tls
- Utilities for storing and accessing the virtual machine from thread-local storage.
- unit
- A single execution unit in the stk virtual machine.
Macros§
- decl_
external - Implement the value trait for an external type.
Structs§
- Any
- Our own private dynamic Any implementation.
- Context
- Static run context visible to the virtual machine.
- Error
- An error raised from a user functions.
- Hash
- The hash of a primitive thing.
- Item
- The name of an item.
- Module
- A collection of functions that can be looked up by type.
- Mut
- Guard for a value exclusively borrowed from a slot in the virtual machine.
- RawMut
Guard - A raw mutable guard.
- RawRef
Guard - A raw reference guard.
- Ref
- Guard for a value borrowed from a slot in the virtual machine.
- Slot
- Compact information on typed slot.
- Task
- The task of a unit being run.
- Unit
- The rust type corresponding to rune’s
None
type. - Vm
- A stack which references variables indirectly from a slab.
Enums§
- Context
Error - An error raised when building the context.
- Inst
- An operation in the stack-based virtual machine.
- Panic
- The reason why a panic was invoked in the virtual machine.
- Stack
Error - An error raised when interacting with types on the stack.
- Value
- A value peeked out of the stack.
- Value
Ptr - An entry on the stack.
- Value
Ref - A value peeked out of the stack.
- Value
Type - The type of an entry.
- Value
Type Info - Type information about a value, that can be printed for human consumption through its Display implementation.
- VmError
- Errors raised by the execution of the virtual machine.
Constants§
- ADD
- The function to implement for the addition operation.
- ADD_
ASSIGN - The function to implement for the addition assign operation.
- DIV
- The function to implement for the division operation.
- DIV_
ASSIGN - The function to implement for the division assign operation.
- INDEX_
GET - The function to access an index.
- INDEX_
SET - The function to set an index.
- MUL
- The function to implement for the multiply operation.
- MUL_
ASSIGN - The function to implement for the multiply assign operation.
- NEXT
- The function to call to continue iteration.
- SUB
- The function to implement for the subtraction operation.
- SUB_
ASSIGN - The function to implement for the subtraction assign operation.
Traits§
- From
Value - Trait for converting from a value.
- Into
Args - Trait for converting arguments into values.
- Reflect
Value Type - Trait for converting types into values.
- ToValue
- Trait for converting types into values.
- Unsafe
From Value - A potentially unsafe conversion for value conversion.
- Unsafe
ToValue - Trait for unsafe conversion of value types into values.