add vm -_-
This commit is contained in:
parent
a80e9bbccb
commit
13135c7da6
@ -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,
|
||||||
|
@ -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
26
src/vm.rs
Normal 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) {}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user