From 31c234485a6bd0ce1dd9dc4ee726d065b5d52a0f Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Wed, 25 May 2022 09:30:34 +0300 Subject: [PATCH] cgen: split keys and values in generated new_map_init calls into separate lines --- vlib/v/gen/c/cgen.v | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/vlib/v/gen/c/cgen.v b/vlib/v/gen/c/cgen.v index ce20b6294b..b31ee5e5c6 100644 --- a/vlib/v/gen/c/cgen.v +++ b/vlib/v/gen/c/cgen.v @@ -3630,20 +3630,24 @@ fn (mut g Gen) map_init(node ast.MapInit) { } if size > 0 { if value_sym.kind == .function { - g.write('new_map_init${noscan}($hash_fn, $key_eq_fn, $clone_fn, $free_fn, $size, sizeof($key_typ_str), sizeof(voidptr), _MOV(($key_typ_str[$size]){') + g.writeln('new_map_init${noscan}($hash_fn, $key_eq_fn, $clone_fn, $free_fn, $size, sizeof($key_typ_str), sizeof(voidptr),') } else { - g.write('new_map_init${noscan}($hash_fn, $key_eq_fn, $clone_fn, $free_fn, $size, sizeof($key_typ_str), sizeof($value_typ_str), _MOV(($key_typ_str[$size]){') + g.writeln('new_map_init${noscan}($hash_fn, $key_eq_fn, $clone_fn, $free_fn, $size, sizeof($key_typ_str), sizeof($value_typ_str),') } + g.writeln('\t\t_MOV(($key_typ_str[$size]){') for expr in node.keys { + g.write('\t\t\t') g.expr(expr) - g.write(', ') + g.writeln(', ') } + g.writeln('\t\t}),') if value_sym.kind == .function { - g.write('}), _MOV((voidptr[$size]){') + g.writeln('\t\t_MOV((voidptr[$size]){') } else { - g.write('}), _MOV(($value_typ_str[$size]){') + g.writeln('\t\t_MOV(($value_typ_str[$size]){') } for i, expr in node.vals { + g.write('\t\t\t') if expr.is_auto_deref_var() { g.write('*') } @@ -3652,12 +3656,14 @@ fn (mut g Gen) map_init(node ast.MapInit) { } else { g.expr(expr) } - g.write(', ') + g.writeln(', ') } - g.write('}))') + g.writeln('\t\t})') + g.writeln('\t)') } else { g.write('new_map${noscan}(sizeof($key_typ_str), sizeof($value_typ_str), $hash_fn, $key_eq_fn, $clone_fn, $free_fn)') } + g.writeln('') if g.is_shared { g.write('}, sizeof($shared_styp))') } else if is_amp {