The DarkVM is a VM that can be targeted by any language. It is written for the Envious programming language, but may targeted by any language. The VM was created with zero-copy, speed, and simplicity in mind. This means that the implementation of the VM uses reference counted values, resembling Swift. Currently, the VM is highly experimental and may change, therefore writing programs in this language is not recommended.
The Code module, which maintains the different values generated by the lexer. The Code struct maintains the values and the current position of the values vector. In the future, it should maintain labels, constants, and other information about the code. This Code struct is called internally and should not be called from the outside.
The Errors module, which contains the Error struct and the ErrorKind enum. These describe the various errors that could occur during the program execution.
The Lexer module, which creates a vector of all of the tokens in the input. This input may come from either a file or a REPL. The Lexer struct tokenizes the input and returns a VecDeque of Tokens The lexer may prematurely return an error if it can not parse a specific character.
The Tokens module, which contains the Token struct and the TokenKind enum. These describe the various tokens that can be recognized.
The Utils module, which contains common utilities such as the stack and frames.
The Values module, which contains the Value struct and ValueKind enum. These describe the various values within the program.
The VM module. This maintains most of the code for the behavior of different instructions and the behavior of the VM in general. The VM struct represents the VM state after any given changes. This struct maintains the code that is given and the stack. This struct also should not change that much. The only changes would be additions to value enum and evaluate_value function.
Runs the VM, and produces either an error, or the final state of the VM after the operations. The errors produced can be found in the utils::error::ErrorKind enum.