Opcode calling

This commit is contained in:
2026-03-14 00:09:53 +01:00
parent af5e7d26f8
commit 13a9c59364
+8 -1
View File
@@ -14,6 +14,7 @@ pub struct Function {
pub struct Runtime { pub struct Runtime {
pub registry: Registry, pub registry: Registry,
pub functions: HashMap<String, Function>, pub functions: HashMap<String, Function>,
pub opcodes: HashMap<String, Box<dyn Fn(Vec<String>)>>,
} }
impl Registry { impl Registry {
@@ -27,6 +28,7 @@ impl Runtime {
Self { Self {
registry: Registry::new(), registry: Registry::new(),
functions: HashMap::new(), functions: HashMap::new(),
opcodes: HashMap::new(),
} }
} }
} }
@@ -53,7 +55,12 @@ impl Runtime {
for statement in statements { for statement in statements {
match statement { match statement {
Statement::Instruction(inst) => { Statement::Instruction(inst) => {
println!("{inst:#?}"); let op = self
.opcodes
.get(&inst.opcode.to_lowercase())
.expect("Invalid opcode");
(op)(vec![]);
} }
_ => {} _ => {}
} }