add vm -_-

This commit is contained in:
SimonFJ20 2024-05-31 11:37:28 +02:00
parent a80e9bbccb
commit 13135c7da6
3 changed files with 28 additions and 0 deletions

View File

@ -110,6 +110,7 @@ impl<'syms> FnCompiler<'syms> {
self.push(Op::Pop); self.push(Op::Pop);
} }
} }
self.push(Op::Return);
self.fns.push(Fn { self.fns.push(Fn {
ops: self.ops, ops: self.ops,
data: self.data, data: self.data,

View File

@ -11,6 +11,7 @@ mod parser;
mod sym; mod sym;
mod token; mod token;
mod util; mod util;
mod vm;
fn main() { fn main() {
println!("Hello, world!"); println!("Hello, world!");

26
src/vm.rs Normal file
View File

@ -0,0 +1,26 @@
use crate::ir::Fn;
enum Value {
I32(i32),
U32(u32),
StaticPtr(u32),
Fn(u32),
}
struct Vm<'a> {
fns: &'a Vec<Fn>,
call_stack: Vec<(u64, i32)>,
value_stack: Vec<Value>,
}
impl<'a> Vm<'a> {
pub fn new(fns: &'a Vec<Fn>) -> Self {
Self {
fns,
call_stack: Vec::new(),
value_stack: Vec::new(),
}
}
pub fn run(&mut self, entry: u64) {}
}