finished try/catch

This commit is contained in:
afonya 2025-06-18 14:21:31 +02:00
parent 3dd28cedd3
commit 6fe9395817
Signed by: afonya
GPG key ID: EBB9C4CAFAAFB2DC
5 changed files with 424 additions and 99 deletions

View file

@ -679,8 +679,12 @@ fn do_ast_op(ast_op: ASTPart, op_count: &mut usize, ops: &mut Vec<Operation>, va
}
},
ASTPart::TryCatch(tc) => {
let catch_f = compile_function(tc.catch_block.body, None, registers, next_var_id, ctx, traceback, None);
let mut try_f = compile_function(tc.try_block.body, None, registers, next_var_id, ctx, traceback, Some(0));
let self_tb = PrevFunc {
variables: variables.clone(),
previous: Some(Box::new(traceback.clone())),
};
let catch_f = compile_function(tc.catch_block.body, Some(tc.catch_block.args), registers, next_var_id, ctx, &self_tb, None);
let mut try_f = compile_function(tc.try_block.body, None, registers, next_var_id, ctx, &self_tb, Some(0));
let mut nextt_f = 1;
for (fid, _) in &try_f.functions {
if fid >= &nextt_f {