fixing2
This commit is contained in:
parent
749ba9a1a9
commit
6f99f9ef62
2 changed files with 40 additions and 17 deletions
|
@ -12,28 +12,28 @@ pub enum VMMemory {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
struct VMMemoryString {
|
pub struct VMMemoryString {
|
||||||
value: String,
|
pub value: String,
|
||||||
variable_id: u32,
|
pub variable_id: u32,
|
||||||
}
|
}
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
struct VMMemoryNumber {
|
pub struct VMMemoryNumber {
|
||||||
value: i64,
|
pub value: i64,
|
||||||
variable_id: u32,
|
pub variable_id: u32,
|
||||||
}
|
}
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
struct VMMemoryBoolean {
|
pub struct VMMemoryBoolean {
|
||||||
value: bool,
|
pub value: bool,
|
||||||
variable_id: u32,
|
pub variable_id: u32,
|
||||||
}
|
}
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
struct VMMemoryFunction {
|
pub struct VMMemoryFunction {
|
||||||
function: DecompiledFunction,
|
pub function: DecompiledFunction,
|
||||||
variable_id: u32,
|
pub variable_id: u32,
|
||||||
}
|
}
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
struct VMMemoryNull {
|
pub struct VMMemoryNull {
|
||||||
variable_id: u32,
|
pub variable_id: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[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() {
|
if memory.get(mem1).is_none() || memory.get(mem2).is_none() {
|
||||||
panic!("Memory location not found for registers");
|
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 {
|
match operation.opcode {
|
||||||
10 => {
|
10 => {
|
||||||
match memory.get(mem1).unwrap() {
|
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 operation for boolean operation"),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
_ => panic!("Invalid memory types for operation"),
|
_ => panic!("Invalid memory types for operation, OP: {:?}", operation),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
8
test.as
8
test.as
|
@ -1,2 +1,8 @@
|
||||||
gethelj a = 1
|
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
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue