Add stub for virtual_machine

This commit is contained in:
Andrew Morris
2022-04-28 20:23:26 +10:00
parent a7f1843994
commit 0b729f0168
3 changed files with 28 additions and 2 deletions

View File

@@ -1,5 +1,6 @@
mod assemble;
mod run;
mod virtual_machine;
use std::env;
use std::process::exit;

View File

@@ -1,4 +1,5 @@
use super::assemble::assemble;
use super::virtual_machine::VirtualMachine;
use std::process::exit;
pub fn command(args: &Vec<String>) {
@@ -19,8 +20,10 @@ pub fn command(args: &Vec<String>) {
let bytecode = to_bytecode(&args[2], &args[3]);
std::println!("Found {} bytes of bytecode", bytecode.len());
std::panic!("Not implemented: Run bytecode");
let mut vm = VirtualMachine::new();
vm.load(bytecode);
vm.run();
vm.print();
}
fn to_bytecode(option: &String, file_path: &String) -> Vec<u8> {

View File

@@ -0,0 +1,22 @@
#[derive(Default)]
pub struct VirtualMachine {
bytecode: Vec<u8>,
}
impl VirtualMachine {
pub fn load(&mut self, bytecode: Vec<u8>) {
self.bytecode = bytecode;
}
pub fn run(&mut self) {
std::panic!("Not implemented");
}
pub fn new() -> Self {
return Default::default();
}
pub fn print(&self) {
std::panic!("Not implemented");
}
}