add function execution to the VM

This commit is contained in:
afonya2 2025-06-03 18:32:52 +02:00
parent 598f4a0cdb
commit a5c2420d20
Signed by: afonya
GPG key ID: EBB9C4CAFAAFB2DC
4 changed files with 82 additions and 26 deletions

View file

@ -217,7 +217,12 @@ fn do_ast_op(ast_op: ASTPart, op_count: &mut usize, ops: &mut Vec<Operation>, va
ops.push(Operation { opcode: 28, arg1: Some(arg_reg), arg2: None, arg3: None });
set_register(registers, RegisterState { id: arg_reg, used: false, variable: 0, last_used: 0 });
}
ops.push(Operation { opcode: 27, arg1: Some(func), arg2: None, arg3: None });
let ret_reg = allocate_register(registers);
if ret_reg.unbind_before {
ops.push(Operation { opcode: 8, arg1: Some(ret_reg.register), arg2: None, arg3: None });
}
ops.push(Operation { opcode: 27, arg1: Some(func), arg2: Some(ret_reg.register as i64), arg3: None });
return ret_reg.register;
},
ASTPart::If(if_part) => {
let condition_reg = do_ast_op(*if_part.condition, op_count, ops, variables, next_var_id, strings, next_string_id, functions, next_function_id, registers);