cgen: split keys and values in generated new_map_init calls into separate lines

Delyan Angelov 2022-05-25 09:30:34 +03:00 committed by Jef Roosens
parent fcabcfc048
commit f9515f7515
Signed by: Jef Roosens
GPG Key ID: B75D4F293C7052DB
1 changed files with 13 additions and 7 deletions

View File

@ -3630,20 +3630,24 @@ fn (mut g Gen) map_init(node ast.MapInit) {
} }
if size > 0 { if size > 0 {
if value_sym.kind == .function { 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 { } 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 { for expr in node.keys {
g.write('\t\t\t')
g.expr(expr) g.expr(expr)
g.write(', ') g.writeln(', ')
} }
g.writeln('\t\t}),')
if value_sym.kind == .function { if value_sym.kind == .function {
g.write('}), _MOV((voidptr[$size]){') g.writeln('\t\t_MOV((voidptr[$size]){')
} else { } else {
g.write('}), _MOV(($value_typ_str[$size]){') g.writeln('\t\t_MOV(($value_typ_str[$size]){')
} }
for i, expr in node.vals { for i, expr in node.vals {
g.write('\t\t\t')
if expr.is_auto_deref_var() { if expr.is_auto_deref_var() {
g.write('*') g.write('*')
} }
@ -3652,12 +3656,14 @@ fn (mut g Gen) map_init(node ast.MapInit) {
} else { } else {
g.expr(expr) g.expr(expr)
} }
g.write(', ') g.writeln(', ')
} }
g.write('}))') g.writeln('\t\t})')
g.writeln('\t)')
} else { } else {
g.write('new_map${noscan}(sizeof($key_typ_str), sizeof($value_typ_str), $hash_fn, $key_eq_fn, $clone_fn, $free_fn)') 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 { if g.is_shared {
g.write('}, sizeof($shared_styp))') g.write('}, sizeof($shared_styp))')
} else if is_amp { } else if is_amp {