1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

cgen: minor cleanup of gen_assert_stmt (#8334)

This commit is contained in:
yuyi 2021-01-25 21:28:34 +08:00 committed by GitHub
parent 02d8ede94d
commit 444d49da75
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1579,7 +1579,6 @@ fn (mut g Gen) gen_assert_stmt(original_assert_statement ast.AssertStmt) {
metaname_panic := g.gen_assert_metainfo(a)
g.writeln('\t__print_assert_failure(&$metaname_panic);')
g.writeln('\tv_panic(_SLIT("Assertion failed..."));')
g.writeln('\texit(1);')
g.writeln('}')
}
}
@ -1594,8 +1593,7 @@ fn (mut g Gen) gen_assert_metainfo(a ast.AssertStmt) string {
line_nr := a.pos.line_nr
src := cestring(a.expr.str())
metaname := 'v_assert_meta_info_$g.new_tmp_var()'
g.writeln('\tVAssertMetaInfo $metaname;')
g.writeln('\tmemset(&$metaname, 0, sizeof(VAssertMetaInfo));')
g.writeln('\tVAssertMetaInfo $metaname = {0};')
g.writeln('\t${metaname}.fpath = ${ctoslit(mod_path)};')
g.writeln('\t${metaname}.line_nr = $line_nr;')
g.writeln('\t${metaname}.fn_name = ${ctoslit(fn_name)};')