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

master
Delyan Angelov 2022-05-25 09:30:34 +03:00
parent e19ac0c4a7
commit 31c234485a
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
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 {