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

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

This commit is contained in:
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

View File

@ -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 {