Implement a Bytecode Machine

Posted On 11.05.2022

Alright, I’m back.

In this commit, I implemented a stack-based bytecode machine so we can execute the
code that was generated by the compiler.

It supports a very small instruction set right now, enough for working with i32 numbers,

No string support for now.

Example usage:

let program = vec![
// print(10 + 5)
OpCode::PUSH as i32, 10,            // 000
OpCode::PUSH as i32, 5,             // 002

We can pass a struct that implements the std::io::Write trait in to the VirtualMachine::run
method to act as the output device, for example, std::io::stdout().