added even more opeartions to the VM

This commit is contained in:
afonya2 2025-06-01 16:56:07 +02:00
parent 7c2c29fb1a
commit c901731119
Signed by: afonya
GPG key ID: EBB9C4CAFAAFB2DC
2 changed files with 81 additions and 6 deletions

View file

@ -200,7 +200,6 @@ fn do_ast_op(ast_op: ASTPart, op_count: &mut usize, ops: &mut Vec<Operation>, va
},
ASTPart::If(if_part) => {
let condition_reg = do_ast_op(*if_part.condition, op_count, ops, var_ids, next_var_id, strings, next_string_id, functions, next_function_id, registers);
ops.push(Operation { opcode: 30, arg1: Some(condition_reg), arg2: Some(2), arg3: None });
ops.push(Operation { opcode: 24, arg1: Some(condition_reg), arg2: Some(condition_reg as i64), arg3: None });
//Update the lastif variable
@ -281,7 +280,6 @@ fn do_ast_op(ast_op: ASTPart, op_count: &mut usize, ops: &mut Vec<Operation>, va
ops.push(Operation { opcode: 24, arg1: Some(else_condition_reg), arg2: Some(else_condition_reg as i64), arg3: None });
let condition_reg = do_ast_op(*elseif_part.condition, op_count, ops, var_ids, next_var_id, strings, next_string_id, functions, next_function_id, registers);
ops.push(Operation { opcode: 30, arg1: Some(condition_reg), arg2: Some(2), arg3: None });
ops.push(Operation { opcode: 16, arg1: Some(else_condition_reg), arg2: Some(condition_reg as i64), arg3: Some(condition_reg) });
ops.push(Operation { opcode: 24, arg1: Some(condition_reg), arg2: Some(condition_reg as i64), arg3: None });
@ -314,7 +312,6 @@ fn do_ast_op(ast_op: ASTPart, op_count: &mut usize, ops: &mut Vec<Operation>, va
ASTPart::While(while_part) => {
let start = ops.len();
let condition_reg = do_ast_op(*while_part.condition, op_count, ops, var_ids, next_var_id, strings, next_string_id, functions, next_function_id, registers);
ops.push(Operation { opcode: 30, arg1: Some(condition_reg), arg2: Some(2), arg3: None });
ops.push(Operation { opcode: 24, arg1: Some(condition_reg), arg2: Some(condition_reg as i64), arg3: None });
let op_placeholder = ops.len();
@ -370,7 +367,6 @@ fn do_ast_op(ast_op: ASTPart, op_count: &mut usize, ops: &mut Vec<Operation>, va
do_ast_op(*for_part.init, op_count, ops, var_ids, next_var_id, strings, next_string_id, functions, next_function_id, registers);
let start = ops.len();
let condition_reg = do_ast_op(*for_part.condition, op_count, ops, var_ids, next_var_id, strings, next_string_id, functions, next_function_id, registers);
ops.push(Operation { opcode: 30, arg1: Some(condition_reg), arg2: Some(2), arg3: None });
ops.push(Operation { opcode: 24, arg1: Some(condition_reg), arg2: Some(condition_reg as i64), arg3: None });
let op_placeholder = ops.len();