This commit is contained in:
afonya2 2025-06-01 17:20:48 +02:00
parent 749ba9a1a9
commit 6f99f9ef62
Signed by: afonya
GPG key ID: EBB9C4CAFAAFB2DC
2 changed files with 40 additions and 17 deletions

View file

@ -12,28 +12,28 @@ pub enum VMMemory {
}
#[derive(Debug, Clone)]
struct VMMemoryString {
value: String,
variable_id: u32,
pub struct VMMemoryString {
pub value: String,
pub variable_id: u32,
}
#[derive(Debug, Clone)]
struct VMMemoryNumber {
value: i64,
variable_id: u32,
pub struct VMMemoryNumber {
pub value: i64,
pub variable_id: u32,
}
#[derive(Debug, Clone)]
struct VMMemoryBoolean {
value: bool,
variable_id: u32,
pub struct VMMemoryBoolean {
pub value: bool,
pub variable_id: u32,
}
#[derive(Debug, Clone)]
struct VMMemoryFunction {
function: DecompiledFunction,
variable_id: u32,
pub struct VMMemoryFunction {
pub function: DecompiledFunction,
pub variable_id: u32,
}
#[derive(Debug, Clone)]
struct VMMemoryNull {
variable_id: u32,
pub struct VMMemoryNull {
pub variable_id: u32,
}
#[derive(Debug, Clone)]
@ -190,7 +190,24 @@ fn do_operation_operation(registers: &mut Vec<Register>, memory: &mut Vec<VMMemo
if memory.get(mem1).is_none() || memory.get(mem2).is_none() {
panic!("Memory location not found for registers");
}
if reg3.unwrap().pointer == 0 {
//TODO: use set memory or something instead of this
let change_mem_type = reg3.unwrap().pointer == 0 || match operation.opcode {
10 => true,
11 | 12 | 13 | 14 | 15 => {
match memory.get(mem3).unwrap() {
VMMemory::Number(_) => false,
_ => true,
}
},
16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 => {
match memory.get(mem3).unwrap() {
VMMemory::Boolean(_) => false,
_ => true,
}
},
_ => false
};
if change_mem_type {
match operation.opcode {
10 => {
match memory.get(mem1).unwrap() {
@ -305,7 +322,7 @@ fn do_operation_operation(registers: &mut Vec<Register>, memory: &mut Vec<VMMemo
_ => panic!("Invalid operation for boolean operation"),
}
},
_ => panic!("Invalid memory types for operation"),
_ => panic!("Invalid memory types for operation, OP: {:?}", operation),
}
}

View file

@ -1,2 +1,8 @@
gethelj a = 1
gethelj b = (a + 2) * 3
gethelj b = (a + 2) * 3
gethelj c = piszv & nem piszv
ha geny (a < b) {
gethelj d = 69
} ha nem geny {
gethelj de = 420
}