Runtime and utilities for the Voxel programming language and VxC virtual machine.
Voxel is a loosely-typed programming language that is designed to be powerful, versatile, easy-to-use and portable. It has a C-like syntax and has many features that can be found in other modern programming languages.
Portability is a key goal of Voxel — especially so that programs written in it can run on low-powered hardware, such as microcontrollers. Voxel achieves this by compiling source code into a bytecode format, called VxC (Voxel Code). Voxel can generate space-efficient bytecode by using a number of optimisations, including name mangling and dead code elimination (DCE) via static code analysis.
Voxel only generates the necessary bytecode to provide the supporting features needed by the main program’s code. As an example, here’s a hex dump of all the bytecode needed to output “Hello, world!”:
56 78 43 01 22 48 65 6c 6c 6f 2c 20 77 6f 72 6c VxC."Hello, worl
64 21 0a 00 33 01 2e 69 6f 5f 6f 75 74 00 70 00 d!..3..io_out.p.
Examples of Voxel programs can be found in the examples
and test
directories.
...
) to dynamically provide argument values to functions and allow functions to become variadic&&
and ||
(evaluation of subsequent operands is aborted if result’s value is guaranteed to be true
or false
)&&&
and |||
(all operands are evaluated — this produces simpler bytecode but may perform unnecessary computations at runtime)push
and pop
methods)this
keyword, including constructor methods that are called by using new
get
or set
)super
keyword to call the constructor method (super()
) or other methods (super.methodName()
)throw
and try
/catch
weak
method to obtain weak reference and deref
method to obtain the referenced valueif
statements and while
loops (due to condition always being true
or false
) is removedthreads
library, which allows multiple functions to be executed concurrentlypatterns
library, which is an alternative to regular expressions found in other programming languagesvoxel_newContext
and loads in the byte buffer from a syscall argument as code for executionBefore compiling projects, you currently must first have Deno installed. We are currently in the process of transitioning VxBuild into a self-hosting compiler.
To compile Voxel source code (.vxl files) into VxC bytecode (.vxc files), run:
deno run --allow-read --allow-write tools/vxbuild-js/vxbuild.js examples/hello.vxl -o examples/build/hello.vxc
To build the Voxel runtime, run:
./build.sh --runtime
You can then run a .vxc file like this:
runtime/build/voxel code.vxc
To build the libvoxel integration example, then run the hello
example code, run:
./build.sh --examples && examples/build/hello
To test all features of Voxel, run:
./test.sh
This will perform all tests listed in the test
directory against their expected outputs and for memory leaks (the latter runs a test’s program in an infinite loop and measures the difference in memory consumption). Tests are automatically performed for new commits on pull requests and must all pass before a pull request can be merged.