From 3ce6118c3fbb25a193f224416d17bd86205a1db6 Mon Sep 17 00:00:00 2001 From: EmelyanenkoK Date: Sat, 2 Nov 2024 18:23:08 +0300 Subject: [PATCH] Fix try-catch: save c1, c3 to catch continuation (#1332) --- crypto/func/codegen.cpp | 4 ++++ crypto/func/func.h | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/crypto/func/codegen.cpp b/crypto/func/codegen.cpp index de45c8418..aa2972c24 100644 --- a/crypto/func/codegen.cpp +++ b/crypto/func/codegen.cpp @@ -830,6 +830,8 @@ bool Op::generate_code_step(Stack& stack) { catch_stack.push_new_var(left[1]); stack.rearrange_top(catch_vars, catch_last); stack.opt_show(); + stack.o << "c1 PUSH"; + stack.o << "c3 PUSH"; stack.o << "c4 PUSH"; stack.o << "c5 PUSH"; stack.o << "c7 PUSH"; @@ -846,6 +848,8 @@ bool Op::generate_code_step(Stack& stack) { stack.o << "c7 SETCONT"; stack.o << "c5 SETCONT"; stack.o << "c4 SETCONT"; + stack.o << "c3 SETCONT"; + stack.o << "c1 SETCONT"; for (size_t begin = catch_vars.size(), end = begin; end > 0; end = begin) { begin = end >= block_size ? end - block_size : 0; stack.o << std::to_string(end - begin) + " PUSHINT"; diff --git a/crypto/func/func.h b/crypto/func/func.h index e2476911d..25711db8f 100644 --- a/crypto/func/func.h +++ b/crypto/func/func.h @@ -45,7 +45,7 @@ extern std::string generated_from; constexpr int optimize_depth = 20; -const std::string func_version{"0.4.5"}; +const std::string func_version{"0.4.6"}; enum Keyword { _Eof = -1,