mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
FunC: enable asserts and fix try/catch stack corruption (#699)
* FunC: enable asserts in Release * FunC: Fix analyzing infinite loops * FunC: Allow catch with one tensor argument * FunC: Fix try/catch stack corruption --------- Co-authored-by: SpyCheese <mikle98@yandex.ru>
This commit is contained in:
parent
5abfe2337e
commit
583178ccb1
12 changed files with 276 additions and 129 deletions
|
@ -399,7 +399,7 @@ bool check_global_func(const Lexem& cur, sym_idx_t func_name = 0) {
|
|||
cur.loc.show_error(std::string{"undefined function `"} + symbols.get_name(func_name) +
|
||||
"`, defining a global function of unknown type");
|
||||
def = sym::define_global_symbol(func_name, 0, cur.loc);
|
||||
assert(def && "cannot define global function");
|
||||
func_assert(def && "cannot define global function");
|
||||
++undef_func_cnt;
|
||||
make_new_glob_func(def, TypeExpr::new_func()); // was: ... ::new_func()
|
||||
return true;
|
||||
|
@ -1111,6 +1111,7 @@ blk_fl::val parse_do_stmt(Lexer& lex, CodeBlob& code) {
|
|||
}
|
||||
|
||||
blk_fl::val parse_try_catch_stmt(Lexer& lex, CodeBlob& code) {
|
||||
code.require_callxargs = true;
|
||||
lex.expect(_Try);
|
||||
Op& try_catch_op = code.emplace_back(lex.cur().loc, Op::_TryCatch);
|
||||
code.push_set_cur(try_catch_op.block0);
|
||||
|
@ -1132,7 +1133,7 @@ blk_fl::val parse_try_catch_stmt(Lexer& lex, CodeBlob& code) {
|
|||
expr->predefine_vars();
|
||||
expr->define_new_vars(code);
|
||||
try_catch_op.left = expr->pre_compile(code);
|
||||
assert(try_catch_op.left.size() == 2);
|
||||
func_assert(try_catch_op.left.size() == 2 || try_catch_op.left.size() == 1);
|
||||
blk_fl::val res1 = parse_block_stmt(lex, code);
|
||||
sym::close_scope(lex);
|
||||
code.close_pop_cur(lex.cur().loc);
|
||||
|
@ -1295,7 +1296,7 @@ SymValAsmFunc* parse_asm_func_body(Lexer& lex, TypeExpr* func_type, const Formal
|
|||
}
|
||||
lex.next();
|
||||
}
|
||||
assert(arg_order.size() == (unsigned)tot_width);
|
||||
func_assert(arg_order.size() == (unsigned)tot_width);
|
||||
}
|
||||
if (lex.tp() == _Mapsto) {
|
||||
lex.expect(_Mapsto);
|
||||
|
@ -1487,7 +1488,7 @@ void parse_func_def(Lexer& lex) {
|
|||
std::cerr << "function " << func_name.str << " : " << func_type << std::endl;
|
||||
}
|
||||
SymDef* func_sym = sym::define_global_symbol(func_name.val, 0, loc);
|
||||
assert(func_sym);
|
||||
func_assert(func_sym);
|
||||
SymValFunc* func_sym_val = dynamic_cast<SymValFunc*>(func_sym->value);
|
||||
if (func_sym->value) {
|
||||
if (func_sym->value->type != SymVal::_Func || !func_sym_val) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue