cgen: optimize gen c code format

pull/5204/head
yuyi 2020-06-03 23:24:08 +08:00 committed by GitHub
parent 5e2a6ffe65
commit ffafeac0f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View File

@ -2240,7 +2240,7 @@ fn (mut g Gen) index_expr(node ast.IndexExpr) {
}
*/
if need_wrapper {
g.write(', &($elem_type_str[]) { \n')
g.write(', &($elem_type_str[]) { ')
} else {
g.write(', &')
}
@ -2292,7 +2292,7 @@ fn (mut g Gen) index_expr(node ast.IndexExpr) {
g.expr(node.left)
g.write(', ')
g.expr(node.index)
g.write(', &($elem_type_str[]) { \n')
g.write(', &($elem_type_str[]) { ')
} else {
/*
g.write('(*($elem_type_str*)map_get2(')

View File

@ -252,7 +252,13 @@ fn (mut g Gen) gen_fn_decl(it ast.FnDecl) {
if g.pref.is_prof {
g.profile_fn(it.name, is_main)
}
if is_main {
g.indent++
}
g.stmts(it.stmts)
if is_main {
g.indent--
}
// ////////////
if is_main {
if g.autofree {